summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorAlejandro Brito Monedero <abrito@alea-soluciones.com>2015-10-29 16:12:30 +0100
committerAlejandro Brito Monedero <abrito@alea-soluciones.com>2015-10-29 16:12:30 +0100
commita695f0ca5ab2b802f084461a957debc8f233cf94 (patch)
treefc9e34c28d3719a189f9a40d7e055cafe049da21 /tests/unit
parent47ab89ec2bd3bddf1221b856ffbaff333edeabb4 (diff)
downloaddocker-py-a695f0ca5ab2b802f084461a957debc8f233cf94.tar.gz
Fix #627
Docker-py couldn't pull private images if the account have non ascii chars in either user or password. It that case an exception ending with no auth credentials. Instead docker client (golang) don't suffer this issue. Also add a test to check the login or password even with non ascii char have a valid auth dictionary Signed-off-by: Alejandro Brito Monedero <abrito@alea-soluciones.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/auth_test.py30
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)