-
Notifications
You must be signed in to change notification settings - Fork 13
/
label-based-team-access_test.rego
91 lines (78 loc) · 1.83 KB
/
label-based-team-access_test.rego
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package spacelift
# in most cases read/write/deny act exactly the same, so tests
# will only focus on specifics for those when it applies
test_no_denywrite_if_nothing {
not deny_write with input as {
"session": {"teams": []},
"stack": {"labels": []},
}
}
test_denywrite_if_administrative {
deny_write with input as {
"session": {"teams": []},
"stack": {
"administrative": true,
"labels": [],
},
}
}
test_no_write_if_nothing {
not write with input as {
"session": {"teams": []},
"stack": {"labels": []},
}
}
test_no_write_if_label {
not write with input as {
"session": {"teams": []},
"stack": {"labels": ["access:write:my-team"]},
}
}
test_no_write_if_wrong_team {
not write with input as {
"session": {"teams": ["My_Team"]},
"stack": {"labels": ["access:write:my-team"]},
}
}
test_write_if_correct_team {
write with input as {
"session": {"teams": ["My Team"]},
"stack": {"labels": ["access:write:my-team"]},
}
}
test_write_if_correct_team2 {
write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["access:write:my-team"]},
}
}
test_no_write_if_wrong_level {
not write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["access:read:my-team"]},
}
}
test_no_write_if_wrong_wrong_label {
not write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["access:write:*"]},
}
}
test_no_write_if_wrong_wrong_label2 {
not write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["write"]},
}
}
test_no_write_if_wrong_wrong_label3 {
not write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["write:my-team"]},
}
}
test_no_write_if_wrong_wrong_label4 {
not write with input as {
"session": {"teams": ["My - Team"]},
"stack": {"labels": ["access:write:my-team:haha"]},
}
}