Merge pull request #1896 from docker/1895-login-auths

Add login data to the right subdict in auth_configs
This commit is contained in:
Joffrey F 2018-02-02 10:29:33 -08:00 committed by GitHub
commit 855b71eabe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -139,7 +139,7 @@ class DaemonApiMixin(object):
if response.status_code == 200:
if 'auths' not in self._auth_configs:
self._auth_configs['auths'] = {}
self._auth_configs[registry or auth.INDEX_NAME] = req_data
self._auth_configs['auths'][registry or auth.INDEX_NAME] = req_data
return self._result(response, json=True)
def ping(self):

View File

@ -212,6 +212,24 @@ class DockerApiTest(BaseAPIClientTest):
timeout=DEFAULT_TIMEOUT_SECONDS
)
def test_login(self):
self.client.login('sakuya', 'izayoi')
fake_request.assert_called_with(
'POST', url_prefix + 'auth',
data=json.dumps({'username': 'sakuya', 'password': 'izayoi'}),
timeout=DEFAULT_TIMEOUT_SECONDS,
headers={'Content-Type': 'application/json'}
)
assert self.client._auth_configs['auths'] == {
'docker.io': {
'email': None,
'password': 'izayoi',
'username': 'sakuya',
'serveraddress': None,
}
}
def test_events(self):
self.client.events()