diff options
author | Joffrey F <f.joffrey@gmail.com> | 2015-11-18 14:29:00 -0800 |
---|---|---|
committer | Joffrey F <f.joffrey@gmail.com> | 2015-11-18 14:29:00 -0800 |
commit | 9ed721957ad42680b69141f89024e19245f1305b (patch) | |
tree | 000d5eff3099058c00465a23758afce2aa6a11f0 /tests | |
parent | 0284eadaff45e89dc9010a84ec13fae4b4bc45cc (diff) | |
parent | a695f0ca5ab2b802f084461a957debc8f233cf94 (diff) | |
download | docker-py-9ed721957ad42680b69141f89024e19245f1305b.tar.gz |
Merge pull request #832 from aebm/master
Fix #627
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/auth_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py index 9f4d439..6783038 100644 --- a/tests/unit/auth_test.py +++ b/tests/unit/auth_test.py @@ -316,3 +316,33 @@ class LoadConfigTest(base.Cleanup, base.BaseTestCase): self.assertEqual(cfg['password'], 'izayoi') self.assertEqual(cfg['email'], 'sakuya@scarlet.net') self.assertEqual(cfg.get('auth'), None) + + def test_load_config_custom_config_env_utf8(self): + folder = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, folder) + + dockercfg_path = os.path.join(folder, 'config.json') + registry = 'https://your.private.registry.io' + auth_ = base64.b64encode( + b'sakuya\xc3\xa6:izayoi\xc3\xa6').decode('ascii') + config = { + 'auths': { + registry: { + 'auth': '{0}'.format(auth_), + 'email': 'sakuya@scarlet.net' + } + } + } + + with open(dockercfg_path, 'w') as f: + json.dump(config, f) + + with mock.patch.dict(os.environ, {'DOCKER_CONFIG': folder}): + cfg = auth.load_config(None) + assert registry in cfg + self.assertNotEqual(cfg[registry], None) + cfg = cfg[registry] + self.assertEqual(cfg['username'], b'sakuya\xc3\xa6'.decode('utf8')) + self.assertEqual(cfg['password'], b'izayoi\xc3\xa6'.decode('utf8')) + self.assertEqual(cfg['email'], 'sakuya@scarlet.net') + self.assertEqual(cfg.get('auth'), None) |