Skip to content

Commit 9e7da04

Browse files
authored
Fix test_invalid_registry_host() integration test (#1485)
1 parent f8fab12 commit 9e7da04

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/integration/containerized/test_container_management.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ def test_non_owner_install(mocker, project_fixtures, runtime, container_image):
100100

101101
@pytest.mark.test_all_runtimes
102102
def test_invalid_registry_host(tmp_path, runtime):
103+
"""
104+
Test using registry authentication.
105+
106+
We use an invalid registry, so we expect the run to fail. But we will verify that the authentication
107+
data is written to the auth configuration file correctly.
108+
"""
103109
pdd_path = tmp_path / 'private_data_dir'
104110
pdd_path.mkdir()
105111
private_data_dir = str(pdd_path)
106112

107-
image_name = 'quay.io/kdelee/does-not-exist'
113+
image_name = 'quay.io/ansible-runner/does-not-exist'
108114

109115
res = run(
110116
private_data_dir=private_data_dir,
@@ -124,15 +130,14 @@ def test_invalid_registry_host(tmp_path, runtime):
124130

125131
with res.stdout as f:
126132
result_stdout = f.read()
133+
134+
assert 'unauthorized' in result_stdout.lower()
135+
127136
auth_file_path = os.path.join(res.config.registry_auth_path, 'config.json')
128137
registry_conf = os.path.join(res.config.registry_auth_path, 'registries.conf')
129-
error_msg = 'access to the requested resource is not authorized'
130138
if runtime == 'podman':
131-
assert image_name in result_stdout
132-
error_msg = 'unauthorized'
133139
auth_file_path = res.config.registry_auth_path
134140
registry_conf = os.path.join(os.path.dirname(res.config.registry_auth_path), 'registries.conf')
135-
assert error_msg in result_stdout
136141

137142
with open(auth_file_path, 'r') as f:
138143
content = f.read()

0 commit comments

Comments
 (0)