summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <f.joffrey@gmail.com>2018-02-02 10:29:33 -0800
committerGitHub <noreply@github.com>2018-02-02 10:29:33 -0800
commit855b71eabe54733c49ae2814c88ac91a34ec5da6 (patch)
tree2c5bc07fce9def37b96795e319b831f4fc5cf7f2
parentf00e76cac96cb2c27429faaa6d1e30272cadf2e0 (diff)
parent83d185d69533757eac4beef646f1e46737bdd67f (diff)
downloaddocker-py-855b71eabe54733c49ae2814c88ac91a34ec5da6.tar.gz
Merge pull request #1896 from docker/1895-login-auths
Add login data to the right subdict in auth_configs
-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()