(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestCoordinator(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | t.Run("ClientWithoutAgent", func(t *testing.T) { |
| 23 | t.Parallel() |
| 24 | logger := testutil.Logger(t) |
| 25 | ctx := testutil.Context(t, testutil.WaitShort) |
| 26 | coordinator := tailnet.NewCoordinator(logger) |
| 27 | defer func() { |
| 28 | err := coordinator.Close() |
| 29 | require.NoError(t, err) |
| 30 | }() |
| 31 | |
| 32 | client := test.NewClient(ctx, t, coordinator, "client", uuid.New()) |
| 33 | defer client.Close(ctx) |
| 34 | client.UpdateNode(&proto.Node{ |
| 35 | Addresses: []string{tailnet.TailscaleServicePrefix.RandomPrefix().String()}, |
| 36 | PreferredDerp: 10, |
| 37 | }) |
| 38 | require.Eventually(t, func() bool { |
| 39 | return coordinator.Node(client.ID) != nil |
| 40 | }, testutil.WaitShort, testutil.IntervalFast) |
| 41 | }) |
| 42 | |
| 43 | t.Run("ClientWithoutAgent_InvalidIPBits", func(t *testing.T) { |
| 44 | t.Parallel() |
| 45 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug) |
| 46 | ctx := testutil.Context(t, testutil.WaitShort) |
| 47 | coordinator := tailnet.NewCoordinator(logger) |
| 48 | defer func() { |
| 49 | err := coordinator.Close() |
| 50 | require.NoError(t, err) |
| 51 | }() |
| 52 | |
| 53 | client := test.NewClient(ctx, t, coordinator, "client", uuid.New()) |
| 54 | defer client.Close(ctx) |
| 55 | |
| 56 | client.UpdateNode(&proto.Node{ |
| 57 | Addresses: []string{ |
| 58 | netip.PrefixFrom(tailnet.TailscaleServicePrefix.RandomAddr(), 64).String(), |
| 59 | }, |
| 60 | PreferredDerp: 10, |
| 61 | }) |
| 62 | client.AssertEventuallyResponsesClosed( |
| 63 | tailnet.AuthorizationError{Wrapped: tailnet.InvalidAddressBitsError{Bits: 64}}.Error()) |
| 64 | }) |
| 65 | |
| 66 | t.Run("AgentWithoutClients", func(t *testing.T) { |
| 67 | t.Parallel() |
| 68 | logger := testutil.Logger(t) |
| 69 | ctx := testutil.Context(t, testutil.WaitShort) |
| 70 | coordinator := tailnet.NewCoordinator(logger) |
| 71 | defer func() { |
| 72 | err := coordinator.Close() |
| 73 | require.NoError(t, err) |
| 74 | }() |
| 75 | |
| 76 | agent := test.NewAgent(ctx, t, coordinator, "agent") |
| 77 | defer agent.Close(ctx) |
nothing calls this directly
no test coverage detected