From 69e02b326e498cccec7da885d914d6fff26abbf3 Mon Sep 17 00:00:00 2001 From: Mradul Singh Date: Mon, 23 Nov 2026 17:40:35 +0530 Subject: [PATCH] fix(core): allow colons in DOCKER_AUTH_CONFIG passwords --- src/testcontainers/core/auth.py | 2 +- tests/core/test_auth.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/testcontainers/core/auth.py b/src/testcontainers/core/auth.py index afabe9e9d..1ffd94273 100644 --- a/src/testcontainers/core/auth.py +++ b/src/testcontainers/core/auth.py @@ -36,7 +36,7 @@ def process_docker_auth_config_encoded(auth_config_dict: dict[str, dict[str, dic for registry, auth in auths.items(): auth_str = str(auth.get("auth")) auth_str = base64.b64decode(auth_str).decode("utf-8") - username, password = auth_str.split(":") + username, password = auth_str.split(":", 1) auth_info.append(DockerAuthInfo(registry, username, password)) return auth_info diff --git a/tests/core/test_auth.py b/tests/core/test_auth.py index f518fff29..9cc8b06d0 100644 --- a/tests/core/test_auth.py +++ b/tests/core/test_auth.py @@ -1,3 +1,4 @@ +import base64 import json import pytest @@ -58,6 +59,19 @@ def test_parse_docker_auth_config_encoded_multiple(): ) +@pytest.mark.parametrize( + "username, password", + [ + ("user", "pass:word:"), + ("_json_key", '{"type": "service_account", "token_uri": "https://oauth2.googleapis.com/token"}'), + ], +) +def test_parse_docker_auth_config_password_with_colon(username: str, password: str): + auth = base64.b64encode(f"{username}:{password}".encode()).decode() + auth_info = parse_docker_auth_config(json.dumps({"auths": {"gcr.io": {"auth": auth}}})) + assert auth_info == [DockerAuthInfo(registry="gcr.io", username=username, password=password)] + + def test_parse_docker_auth_config_unknown(): auth_config_str = '{"key": "value"}' assert parse_docker_auth_config(auth_config_str) is None