Skip to content

Commit

Permalink
api: adding global readonly user to list repo endpoint (PROJQUAY-7446) (
Browse files Browse the repository at this point in the history
quay#3072)

Adding global readonly user to list repo endpoint.
  • Loading branch information
bcaton85 authored Jul 25, 2024
1 parent b78a746 commit ec64325
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions endpoints/api/repository_models_pre_oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from data.database import RepositoryState
from data.registry_model import registry_model
from data.registry_model.datatypes import RepositoryReference
from endpoints.api import allow_if_superuser
from endpoints.api import allow_if_global_readonly_superuser, allow_if_superuser
from endpoints.api.repository_models_interface import (
ApplicationRepository,
Channel,
Expand Down Expand Up @@ -115,7 +115,7 @@ def can_view_repo(repo):
limit=REPOS_PER_PAGE + 1,
kind_filter=repo_kind,
namespace=namespace,
is_superuser=allow_if_superuser(),
is_superuser=allow_if_superuser() or allow_if_global_readonly_superuser(),
)

repos, next_page_token = model.modelutil.paginate_query(
Expand Down
21 changes: 21 additions & 0 deletions test/test_api_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,27 @@ def test_listrepos_org_filtered(self):
self.login(PUBLIC_USER)
self.assertRepositoryNotVisible("neworg", "somerepo")

def test_list_repos_globalreadonlysuperuser(self):
repository = model.repository.get_repository("orgwithnosuperuser", "repo")
assert repository is not None
assert repository.visibility.name == "private"
self.login("globalreadonlysuperuser")
json = self.getJsonResponse(
RepositoryList,
params=dict(namespace="orgwithnosuperuser", public=False),
)

assert len(json["repositories"]) == 1
assert json["repositories"][0]["name"] == "repo"

# Make sure a normal user can't see the repository
self.login(NO_ACCESS_USER)
json = self.getJsonResponse(
RepositoryList,
params=dict(namespace="orgwithnosuperuser", public=False),
)
assert len(json["repositories"]) == 0


class TestViewPublicRepository(ApiTestCase):
def test_normalview(self):
Expand Down

0 comments on commit ec64325

Please sign in to comment.