diff options
author | Joffrey F <f.joffrey@gmail.com> | 2018-02-14 16:04:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 16:04:47 -0800 |
commit | dbcf04388af91094a1bd0b4d562f075196054a92 (patch) | |
tree | 6fc6197b3691f6e71d40ff0353ca6ca41d9ee8db | |
parent | 5e28dcaace5f7b70cbe44c313b7a3b288fa38916 (diff) | |
parent | 3498b63fb0b9d2fd5a7f1f42e6c6dde772e055ce (diff) | |
download | docker-py-dbcf04388af91094a1bd0b4d562f075196054a92.tar.gz |
Merge pull request #1908 from docker/1861-credstore_login
Fix authconfig resolution when credStore is used combined with login()
-rw-r--r-- | docker/auth.py | 5 | ||||
-rw-r--r-- | tests/unit/auth_test.py | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/docker/auth.py b/docker/auth.py index 91be2b8..48fcd8b 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -90,9 +90,12 @@ def resolve_authconfig(authconfig, registry=None): log.debug( 'Using credentials store "{0}"'.format(store_name) ) - return _resolve_authconfig_credstore( + cfg = _resolve_authconfig_credstore( authconfig, registry, store_name ) + if cfg is not None: + return cfg + log.debug('No entry in credstore - fetching from auth dict') # Default to the public index server registry = resolve_index_name(registry) if registry else INDEX_NAME diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py index d6981cd..ee32ca0 100644 --- a/tests/unit/auth_test.py +++ b/tests/unit/auth_test.py @@ -210,6 +210,19 @@ class ResolveAuthTest(unittest.TestCase): self.auth_config, auth.resolve_repository_name(image)[0] ) is None + def test_resolve_auth_with_empty_credstore_and_auth_dict(self): + auth_config = { + 'auths': auth.parse_auth({ + 'https://index.docker.io/v1/': self.index_config, + }), + 'credsStore': 'blackbox' + } + with mock.patch('docker.auth._resolve_authconfig_credstore') as m: + m.return_value = None + assert 'indexuser' == auth.resolve_authconfig( + auth_config, None + )['username'] + class CredStoreTest(unittest.TestCase): def test_get_credential_store(self): |