Skip to content

Commit 0f68056

Browse files
committed
Intentionally set auth when checking if image exists in registry
1 parent 2fece29 commit 0f68056

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/norun/test_registry.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,29 @@ def test_registry_explicit_creds(registry, dind):
165165
)
166166
r2d.start()
167167

168-
proc = subprocess.run(
169-
["docker", "manifest", "inspect", "--insecure", image_name]
170-
)
171-
assert proc.returncode == 0
168+
# CONTAINER_ENGINE_REGISTRY_CREDENTIALS unfortunately doesn't propagate to docker manifest, so
169+
# let's explicitly set up a docker_config here so we can check if the image exists
170+
with TemporaryDirectory() as d:
171+
(Path(d) / "config.json").write_text(
172+
json.dumps(
173+
{
174+
"auths": {
175+
f"http://{registry_host}": {
176+
"auth": b64encode(
177+
f"{username}:{password}".encode()
178+
).decode()
179+
}
180+
}
181+
}
182+
)
183+
)
184+
env = os.environ.copy()
185+
env["DOCKER_CONFIG"] = d
186+
proc = subprocess.run(
187+
["docker", "manifest", "inspect", "--insecure", image_name],
188+
env=env
189+
)
190+
assert proc.returncode == 0
172191

173192
# Validate that we didn't leak our registry creds into existing docker config
174193
docker_config_path = Path(

0 commit comments

Comments
 (0)