Skip to content

Commit

Permalink
Intentionally set auth when checking if image exists in registry
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Feb 28, 2025
1 parent 2fece29 commit 0f68056
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/norun/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,29 @@ def test_registry_explicit_creds(registry, dind):
)
r2d.start()

proc = subprocess.run(
["docker", "manifest", "inspect", "--insecure", image_name]
)
assert proc.returncode == 0
# CONTAINER_ENGINE_REGISTRY_CREDENTIALS unfortunately doesn't propagate to docker manifest, so
# let's explicitly set up a docker_config here so we can check if the image exists
with TemporaryDirectory() as d:
(Path(d) / "config.json").write_text(
json.dumps(
{
"auths": {
f"http://{registry_host}": {
"auth": b64encode(
f"{username}:{password}".encode()
).decode()
}
}
}
)
)
env = os.environ.copy()
env["DOCKER_CONFIG"] = d
proc = subprocess.run(
["docker", "manifest", "inspect", "--insecure", image_name],
env=env
)
assert proc.returncode == 0

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

0 comments on commit 0f68056

Please sign in to comment.