Skip to content

Commit dbcf043

Browse files
authored
Merge pull request #1908 from docker/1861-credstore_login
Fix authconfig resolution when credStore is used combined with login()
2 parents 5e28dca + 3498b63 commit dbcf043

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docker/auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ def resolve_authconfig(authconfig, registry=None):
9090
log.debug(
9191
'Using credentials store "{0}"'.format(store_name)
9292
)
93-
return _resolve_authconfig_credstore(
93+
cfg = _resolve_authconfig_credstore(
9494
authconfig, registry, store_name
9595
)
96+
if cfg is not None:
97+
return cfg
98+
log.debug('No entry in credstore - fetching from auth dict')
9699

97100
# Default to the public index server
98101
registry = resolve_index_name(registry) if registry else INDEX_NAME

tests/unit/auth_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ def test_resolve_registry_and_auth_unauthenticated_registry(self):
210210
self.auth_config, auth.resolve_repository_name(image)[0]
211211
) is None
212212

213+
def test_resolve_auth_with_empty_credstore_and_auth_dict(self):
214+
auth_config = {
215+
'auths': auth.parse_auth({
216+
'https://index.docker.io/v1/': self.index_config,
217+
}),
218+
'credsStore': 'blackbox'
219+
}
220+
with mock.patch('docker.auth._resolve_authconfig_credstore') as m:
221+
m.return_value = None
222+
assert 'indexuser' == auth.resolve_authconfig(
223+
auth_config, None
224+
)['username']
225+
213226

214227
class CredStoreTest(unittest.TestCase):
215228
def test_get_credential_store(self):

0 commit comments

Comments
 (0)