47
47
}
48
48
]
49
49
50
+ project_allowlist_created_content = {
51
+ "target_project_id" : 2 ,
52
+ "project_id" : 1 ,
53
+ }
54
+
50
55
groups_allowlist_content = [
51
56
{
52
57
"id" : 4 ,
55
60
}
56
61
]
57
62
63
+ group_allowlist_created_content = {
64
+ "target_group_id" : 4 ,
65
+ "project_id" : 1 ,
66
+ }
67
+
58
68
59
69
@pytest .fixture
60
70
def resp_get_job_token_scope ():
@@ -82,6 +92,19 @@ def resp_get_allowlist():
82
92
yield rsps
83
93
84
94
95
+ @pytest .fixture
96
+ def resp_add_to_allowlist ():
97
+ with responses .RequestsMock (assert_all_requests_are_fired = False ) as rsps :
98
+ rsps .add (
99
+ method = responses .POST ,
100
+ url = "http://localhost/api/v4/projects/1/job_token_scope/allowlist" ,
101
+ json = project_allowlist_created_content ,
102
+ content_type = "application/json" ,
103
+ status = 200 ,
104
+ )
105
+ yield rsps
106
+
107
+
85
108
@pytest .fixture
86
109
def resp_get_groups_allowlist ():
87
110
with responses .RequestsMock (assert_all_requests_are_fired = False ) as rsps :
@@ -95,6 +118,19 @@ def resp_get_groups_allowlist():
95
118
yield rsps
96
119
97
120
121
+ @pytest .fixture
122
+ def resp_add_to_groups_allowlist ():
123
+ with responses .RequestsMock (assert_all_requests_are_fired = False ) as rsps :
124
+ rsps .add (
125
+ method = responses .POST ,
126
+ url = "http://localhost/api/v4/projects/1/job_token_scope/groups_allowlist" ,
127
+ json = group_allowlist_created_content ,
128
+ content_type = "application/json" ,
129
+ status = 200 ,
130
+ )
131
+ yield rsps
132
+
133
+
98
134
@pytest .fixture
99
135
def resp_patch_job_token_scope ():
100
136
with responses .RequestsMock (assert_all_requests_are_fired = False ) as rsps :
@@ -140,9 +176,25 @@ def test_get_projects_allowlist(job_token_scope, resp_get_allowlist):
140
176
assert isinstance (allowlist_content , list )
141
177
142
178
179
+ def test_add_project_to_allowlist (job_token_scope , resp_add_to_allowlist ):
180
+ allowlist = job_token_scope .allowlist
181
+ assert isinstance (allowlist , AllowlistedProjectManager )
182
+
183
+ resp = allowlist .create ({"target_project_id" : 2 })
184
+ assert resp .get_id () == 2
185
+
186
+
143
187
def test_get_groups_allowlist (job_token_scope , resp_get_groups_allowlist ):
144
188
allowlist = job_token_scope .groups_allowlist
145
189
assert isinstance (allowlist , AllowlistedGroupManager )
146
190
147
191
allowlist_content = allowlist .list ()
148
192
assert isinstance (allowlist_content , list )
193
+
194
+
195
+ def test_add_group_to_allowlist (job_token_scope , resp_add_to_groups_allowlist ):
196
+ allowlist = job_token_scope .groups_allowlist
197
+ assert isinstance (allowlist , AllowlistedGroupManager )
198
+
199
+ resp = allowlist .create ({"target_group_id" : 4 })
200
+ assert resp .get_id () == 4
0 commit comments