forked from ansible/example-opa-policy-for-aap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_scm_branch_validation_test.rego
More file actions
39 lines (34 loc) · 1.02 KB
/
project_scm_branch_validation_test.rego
File metadata and controls
39 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package test_aap_policy_examples
import data.aap_policy_examples
test_valid_main_branch_allowed if {
test_input := {
"project": {
"scm_branch": "main"
}
}
aap_policy_examples.project_scm_branch_validation.allowed == true with input as test_input
}
test_valid_v1_branch_allowed if {
test_input := {
"project": {
"scm_branch": "v1"
}
}
aap_policy_examples.project_scm_branch_validation.allowed == true with input as test_input
}
test_invalid_branch_blocked if {
test_input := {
"project": {
"scm_branch": "develop"
}
}
aap_policy_examples.project_scm_branch_validation.allowed == false with input as test_input
}
test_invalid_branch_violation_message if {
test_input := {
"project": {
"scm_branch": "develop"
}
}
aap_policy_examples.project_scm_branch_validation.violations[0] == "Invalid branch: develop. Only named 'main' or 'v1' branches are allowed." with input as test_input
}