diff options
author | Joffrey F <joffrey@docker.com> | 2016-02-08 17:54:14 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2016-02-09 12:08:34 -0800 |
commit | dc198be26cd4fb830c6d1febbd9adbc38e805ba0 (patch) | |
tree | c39b8d14168e87947d58eca865dab4f952f2a513 /tests/unit/auth_test.py | |
parent | 575305fdba6c57f06d605920e01b5e1d6b952d3e (diff) | |
download | docker-py-927-config-parsing.tar.gz |
Don't break when parsing unknown config keys927-config-parsing
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/unit/auth_test.py')
-rw-r--r-- | tests/unit/auth_test.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py index 3fba602..921aae0 100644 --- a/tests/unit/auth_test.py +++ b/tests/unit/auth_test.py @@ -433,3 +433,32 @@ class LoadConfigTest(base.Cleanup, base.BaseTestCase): self.assertEqual(cfg['Name'], 'Spike') self.assertEqual(cfg['Surname'], 'Spiegel') + + def test_load_config_unknown_keys(self): + folder = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, folder) + dockercfg_path = os.path.join(folder, 'config.json') + config = { + 'detachKeys': 'ctrl-q, ctrl-u, ctrl-i' + } + with open(dockercfg_path, 'w') as f: + json.dump(config, f) + + cfg = auth.load_config(dockercfg_path) + assert cfg == {} + + def test_load_config_invalid_auth_dict(self): + folder = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, folder) + dockercfg_path = os.path.join(folder, 'config.json') + config = { + 'auths': { + 'scarlet.net': {'sakuya': 'izayoi'} + } + } + with open(dockercfg_path, 'w') as f: + json.dump(config, f) + + self.assertRaises( + errors.InvalidConfigFile, auth.load_config, dockercfg_path + ) |