diff --git a/management/server/setupkey_test.go b/management/server/setupkey_test.go index b049b53ab..651b54010 100644 --- a/management/server/setupkey_test.go +++ b/management/server/setupkey_test.go @@ -354,11 +354,11 @@ func TestSetupKey_Copy(t *testing.T) { } -func TestSetupKeyAccountPeerUpdate(t *testing.T) { +func TestSetupKeyAccountPeersUpdate(t *testing.T) { manager, account, peer1, peer2, peer3 := setupNetworkMapTest(t) err := manager.SaveGroup(context.Background(), account.Id, userID, &nbgroup.Group{ - ID: "group-id", + ID: "groupA", Name: "GroupA", Peers: []string{peer1.ID, peer2.ID, peer3.ID}, }) @@ -370,14 +370,14 @@ func TestSetupKeyAccountPeerUpdate(t *testing.T) { Rules: []*PolicyRule{ { Enabled: true, - Sources: []string{"group-id"}, - Destinations: []string{"group-id"}, + Sources: []string{"groupA"}, + Destinations: []string{"group"}, Bidirectional: true, Action: PolicyTrafficActionAccept, }, }, } - err = manager.SavePolicy(context.Background(), account.Id, userID, &policy) + err = manager.SavePolicy(context.Background(), account.Id, userID, &policy, false) require.NoError(t, err) updMsg := manager.peersUpdateManager.CreateChannel(context.Background(), peer1.ID) @@ -386,6 +386,8 @@ func TestSetupKeyAccountPeerUpdate(t *testing.T) { }) var setupKey *SetupKey + + // Creating setup key should not update account peers and not send peer update t.Run("creating setup key", func(t *testing.T) { done := make(chan struct{}) go func() { @@ -394,9 +396,7 @@ func TestSetupKeyAccountPeerUpdate(t *testing.T) { }() setupKey, err = manager.CreateSetupKey(context.Background(), account.Id, "key1", SetupKeyReusable, time.Hour, nil, 999, userID, false) - if err != nil { - t.Fatal("error creating setup key") - } + assert.NoError(t, err) select { case <-done: diff --git a/management/server/user_test.go b/management/server/user_test.go index 7740b4059..d096a18a8 100644 --- a/management/server/user_test.go +++ b/management/server/user_test.go @@ -1256,12 +1256,12 @@ func TestDefaultAccountManager_SaveUser(t *testing.T) { } } -func TestUserAccountPeerUpdate(t *testing.T) { +func TestUserAccountPeersUpdate(t *testing.T) { // account groups propagation is enabled manager, account, peer1, peer2, peer3 := setupNetworkMapTest(t) err := manager.SaveGroup(context.Background(), account.Id, userID, &nbgroup.Group{ - ID: "group-id", + ID: "groupA", Name: "GroupA", Peers: []string{peer1.ID, peer2.ID, peer3.ID}, }) @@ -1273,14 +1273,14 @@ func TestUserAccountPeerUpdate(t *testing.T) { Rules: []*PolicyRule{ { Enabled: true, - Sources: []string{"group-id"}, - Destinations: []string{"group-id"}, + Sources: []string{"groupA"}, + Destinations: []string{"groupA"}, Bidirectional: true, Action: PolicyTrafficActionAccept, }, }, } - err = manager.SavePolicy(context.Background(), account.Id, userID, &policy) + err = manager.SavePolicy(context.Background(), account.Id, userID, &policy, false) require.NoError(t, err) updMsg := manager.peersUpdateManager.CreateChannel(context.Background(), peer1.ID) @@ -1394,14 +1394,12 @@ func TestUserAccountPeerUpdate(t *testing.T) { } }) - _ = peer4 - peer4UpdMsg := manager.peersUpdateManager.CreateChannel(context.Background(), peer4.ID) t.Cleanup(func() { manager.peersUpdateManager.CloseChannel(context.Background(), peer4.ID) }) - // deleting user with linked peers should update account peers and no send peer update + // deleting user with linked peers should update account peers and send peer update t.Run("deleting user with linked peers", func(t *testing.T) { done := make(chan struct{}) go func() {