Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/testcontainers/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/core/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
import json

import pytest
Expand Down Expand Up @@ -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
Expand Down