11"""
2- GitLab API: https://docs.gitlab.com/ee/api/project_container_registry_protection_rules .html
2+ GitLab API: https://docs.gitlab.com/ee/api/container_repository_protection_rules .html
33"""
44
55import pytest
66import responses
77
8- from gitlab .v4 .objects import ProjectRegistryProtectionRule
8+ from gitlab .v4 .objects import ProjectRegistryRepositoryProtectionRule
99
1010protected_registry_content = {
1111 "id" : 1 ,
@@ -21,7 +21,7 @@ def resp_list_protected_registries():
2121 with responses .RequestsMock () as rsps :
2222 rsps .add (
2323 method = responses .GET ,
24- url = "http://localhost/api/v4/projects/1/registry/protection/rules" ,
24+ url = "http://localhost/api/v4/projects/1/registry/repository/ protection/rules" ,
2525 json = [protected_registry_content ],
2626 content_type = "application/json" ,
2727 status = 200 ,
@@ -34,7 +34,7 @@ def resp_create_protected_registry():
3434 with responses .RequestsMock () as rsps :
3535 rsps .add (
3636 method = responses .POST ,
37- url = "http://localhost/api/v4/projects/1/registry/protection/rules" ,
37+ url = "http://localhost/api/v4/projects/1/registry/repository/ protection/rules" ,
3838 json = protected_registry_content ,
3939 content_type = "application/json" ,
4040 status = 201 ,
@@ -50,7 +50,7 @@ def resp_update_protected_registry():
5050 with responses .RequestsMock () as rsps :
5151 rsps .add (
5252 method = responses .PATCH ,
53- url = "http://localhost/api/v4/projects/1/registry/protection/rules/1" ,
53+ url = "http://localhost/api/v4/projects/1/registry/repository/ protection/rules/1" ,
5454 json = updated_content ,
5555 content_type = "application/json" ,
5656 status = 200 ,
@@ -59,24 +59,24 @@ def resp_update_protected_registry():
5959
6060
6161def test_list_project_protected_registries (project , resp_list_protected_registries ):
62- protected_registry = project .registry_protection_rules .list ()[0 ]
63- assert isinstance (protected_registry , ProjectRegistryProtectionRule )
62+ protected_registry = project .registry_repository_protection_rules .list ()[0 ]
63+ assert isinstance (protected_registry , ProjectRegistryRepositoryProtectionRule )
6464 assert protected_registry .repository_path_pattern == "test/image"
6565
6666
6767def test_create_project_protected_registry (project , resp_create_protected_registry ):
68- protected_registry = project .registry_protection_rules .create (
68+ protected_registry = project .registry_repository_protection_rules .create (
6969 {
7070 "repository_path_pattern" : "test/image" ,
7171 "minimum_access_level_for_push" : "maintainer" ,
7272 }
7373 )
74- assert isinstance (protected_registry , ProjectRegistryProtectionRule )
74+ assert isinstance (protected_registry , ProjectRegistryRepositoryProtectionRule )
7575 assert protected_registry .repository_path_pattern == "test/image"
7676
7777
7878def test_update_project_protected_registry (project , resp_update_protected_registry ):
79- updated = project .registry_protection_rules .update (
79+ updated = project .registry_repository_protection_rules .update (
8080 1 , {"repository_path_pattern" : "abc*" }
8181 )
8282 assert updated ["repository_path_pattern" ] == "abc*"
0 commit comments