Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/policies/engine/rego/rego_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,18 @@ func TestRego_MatchesParameters(t *testing.T) {
Source: regoContent,
}

t.Run("high severity matches medium expectation", func(t *testing.T) {
t.Run("high expectation matches low severity", func(t *testing.T) {
matches, err := r.MatchesParameters(context.TODO(), policy,
map[string]string{"severity": "high"},
map[string]string{"severity": "medium"})
map[string]string{"severity": "low"},
map[string]string{"severity": "high"})
require.NoError(t, err)
assert.True(t, matches)
})

t.Run("low severity does not match high expectation", func(t *testing.T) {
t.Run("medium expectation does not match high severity", func(t *testing.T) {
matches, err := r.MatchesParameters(context.TODO(), policy,
map[string]string{"severity": "low"},
map[string]string{"severity": "high"})
map[string]string{"severity": "high"},
map[string]string{"severity": "medium"})
require.NoError(t, err)
assert.False(t, matches)
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/policies/engine/rego/testfiles/matches_parameters.rego
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ matches_parameters := result {
eval_idx := severity_index(eval_severity)
expected_idx := severity_index(expected_severity)

# Evaluation severity must be >= expected severity
result := eval_idx >= expected_idx
# Expected severity must be >= evaluation severity
result := expected_idx >= eval_idx
}
Loading