mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-12 18:00:49 +01:00
Merge branch 'feature/validate-group-association' into feature/validate-group-association-debug
This commit is contained in:
commit
5c0e4097d8
@ -263,8 +263,7 @@ func (am *DefaultAccountManager) UpdatePeer(ctx context.Context, accountID, user
|
||||
return nil, err
|
||||
}
|
||||
|
||||
expired, _ := peer.LoginExpired(account.Settings.PeerLoginExpiration)
|
||||
if peerLabelUpdated || (expired && peer.LoginExpirationEnabled) {
|
||||
if peerLabelUpdated {
|
||||
am.updateAccountPeers(ctx, account)
|
||||
} else {
|
||||
log.WithContext(ctx).Tracef("Skipping account peers update for peer: %s", update.ID)
|
||||
|
@ -1435,31 +1435,6 @@ func TestPeerAccountPeersUpdate(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// Updating expired peer and peer expiration is enabled should update account peers and send peer update
|
||||
t.Run("updating expired peer and peer expiration is enabled", func(t *testing.T) {
|
||||
err = manager.Store.SavePeerStatus(account.Id, peer4.ID, nbpeer.PeerStatus{
|
||||
Connected: false,
|
||||
LastSeen: time.Now().Add(-48 * time.Hour),
|
||||
LoginExpired: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
peerShouldReceiveUpdate(t, updMsg)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
_, err = manager.UpdatePeer(context.Background(), account.Id, userID, peer4)
|
||||
require.NoError(t, err)
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
t.Error("timeout waiting for peerShouldReceiveUpdate")
|
||||
}
|
||||
})
|
||||
|
||||
// Deleting peer with linked group to policy should update account peers and send peer update
|
||||
t.Run("deleting peer with linked group to policy", func(t *testing.T) {
|
||||
done := make(chan struct{})
|
||||
|
@ -829,7 +829,7 @@ func (am *DefaultAccountManager) SaveOrAddUsers(ctx context.Context, accountID,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if areUsersLinkedToPeers(account, userIDs) && account.Settings.GroupsPropagationEnabled {
|
||||
if account.Settings.GroupsPropagationEnabled && areUsersLinkedToPeers(account, userIDs) {
|
||||
am.updateAccountPeers(ctx, account)
|
||||
} else {
|
||||
log.WithContext(ctx).Tracef("Skipping account peers update for user: %v", userIDs)
|
||||
@ -1217,7 +1217,7 @@ func (am *DefaultAccountManager) DeleteRegularUsers(ctx context.Context, account
|
||||
continue
|
||||
}
|
||||
|
||||
if hadPeers && !updateAccountPeers {
|
||||
if hadPeers {
|
||||
updateAccountPeers = true
|
||||
}
|
||||
|
||||
|
@ -1301,7 +1301,7 @@ func TestUserAccountPeersUpdate(t *testing.T) {
|
||||
})
|
||||
|
||||
// Creating a new regular user should not update account peers and not send peer update
|
||||
t.Run("creating new regular user", func(t *testing.T) {
|
||||
t.Run("creating new regular user with no groups", func(t *testing.T) {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
peerShouldNotReceiveUpdate(t, updMsg)
|
||||
|
Loading…
Reference in New Issue
Block a user