Fix parsing of tenant/project_name values
The parsing of tenant_name value from tempest.conf ends with an error as the ConfigParser.get() function fails if a requested value is missing in a config file. This patch fixes the issue by using the fallback option of the ConfigParser.get() function. Also, the unittest that checks the reading of [identity] section from tempest.conf is fixed. Change-Id: I9b3224f4ab8900a4954814844ef8c13e099ccae9
This commit is contained in:
parent
23d9f5d7df
commit
340344526b
@ -228,7 +228,8 @@ class RefstackClient:
|
||||
project_id = conf_file.get('identity', 'project_id')
|
||||
else:
|
||||
project_id = None
|
||||
project_name = (conf_file.get('identity', 'tenant_name') or
|
||||
project_name = (conf_file.get('identity', 'tenant_name',
|
||||
fallback=False) or
|
||||
conf_file.get('identity', 'project_name'))
|
||||
return {'auth_version': auth_version,
|
||||
'auth_url': auth_url,
|
||||
|
@ -4,7 +4,8 @@ uri = http://0.0.0.0:35357/v2.0
|
||||
uri_v3 = http://0.0.0.0:35357/v3
|
||||
username = admin
|
||||
password = test
|
||||
tenant_id = admin_tenant_id
|
||||
tenant_id = admin_project_id
|
||||
project_name = project_name
|
||||
|
||||
[identity-feature-enabled]
|
||||
api_v2 = true
|
||||
|
@ -189,17 +189,19 @@ class TestRefstackClient(unittest.TestCase):
|
||||
|
||||
def test_get_keystone_config_no_accounts_file(self):
|
||||
"""
|
||||
Test that the client will exit if accounts file
|
||||
is not specified.
|
||||
Test that the client will read account info from
|
||||
tempest.conf when the accounts file is not specified.
|
||||
"""
|
||||
args = rc.parse_cli_args(self.mock_argv())
|
||||
client = rc.RefstackClient(args)
|
||||
client.tempest_dir = self.test_path
|
||||
client._prep_test()
|
||||
|
||||
self.mock_data()
|
||||
with self.assertRaises(SystemExit):
|
||||
client._get_keystone_config(client.conf)
|
||||
|
||||
actual_result = client._get_keystone_config(client.conf)
|
||||
|
||||
expected_result = self.v2_config
|
||||
self.assertEqual(expected_result, actual_result)
|
||||
|
||||
def test_get_keystone_config(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user