TestCoordinatorPropogatedPeerContext tests that the context for a specific peer is propogated through to the `Authorize“ method of the coordinatee auth
(t *testing.T)
| 275 | // TestCoordinatorPropogatedPeerContext tests that the context for a specific peer |
| 276 | // is propogated through to the `Authorize“ method of the coordinatee auth |
| 277 | func TestCoordinatorPropogatedPeerContext(t *testing.T) { |
| 278 | t.Parallel() |
| 279 | |
| 280 | ctx := testutil.Context(t, testutil.WaitShort) |
| 281 | logger := testutil.Logger(t) |
| 282 | |
| 283 | peerCtx := context.WithValue(ctx, test.FakeSubjectKey{}, struct{}{}) |
| 284 | peerCtx, peerCtxCancel := context.WithCancel(peerCtx) |
| 285 | peerID := uuid.UUID{0x01} |
| 286 | agentID := uuid.UUID{0x02} |
| 287 | |
| 288 | c1 := tailnet.NewCoordinator(logger) |
| 289 | t.Cleanup(func() { |
| 290 | err := c1.Close() |
| 291 | require.NoError(t, err) |
| 292 | }) |
| 293 | |
| 294 | ch := make(chan struct{}) |
| 295 | auth := test.FakeCoordinateeAuth{ |
| 296 | Chan: ch, |
| 297 | } |
| 298 | |
| 299 | reqs, _ := c1.Coordinate(peerCtx, peerID, "peer1", auth) |
| 300 | |
| 301 | testutil.RequireSend(ctx, t, reqs, &proto.CoordinateRequest{AddTunnel: &proto.CoordinateRequest_Tunnel{Id: tailnet.UUIDToByteSlice(agentID)}}) |
| 302 | _ = testutil.TryReceive(ctx, t, ch) |
| 303 | // If we don't cancel the context, the coordinator close will wait until the |
| 304 | // peer request loop finishes, which will be after the timeout |
| 305 | peerCtxCancel() |
| 306 | } |
nothing calls this directly
no test coverage detected