Last active
November 18, 2020 14:09
-
-
Save klauern/e6d4681b4d45a30c260b4ae0a276a7ac to your computer and use it in GitHub Desktop.
Test for combined rego/conftest policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: scrum_group | |
group_name: first | |
members: | |
- one | |
- two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: scrum_group | |
group_name: second | |
members: | |
- two | |
- three |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
deny[msg] { | |
some team_a, team_b | |
team_a != team_b | |
a_members := input.Combined[team_a].contents.members | |
b_members := input.Combined[team_b].contents.members | |
group_a := input.Combined[team_a].contents.group_name | |
group_b := input.Combined[team_b].contents.group_name | |
input.Combined[team_a].contents.type == "scrum_group" | |
input.Combined[team_b].contents.type == "scrum_group" | |
some member_a, member_b | |
first := a_members[member_a] | |
second := b_members[member_b] | |
first == second | |
msg := sprintf("member cannot be in more than one scrum group: %v, groups: %v, %v", [first, group_a, group_b]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
test_scrum_group_member_listed_twice { | |
deny["member cannot be in more than one scrum group: two, groups: first, second"] with input as { | |
"Combined": [ | |
{ | |
"contents": { | |
"group_name": "second", | |
"members": [ | |
"one", | |
"two" | |
], | |
"type": "scrum_group" | |
}, | |
"path": "data/groups/second.yaml" | |
}, | |
{ | |
"contents": { | |
"group_name": "first", | |
"members": [ | |
"two", | |
"three" | |
], | |
"type": "scrum_group" | |
}, | |
"path": "data/groups/first.yaml" | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment