Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmmbaga committed Jan 18, 2024
1 parent 3f24053 commit f27e918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
7 changes: 3 additions & 4 deletions management/server/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,12 @@ func (a *Account) validatePostureChecksOnPeer(sourcePostureChecksID []string, pe

for _, check := range postureChecks.Checks {
isValid, err := check.Check(*peer)
if err != nil {
log.Debugf("an error occurred check %s: on peer: %s :%s", check.Name(), peer.ID, err.Error())
}
if !isValid {
if err != nil {
log.Debugf("an error occurred check %s: on peer: %s :%s", check.Name(), peer.ID, err.Error())
}
return false
}

}
}
return true
Expand Down
9 changes: 2 additions & 7 deletions management/server/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"

nbpeer "github.com/netbirdio/netbird/management/server/peer"
Expand Down Expand Up @@ -708,12 +707,8 @@ func TestAccount_getPeersByPolicyPostureChecks(t *testing.T) {
Port: "80",
},
}
require.Len(t, firewallRules, len(expectedFirewallRules))
slices.SortFunc(expectedFirewallRules, sortFunc())
slices.SortFunc(firewallRules, sortFunc())
for i := range firewallRules {
assert.Equal(t, expectedFirewallRules[i], firewallRules[i])
}
assert.Len(t, firewallRules, len(expectedFirewallRules))
assert.ElementsMatch(t, firewallRules, expectedFirewallRules)
})
}

Expand Down

0 comments on commit f27e918

Please sign in to comment.