mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-26 04:06:38 +00:00
@@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/xid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
@@ -870,6 +871,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupB"},
|
Sources: []string{"groupB"},
|
||||||
Destinations: []string{"groupC"},
|
Destinations: []string{"groupC"},
|
||||||
@@ -903,6 +905,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupA"},
|
Sources: []string{"groupA"},
|
||||||
Destinations: []string{"groupB"},
|
Destinations: []string{"groupB"},
|
||||||
@@ -937,6 +940,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
Sources: []string{"groupC"},
|
Sources: []string{"groupC"},
|
||||||
Destinations: []string{"groupD"},
|
Destinations: []string{"groupD"},
|
||||||
@@ -971,6 +975,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupA"},
|
Sources: []string{"groupA"},
|
||||||
Destinations: []string{"groupD"},
|
Destinations: []string{"groupD"},
|
||||||
@@ -1003,6 +1008,7 @@ func TestPolicyAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupA"},
|
Sources: []string{"groupA"},
|
||||||
Destinations: []string{"groupD"},
|
Destinations: []string{"groupD"},
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/management/server/group"
|
"github.com/netbirdio/netbird/management/server/group"
|
||||||
|
"github.com/rs/xid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/management/server/posture"
|
"github.com/netbirdio/netbird/management/server/posture"
|
||||||
@@ -205,6 +206,7 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupA"},
|
Sources: []string{"groupA"},
|
||||||
Destinations: []string{"groupA"},
|
Destinations: []string{"groupA"},
|
||||||
@@ -329,6 +331,7 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupB"},
|
Sources: []string{"groupB"},
|
||||||
Destinations: []string{"groupC"},
|
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
|
// Updating linked posture check to policy where destination has peers but source does not
|
||||||
// should trigger account peers update and send peer update
|
// 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) {
|
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{
|
policy = Policy{
|
||||||
ID: "policyB",
|
ID: "policyB",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Rules: []*PolicyRule{
|
Rules: []*PolicyRule{
|
||||||
{
|
{
|
||||||
|
ID: xid.New().String(),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Sources: []string{"groupB"},
|
Sources: []string{"groupB"},
|
||||||
Destinations: []string{"groupA"},
|
Destinations: []string{"groupA"},
|
||||||
@@ -379,12 +387,13 @@ func TestPostureCheckAccountPeersUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
SourcePostureChecks: []string{postureCheck.ID},
|
SourcePostureChecks: []string{postureCheck.ID},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = manager.SavePolicy(context.Background(), account.Id, userID, &policy, true)
|
err = manager.SavePolicy(context.Background(), account.Id, userID, &policy, true)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
peerShouldReceiveUpdate(t, updMsg)
|
peerShouldReceiveUpdate(t, updMsg1)
|
||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user