-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #562 This enhancement adds capability to utilize the env var `DOCKER_AUTH_CONFIG` in-order to login to a private docker registry. --------- Co-authored-by: David Ankin <[email protected]>
- Loading branch information
1 parent
9d2ceb6
commit 59fbcfa
Showing
5 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import json | ||
|
||
from testcontainers.core.utils import parse_docker_auth_config, DockerAuthInfo | ||
|
||
|
||
def test_parse_docker_auth_config(): | ||
auth_config_json = '{"auths":{"https://index.docker.io/v1/":{"auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}}' | ||
auth_info = parse_docker_auth_config(auth_config_json) | ||
assert len(auth_info) == 1 | ||
assert auth_info[0] == DockerAuthInfo( | ||
registry="https://index.docker.io/v1/", | ||
username="username", | ||
password="password", | ||
) | ||
|
||
|
||
def test_parse_docker_auth_config_multiple(): | ||
auth_dict = { | ||
"auths": { | ||
"localhost:5000": {"auth": "dXNlcjE6cGFzczE=="}, | ||
"https://example.com": {"auth": "dXNlcl9uZXc6cGFzc19uZXc=="}, | ||
"example2.com": {"auth": "YWJjOjEyMw==="}, | ||
} | ||
} | ||
auth_config_json = json.dumps(auth_dict) | ||
auth_info = parse_docker_auth_config(auth_config_json) | ||
assert len(auth_info) == 3 | ||
assert auth_info[0] == DockerAuthInfo( | ||
registry="localhost:5000", | ||
username="user1", | ||
password="pass1", | ||
) | ||
assert auth_info[1] == DockerAuthInfo( | ||
registry="https://example.com", | ||
username="user_new", | ||
password="pass_new", | ||
) | ||
assert auth_info[2] == DockerAuthInfo( | ||
registry="example2.com", | ||
username="abc", | ||
password="123", | ||
) |