From fdd0db7a7f8d1654c38c11bcc681b0da6753ab95 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 20 Jun 2018 18:21:59 -0400 Subject: [PATCH] Add test for trying to pull the catalog under a disabled namespace --- test/registry/protocol_v2.py | 4 +++- test/registry/registry_tests.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/registry/protocol_v2.py b/test/registry/protocol_v2.py index ec0b24923..938b77b54 100644 --- a/test/registry/protocol_v2.py +++ b/test/registry/protocol_v2.py @@ -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 diff --git a/test/registry/registry_tests.py b/test/registry/registry_tests.py index e63e7bffa..0accbde17 100644 --- a/test/registry/registry_tests.py +++ b/test/registry/registry_tests.py @@ -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'),