Add test for trying to pull the catalog under a disabled namespace
This commit is contained in:
parent
892cc82b6a
commit
fdd0db7a7f
2 changed files with 18 additions and 1 deletions
|
@ -16,6 +16,7 @@ class V2ProtocolSteps(Enum):
|
|||
GET_MANIFEST = 'get-manifest'
|
||||
PUT_MANIFEST = 'put-manifest'
|
||||
MOUNT_BLOB = 'mount-blob'
|
||||
CATALOG = 'catalog'
|
||||
|
||||
|
||||
class V2Protocol(RegistryProtocol):
|
||||
|
@ -421,7 +422,8 @@ class V2Protocol(RegistryProtocol):
|
|||
params['n'] = page_size
|
||||
|
||||
while True:
|
||||
response = self.conduct(session, 'GET', url, headers=headers, params=params)
|
||||
response = self.conduct(session, 'GET', url, headers=headers, params=params,
|
||||
expected_status=(200, expected_failure, V2ProtocolSteps.CATALOG))
|
||||
data = response.json()
|
||||
|
||||
assert len(data['repositories']) <= page_size
|
||||
|
|
|
@ -739,6 +739,21 @@ def test_catalog_caching(v2_protocol, basic_images, liveserver_session, app_relo
|
|||
assert set(cached_results) == set(results)
|
||||
|
||||
|
||||
def test_catalog_disabled_namespace(v2_protocol, basic_images, liveserver_session, app_reloader,
|
||||
liveserver, registry_server_executor):
|
||||
credentials = ('devtable', 'password')
|
||||
|
||||
# Get a valid token.
|
||||
token, _ = v2_protocol.auth(liveserver_session, credentials, 'devtable', 'simple')
|
||||
|
||||
# Disable the devtable namespace.
|
||||
registry_server_executor.on(liveserver).disable_namespace('devtable')
|
||||
|
||||
# Try to retrieve the catalog and ensure it fails to return any results.
|
||||
results = v2_protocol.catalog(liveserver_session, bearer_token=token)
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('username, namespace, repository', [
|
||||
('devtable', 'devtable', 'simple'),
|
||||
('devtable', 'devtable', 'gargantuan'),
|
||||
|
|
Reference in a new issue