diff --git a/management/server/policy_test.go b/management/server/policy_test.go index 88f528b49..8d2199c47 100644 --- a/management/server/policy_test.go +++ b/management/server/policy_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "github.com/rs/xid" "github.com/stretchr/testify/assert" "golang.org/x/exp/slices" @@ -870,6 +871,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupB"}, Destinations: []string{"groupC"}, @@ -903,6 +905,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupA"}, Destinations: []string{"groupB"}, @@ -937,6 +940,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: false, Sources: []string{"groupC"}, Destinations: []string{"groupD"}, @@ -971,6 +975,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupA"}, Destinations: []string{"groupD"}, @@ -1003,6 +1008,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupA"}, Destinations: []string{"groupD"}, diff --git a/management/server/posture_checks_test.go b/management/server/posture_checks_test.go index 2aa506833..6adca3db1 100644 --- a/management/server/posture_checks_test.go +++ b/management/server/posture_checks_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/netbirdio/netbird/management/server/group" + "github.com/rs/xid" "github.com/stretchr/testify/assert" "github.com/netbirdio/netbird/management/server/posture" @@ -205,6 +206,7 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupA"}, Destinations: []string{"groupA"}, @@ -329,6 +331,7 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) { Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupB"}, Destinations: []string{"groupC"}, @@ -365,11 +368,16 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) { // Updating linked posture check to policy where destination has peers but source does not // should trigger account peers update and send peer update t.Run("updating linked posture check to policy where destination has peers but source does not", func(t *testing.T) { + updMsg1 := manager.peersUpdateManager.CreateChannel(context.Background(), peer2.ID) + t.Cleanup(func() { + manager.peersUpdateManager.CloseChannel(context.Background(), peer2.ID) + }) policy = Policy{ ID: "policyB", Enabled: true, Rules: []*PolicyRule{ { + ID: xid.New().String(), Enabled: true, Sources: []string{"groupB"}, Destinations: []string{"groupA"}, @@ -379,12 +387,13 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) { }, SourcePostureChecks: []string{postureCheck.ID}, } + err = manager.SavePolicy(context.Background(), account.Id, userID, &policy, true) assert.NoError(t, err) done := make(chan struct{}) go func() { - peerShouldReceiveUpdate(t, updMsg) + peerShouldReceiveUpdate(t, updMsg1) close(done) }()