Merge branch 'feature/validate-group-association' into feature/validate-group-association-debug

This commit is contained in:
bcmmbaga 2024-10-21 15:35:56 +03:00
commit 5c0e4097d8
No known key found for this signature in database
GPG Key ID: 511EED5C928AD547
4 changed files with 4 additions and 30 deletions

View File

@ -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)

View File

@ -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{})

View File

@ -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
}

View File

@ -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)