summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-02-01 16:02:09 -0800
committerJoffrey F <joffrey@docker.com>2018-02-05 13:38:19 -0800
commit539b321bd1dfc5cbbba4c1573cd46adb0f47a3f1 (patch)
tree778fb3ce37cce7fc18134685e249c807477d43d6
parenta60011ca3a7142d28282b70d87708b6c66e85c51 (diff)
downloaddocker-py-539b321bd1dfc5cbbba4c1573cd46adb0f47a3f1.tar.gz
Add login data to the right subdict in auth_configs
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/daemon.py2
-rw-r--r--tests/unit/api_test.py18
2 files changed, 19 insertions, 1 deletions
diff --git a/docker/api/daemon.py b/docker/api/daemon.py
index 033dbf1..0e1c753 100644
--- a/docker/api/daemon.py
+++ b/docker/api/daemon.py
@@ -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):
diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py
index c53a4be..f65e13e 100644
--- a/tests/unit/api_test.py
+++ b/tests/unit/api_test.py
@@ -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()