@@ -422,8 +422,28 @@ func TestCoordinator(t *testing.T) {
422
422
clientID := uuid .New ()
423
423
agentID := uuid .New ()
424
424
425
- aReq , _ := coordinator .Coordinate (ctx , agentID , agentID .String (), tailnet.AgentCoordinateeAuth {ID : agentID })
426
- _ , cRes := coordinator .Coordinate (ctx , clientID , clientID .String (), tailnet.ClientCoordinateeAuth {AgentID : agentID })
425
+ aReq , aRes := coordinator .Coordinate (ctx , agentID , agentID .String (), tailnet.AgentCoordinateeAuth {ID : agentID })
426
+ cReq , cRes := coordinator .Coordinate (ctx , clientID , clientID .String (), tailnet.ClientCoordinateeAuth {AgentID : agentID })
427
+
428
+ {
429
+ nk , err := key .NewNode ().Public ().MarshalBinary ()
430
+ require .NoError (t , err )
431
+ dk , err := key .NewDisco ().Public ().MarshalText ()
432
+ require .NoError (t , err )
433
+ cReq <- & proto.CoordinateRequest {UpdateSelf : & proto.CoordinateRequest_UpdateSelf {
434
+ Node : & proto.Node {
435
+ Id : 3 ,
436
+ Key : nk ,
437
+ Disco : string (dk ),
438
+ },
439
+ }}
440
+ }
441
+
442
+ cReq <- & proto.CoordinateRequest {AddTunnel : & proto.CoordinateRequest_Tunnel {
443
+ Id : agentID [:],
444
+ }}
445
+
446
+ testutil .RequireRecvCtx (ctx , t , aRes )
427
447
428
448
aReq <- & proto.CoordinateRequest {ReadyForHandshake : []* proto.CoordinateRequest_ReadyForHandshake {{
429
449
Id : clientID [:],
@@ -434,6 +454,44 @@ func TestCoordinator(t *testing.T) {
434
454
require .Equal (t , proto .CoordinateResponse_PeerUpdate_READY_FOR_HANDSHAKE , ack .PeerUpdates [0 ].Kind )
435
455
require .Equal (t , agentID [:], ack .PeerUpdates [0 ].Id )
436
456
})
457
+
458
+ t .Run ("AgentAck_NoPermission" , func (t * testing.T ) {
459
+ t .Parallel ()
460
+ logger := slogtest .Make (t , & slogtest.Options {IgnoreErrors : true }).Leveled (slog .LevelDebug )
461
+ coordinator := tailnet .NewCoordinator (logger )
462
+ ctx := testutil .Context (t , testutil .WaitShort )
463
+
464
+ clientID := uuid .New ()
465
+ agentID := uuid .New ()
466
+
467
+ aReq , _ := coordinator .Coordinate (ctx , agentID , agentID .String (), tailnet.AgentCoordinateeAuth {ID : agentID })
468
+ _ , _ = coordinator .Coordinate (ctx , clientID , clientID .String (), tailnet.ClientCoordinateeAuth {AgentID : agentID })
469
+
470
+ nk , err := key .NewNode ().Public ().MarshalBinary ()
471
+ require .NoError (t , err )
472
+ dk , err := key .NewDisco ().Public ().MarshalText ()
473
+ require .NoError (t , err )
474
+ aReq <- & proto.CoordinateRequest {UpdateSelf : & proto.CoordinateRequest_UpdateSelf {
475
+ Node : & proto.Node {
476
+ Id : 3 ,
477
+ Key : nk ,
478
+ Disco : string (dk ),
479
+ },
480
+ }}
481
+
482
+ require .Eventually (t , func () bool {
483
+ return coordinator .Node (agentID ) != nil
484
+ }, testutil .WaitShort , testutil .IntervalFast )
485
+
486
+ aReq <- & proto.CoordinateRequest {ReadyForHandshake : []* proto.CoordinateRequest_ReadyForHandshake {{
487
+ Id : clientID [:],
488
+ }}}
489
+
490
+ // The agent node should disappear, indicating it was booted off.
491
+ require .Eventually (t , func () bool {
492
+ return coordinator .Node (agentID ) == nil
493
+ }, testutil .WaitShort , testutil .IntervalFast )
494
+ })
437
495
}
438
496
439
497
// TestCoordinator_AgentUpdateWhileClientConnects tests for regression on
0 commit comments