diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-12-21 14:02:55 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-12-21 14:02:55 +0000 |
commit | 94915f149cd1ab950513437fdcdab850c7a4ea96 (patch) | |
tree | 6309473415e2cdc839b740512657cca37bf8fe8a /os_client_config/tests/test_config.py | |
parent | 88b7e643b9637864252d9c6b715da0dced606352 (diff) | |
parent | 22d740b7007e1182c99370cb2629322384b17a14 (diff) | |
download | os-client-config-94915f149cd1ab950513437fdcdab850c7a4ea96.tar.gz |
Merge "Add backwards compat mapping for auth-token"
Diffstat (limited to 'os_client_config/tests/test_config.py')
-rw-r--r-- | os_client_config/tests/test_config.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 98aaf79..bb45693 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -243,7 +243,9 @@ class TestConfigArgparse(base.TestCase): project_name='project', region_name='region2', snack_type='cookie', + os_auth_token='no-good-things', ) + self.options = argparse.Namespace(**self.args) def test_get_one_cloud_bad_region_argparse(self): @@ -401,6 +403,34 @@ class TestConfigArgparse(base.TestCase): opts, _remain = parser.parse_known_args(['--os-cloud', 'foo']) self.assertEqual(opts.os_cloud, 'foo') + def test_argparse_default_no_token(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + + parser = argparse.ArgumentParser() + c.register_argparse_arguments(parser, []) + # novaclient will add this + parser.add_argument('--os-auth-token') + opts, _remain = parser.parse_known_args() + cc = c.get_one_cloud( + cloud='_test_cloud_regions', argparse=opts) + self.assertEqual(cc.config['auth_type'], 'password') + self.assertNotIn('token', cc.config['auth']) + + def test_argparse_token(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + + parser = argparse.ArgumentParser() + c.register_argparse_arguments(parser, []) + # novaclient will add this + parser.add_argument('--os-auth-token') + opts, _remain = parser.parse_known_args( + ['--os-auth-token', 'very-bad-things']) + cc = c.get_one_cloud(argparse=opts) + self.assertEqual(cc.config['auth_type'], 'token') + self.assertEqual(cc.config['auth']['token'], 'very-bad-things') + def test_register_argparse_bad_plugin(self): c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml]) |