@@ -12,8 +12,6 @@ def test_add_project_to_job_token_scope_allowlist(gl, project):
12
12
13
13
def test_projects_job_token_scope_allowlist_contains_added_project_name (gl , project ):
14
14
scope = project .job_token_scope .get ()
15
- assert len (scope .allowlist .list ()) == 0
16
-
17
15
project_name = "Ci_Cd_token_named_proj"
18
16
project_to_add = gl .projects .create ({"name" : project_name })
19
17
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
26
24
27
25
def test_remove_project_by_id_from_projects_job_token_scope_allowlist (gl , project ):
28
26
scope = project .job_token_scope .get ()
29
- assert len (scope .allowlist .list ()) == 0
30
27
31
28
project_to_add = gl .projects .create ({"name" : "Ci_Cd_token_remove_proj" })
32
29
33
30
scope .allowlist .create ({"target_project_id" : project_to_add .id })
34
31
35
32
scope .refresh ()
36
- assert len (scope .allowlist .list ()) != 0
37
33
38
- scope .allowlist .remove (project_to_add .id )
34
+ scope .allowlist .delete (project_to_add .id )
39
35
40
36
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
+ )
42
40
43
41
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