Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gitlab/v4/objects/registry_protection_repository_rules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from gitlab.base import RESTObject
from gitlab.mixins import CreateMixin, ListMixin, SaveMixin, UpdateMethod, UpdateMixin
from gitlab.mixins import (
CreateMixin,
DeleteMixin,
ListMixin,
SaveMixin,
UpdateMethod,
UpdateMixin,
)
from gitlab.types import RequiredOptional

__all__ = [
Expand All @@ -16,6 +23,7 @@ class ProjectRegistryRepositoryProtectionRuleManager(
ListMixin[ProjectRegistryRepositoryProtectionRule],
CreateMixin[ProjectRegistryRepositoryProtectionRule],
UpdateMixin[ProjectRegistryRepositoryProtectionRule],
DeleteMixin[ProjectRegistryRepositoryProtectionRule],
):
_path = "/projects/{project_id}/registry/protection/repository/rules"
_obj_cls = ProjectRegistryRepositoryProtectionRule
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/api/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def test_project_protected_registry(project: Project):
protected_registry.minimum_access_level_for_push = "owner"
protected_registry.save()
assert protected_registry.minimum_access_level_for_push == "owner"

protected_registry.delete()

rules = project.registry_protection_repository_rules.list()
assert rules == []
15 changes: 15 additions & 0 deletions tests/unit/objects/test_registry_protection_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ def resp_update_protected_registry():
yield rsps


@pytest.fixture
def resp_delete_protected_registry():
with responses.RequestsMock() as rsps:
rsps.add(
method=responses.DELETE,
url="http://localhost/api/v4/projects/1/registry/protection/repository/rules/1",
status=204,
)
yield rsps


def test_list_project_protected_registries(project, resp_list_protected_registries):
protected_registry = project.registry_protection_repository_rules.list()[0]
assert isinstance(protected_registry, ProjectRegistryRepositoryProtectionRule)
Expand All @@ -80,3 +91,7 @@ def test_update_project_protected_registry(project, resp_update_protected_regist
1, {"repository_path_pattern": "abc*"}
)
assert updated["repository_path_pattern"] == "abc*"


def test_delete_project_protected_registry(project, resp_delete_protected_registry):
project.registry_protection_repository_rules.delete(1)