diff --git a/management/server/policy_test.go b/management/server/policy_test.go index 8d2199c47..e213490fc 100644 --- a/management/server/policy_test.go +++ b/management/server/policy_test.go @@ -1001,6 +1001,74 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { } }) + // Disabling policy with destination and source groups containing peers should update account's peers + // and send peer update + t.Run("disabling policy with source and destination groups with peers", func(t *testing.T) { + policy := Policy{ + ID: "policy-source-destination-peers", + Enabled: false, + Rules: []*PolicyRule{ + { + ID: xid.New().String(), + Enabled: true, + Sources: []string{"groupA"}, + Destinations: []string{"groupD"}, + Bidirectional: true, + Action: PolicyTrafficActionAccept, + }, + }, + } + + done := make(chan struct{}) + go func() { + peerShouldReceiveUpdate(t, updMsg1) + close(done) + }() + + err := manager.SavePolicy(context.Background(), account.Id, userID, &policy, true) + assert.NoError(t, err) + + select { + case <-done: + case <-time.After(time.Second): + t.Error("timeout waiting for peerShouldReceiveUpdate") + } + }) + + // Enabling policy with destination and source groups containing peers should update account's peers + // and send peer update + t.Run("enabling policy with source and destination groups with peers", func(t *testing.T) { + policy := Policy{ + ID: "policy-source-destination-peers", + Enabled: true, + Rules: []*PolicyRule{ + { + ID: xid.New().String(), + Enabled: true, + Sources: []string{"groupA"}, + Destinations: []string{"groupD"}, + Bidirectional: true, + Action: PolicyTrafficActionAccept, + }, + }, + } + + done := make(chan struct{}) + go func() { + peerShouldReceiveUpdate(t, updMsg1) + close(done) + }() + + err := manager.SavePolicy(context.Background(), account.Id, userID, &policy, true) + assert.NoError(t, err) + + select { + case <-done: + case <-time.After(time.Second): + t.Error("timeout waiting for peerShouldReceiveUpdate") + } + }) + // Saving unchanged policy should trigger account peers update but not send peer update t.Run("saving unchanged policy", func(t *testing.T) { policy := Policy{ diff --git a/management/server/updatechannel.go b/management/server/updatechannel.go index c34ee977b..760ae5071 100644 --- a/management/server/updatechannel.go +++ b/management/server/updatechannel.go @@ -230,7 +230,6 @@ func isNewPeerUpdateMessage(lastSentUpdate, currUpdateToSend *UpdateMessage) (bo } differ, err := diff.NewDiffer( - diff.DisableStructValues(), diff.CustomValueDiffers(&differs.NetIPAddr{}), diff.CustomValueDiffers(&differs.NetIPPrefix{}), )