Skip to content

Commit 539b321

Browse files
committed
Add login data to the right subdict in auth_configs
Signed-off-by: Joffrey F <[email protected]>
1 parent a60011c commit 539b321

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

docker/api/daemon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def login(self, username, password=None, email=None, registry=None,
139139
if response.status_code == 200:
140140
if 'auths' not in self._auth_configs:
141141
self._auth_configs['auths'] = {}
142-
self._auth_configs[registry or auth.INDEX_NAME] = req_data
142+
self._auth_configs['auths'][registry or auth.INDEX_NAME] = req_data
143143
return self._result(response, json=True)
144144

145145
def ping(self):

tests/unit/api_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ def test_search(self):
212212
timeout=DEFAULT_TIMEOUT_SECONDS
213213
)
214214

215+
def test_login(self):
216+
self.client.login('sakuya', 'izayoi')
217+
fake_request.assert_called_with(
218+
'POST', url_prefix + 'auth',
219+
data=json.dumps({'username': 'sakuya', 'password': 'izayoi'}),
220+
timeout=DEFAULT_TIMEOUT_SECONDS,
221+
headers={'Content-Type': 'application/json'}
222+
)
223+
224+
assert self.client._auth_configs['auths'] == {
225+
'docker.io': {
226+
'email': None,
227+
'password': 'izayoi',
228+
'username': 'sakuya',
229+
'serveraddress': None,
230+
}
231+
}
232+
215233
def test_events(self):
216234
self.client.events()
217235

0 commit comments

Comments
 (0)