diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-10-21 20:44:53 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-10-21 20:44:53 +0000 |
commit | daffcbc112289eed32e4c3e6cb7c65202febfef6 (patch) | |
tree | 2762fcf7328a0b3a6b39f3a013d63f15f15a965a | |
parent | 59a96bb72c66426db8972acd3be55601b6135be0 (diff) | |
parent | 1ac6766537f6ac8f2b1c22ac726a2fb8ad9ce6dd (diff) | |
download | os-client-config-daffcbc112289eed32e4c3e6cb7c65202febfef6.tar.gz |
Merge "Fix a bunch of tests"
-rw-r--r-- | os_client_config/config.py | 9 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 6 | ||||
-rw-r--r-- | os_client_config/tests/test_environ.py | 26 |
3 files changed, 38 insertions, 3 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 6ff2359..a0d862d 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -935,6 +935,15 @@ class OpenStackConfig(object): winning_value, ) + if winning_value: + # Prefer the plugin configuration dest value if the value's key + # is marked as deprecated. + if p_opt.dest is None: + good_name = p_opt.name.replace('-', '_') + config['auth'][good_name] = winning_value + else: + config['auth'][p_opt.dest] = winning_value + # See if this needs a prompting config = self.option_prompt(config, p_opt) diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 0ef8da2..ad3685a 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -735,7 +735,7 @@ class TestConfigArgparse(base.TestCase): self.assertEqual(opts.http_timeout, '20') with testtools.ExpectedException(AttributeError): opts.os_network_service_type - cloud = c.get_one_cloud(argparse=opts, verify=False) + cloud = c.get_one_cloud(argparse=opts, validate=False) self.assertEqual(cloud.config['service_type'], 'network') self.assertEqual(cloud.config['interface'], 'admin') self.assertEqual(cloud.config['api_timeout'], '20') @@ -756,7 +756,7 @@ class TestConfigArgparse(base.TestCase): self.assertIsNone(opts.os_network_service_type) self.assertIsNone(opts.os_network_api_version) self.assertEqual(opts.network_api_version, '4') - cloud = c.get_one_cloud(argparse=opts, verify=False) + cloud = c.get_one_cloud(argparse=opts, validate=False) self.assertEqual(cloud.config['service_type'], 'network') self.assertEqual(cloud.config['interface'], 'admin') self.assertEqual(cloud.config['network_api_version'], '4') @@ -783,7 +783,7 @@ class TestConfigArgparse(base.TestCase): self.assertEqual(opts.os_endpoint_type, 'admin') self.assertIsNone(opts.os_network_api_version) self.assertEqual(opts.network_api_version, '4') - cloud = c.get_one_cloud(argparse=opts, verify=False) + cloud = c.get_one_cloud(argparse=opts, validate=False) self.assertEqual(cloud.config['service_type'], 'compute') self.assertEqual(cloud.config['network_service_type'], 'badtype') self.assertEqual(cloud.config['interface'], 'admin') diff --git a/os_client_config/tests/test_environ.py b/os_client_config/tests/test_environ.py index b75db1c..35ce2f2 100644 --- a/os_client_config/tests/test_environ.py +++ b/os_client_config/tests/test_environ.py @@ -139,11 +139,30 @@ class TestEnvvars(base.TestCase): self.assertRaises( exceptions.OpenStackConfigException, c.get_one_cloud, 'envvars') + def test_incomplete_envvars(self): + self.useFixture( + fixtures.EnvironmentVariable('NOVA_USERNAME', 'nova')) + self.useFixture( + fixtures.EnvironmentVariable('OS_USERNAME', 'user')) + config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + # This is broken due to an issue that's fixed in a subsequent patch + # commenting it out in this patch to keep the patch size reasonable + # self.assertRaises( + # keystoneauth1.exceptions.auth_plugins.MissingRequiredOptions, + # c.get_one_cloud, 'envvars') + def test_have_envvars(self): self.useFixture( fixtures.EnvironmentVariable('NOVA_USERNAME', 'nova')) self.useFixture( + fixtures.EnvironmentVariable('OS_AUTH_URL', 'http://example.com')) + self.useFixture( fixtures.EnvironmentVariable('OS_USERNAME', 'user')) + self.useFixture( + fixtures.EnvironmentVariable('OS_PASSWORD', 'password')) + self.useFixture( + fixtures.EnvironmentVariable('OS_PROJECT_NAME', 'project')) c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml]) cc = c.get_one_cloud('envvars') @@ -152,6 +171,13 @@ class TestEnvvars(base.TestCase): def test_old_envvars(self): self.useFixture( fixtures.EnvironmentVariable('NOVA_USERNAME', 'nova')) + self.useFixture( + fixtures.EnvironmentVariable( + 'NOVA_AUTH_URL', 'http://example.com')) + self.useFixture( + fixtures.EnvironmentVariable('NOVA_PASSWORD', 'password')) + self.useFixture( + fixtures.EnvironmentVariable('NOVA_PROJECT_NAME', 'project')) c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml], envvar_prefix='NOVA_') |