Skip to content

Commit 9ed7219

Browse files
committed
Merge pull request #832 from aebm/master
Fix #627
2 parents 0284ead + a695f0c commit 9ed7219

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

docker/auth/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def decode_auth(auth):
9696
auth = auth.encode('ascii')
9797
s = base64.b64decode(auth)
9898
login, pwd = s.split(b':', 1)
99-
return login.decode('ascii'), pwd.decode('ascii')
99+
return login.decode('utf8'), pwd.decode('utf8')
100100

101101

102102
def encode_header(auth):

tests/unit/auth_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,33 @@ def test_load_config_custom_config_env_with_auths(self):
316316
self.assertEqual(cfg['password'], 'izayoi')
317317
self.assertEqual(cfg['email'], '[email protected]')
318318
self.assertEqual(cfg.get('auth'), None)
319+
320+
def test_load_config_custom_config_env_utf8(self):
321+
folder = tempfile.mkdtemp()
322+
self.addCleanup(shutil.rmtree, folder)
323+
324+
dockercfg_path = os.path.join(folder, 'config.json')
325+
registry = 'https://your.private.registry.io'
326+
auth_ = base64.b64encode(
327+
b'sakuya\xc3\xa6:izayoi\xc3\xa6').decode('ascii')
328+
config = {
329+
'auths': {
330+
registry: {
331+
'auth': '{0}'.format(auth_),
332+
'email': '[email protected]'
333+
}
334+
}
335+
}
336+
337+
with open(dockercfg_path, 'w') as f:
338+
json.dump(config, f)
339+
340+
with mock.patch.dict(os.environ, {'DOCKER_CONFIG': folder}):
341+
cfg = auth.load_config(None)
342+
assert registry in cfg
343+
self.assertNotEqual(cfg[registry], None)
344+
cfg = cfg[registry]
345+
self.assertEqual(cfg['username'], b'sakuya\xc3\xa6'.decode('utf8'))
346+
self.assertEqual(cfg['password'], b'izayoi\xc3\xa6'.decode('utf8'))
347+
self.assertEqual(cfg['email'], '[email protected]')
348+
self.assertEqual(cfg.get('auth'), None)

0 commit comments

Comments
 (0)