@@ -12,8 +12,6 @@ def test_add_project_to_job_token_scope_allowlist(gl, project):
1212
1313def test_projects_job_token_scope_allowlist_contains_added_project_name (gl , project ):
1414 scope = project .job_token_scope .get ()
15- assert len (scope .allowlist .list ()) == 0
16-
1715 project_name = "Ci_Cd_token_named_proj"
1816 project_to_add = gl .projects .create ({"name" : project_name })
1917 scope .allowlist .create ({"target_project_id" : project_to_add .id })
@@ -26,18 +24,70 @@ def test_projects_job_token_scope_allowlist_contains_added_project_name(gl, proj
2624
2725def test_remove_project_by_id_from_projects_job_token_scope_allowlist (gl , project ):
2826 scope = project .job_token_scope .get ()
29- assert len (scope .allowlist .list ()) == 0
3027
3128 project_to_add = gl .projects .create ({"name" : "Ci_Cd_token_remove_proj" })
3229
3330 scope .allowlist .create ({"target_project_id" : project_to_add .id })
3431
3532 scope .refresh ()
36- assert len (scope .allowlist .list ()) != 0
3733
38- scope .allowlist .remove (project_to_add .id )
34+ scope .allowlist .delete (project_to_add .id )
3935
4036 scope .refresh ()
41- assert len (scope .allowlist .list ()) == 0
37+ assert not any (
38+ allowed .id == project_to_add .id for allowed in scope .allowlist .list ()
39+ )
4240
4341 project_to_add .delete ()
42+
43+
44+ def test_add_group_to_job_token_scope_allowlist (gl , project ):
45+ group_to_add = gl .groups .create (
46+ {"name" : "add_group" , "path" : "allowlisted-add-test" }
47+ )
48+
49+ scope = project .job_token_scope .get ()
50+ resp = scope .groups_allowlist .create ({"target_group_id" : group_to_add .id })
51+
52+ assert resp .source_project_id == project .id
53+ assert resp .target_group_id == group_to_add .id
54+
55+ group_to_add .delete ()
56+
57+
58+ def test_projects_job_token_scope_groups_allowlist_contains_added_group_name (
59+ gl , project
60+ ):
61+ scope = project .job_token_scope .get ()
62+ group_name = "list_group"
63+ group_to_add = gl .groups .create (
64+ {"name" : group_name , "path" : "allowlisted-add-and-list-test" }
65+ )
66+
67+ scope .groups_allowlist .create ({"target_group_id" : group_to_add .id })
68+
69+ scope .refresh ()
70+ assert any (allowed .name == group_name for allowed in scope .groups_allowlist .list ())
71+
72+ group_to_add .delete ()
73+
74+
75+ def test_remove_group_by_id_from_projects_job_token_scope_groups_allowlist (gl , project ):
76+ scope = project .job_token_scope .get ()
77+
78+ group_to_add = gl .groups .create (
79+ {"name" : "delete_group" , "path" : "allowlisted-delete-test" }
80+ )
81+
82+ scope .groups_allowlist .create ({"target_group_id" : group_to_add .id })
83+
84+ scope .refresh ()
85+
86+ scope .groups_allowlist .delete (group_to_add .id )
87+
88+ scope .refresh ()
89+ assert not any (
90+ allowed .name == group_to_add .name for allowed in scope .groups_allowlist .list ()
91+ )
92+
93+ group_to_add .delete ()
0 commit comments