Merge "Avoid string actions on non-string objects"
This commit is contained in:
commit
d100a58983
|
@ -33,7 +33,7 @@ class OSC_Config(config.OpenStackConfig):
|
||||||
Migrated from auth.select_auth_plugin()
|
Migrated from auth.select_auth_plugin()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
identity_version = config.get('identity_api_version', '')
|
identity_version = str(config.get('identity_api_version', ''))
|
||||||
|
|
||||||
if config.get('username', None) and not config.get('auth_type', None):
|
if config.get('username', None) and not config.get('auth_type', None):
|
||||||
if identity_version == '3':
|
if identity_version == '3':
|
||||||
|
@ -82,8 +82,8 @@ class OSC_Config(config.OpenStackConfig):
|
||||||
# NOTE(hieulq): If USER_DOMAIN_NAME, USER_DOMAIN_ID, PROJECT_DOMAIN_ID
|
# NOTE(hieulq): If USER_DOMAIN_NAME, USER_DOMAIN_ID, PROJECT_DOMAIN_ID
|
||||||
# or PROJECT_DOMAIN_NAME is present and API_VERSION is 2.0, then
|
# or PROJECT_DOMAIN_NAME is present and API_VERSION is 2.0, then
|
||||||
# ignore all domain related configs.
|
# ignore all domain related configs.
|
||||||
if (config.get('identity_api_version', '').startswith('2') and
|
if (str(config.get('identity_api_version', '')).startswith('2') and
|
||||||
config.get('auth_type', None).endswith('password')):
|
config.get('auth_type').endswith('password')):
|
||||||
domain_props = [
|
domain_props = [
|
||||||
'project_domain_id',
|
'project_domain_id',
|
||||||
'project_domain_name',
|
'project_domain_name',
|
||||||
|
@ -102,7 +102,7 @@ class OSC_Config(config.OpenStackConfig):
|
||||||
Migrated from clientmanager.setup_auth()
|
Migrated from clientmanager.setup_auth()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
identity_version = config.get('identity_api_version', '')
|
identity_version = str(config.get('identity_api_version', ''))
|
||||||
auth_type = config.get('auth_type', None)
|
auth_type = config.get('auth_type', None)
|
||||||
|
|
||||||
# TODO(mordred): This is a usability improvement that's broadly useful
|
# TODO(mordred): This is a usability improvement that's broadly useful
|
||||||
|
|
|
@ -46,6 +46,15 @@ class TestOSCConfig(utils.TestCase):
|
||||||
self.assertEqual('v2password', ret_config['auth_type'])
|
self.assertEqual('v2password', ret_config['auth_type'])
|
||||||
self.assertEqual('fred', ret_config['username'])
|
self.assertEqual('fred', ret_config['username'])
|
||||||
|
|
||||||
|
def test_auth_select_default_plugin_password_v2_int(self):
|
||||||
|
config = {
|
||||||
|
'identity_api_version': 2,
|
||||||
|
'username': 'fred',
|
||||||
|
}
|
||||||
|
ret_config = self.cloud._auth_select_default_plugin(config)
|
||||||
|
self.assertEqual('v2password', ret_config['auth_type'])
|
||||||
|
self.assertEqual('fred', ret_config['username'])
|
||||||
|
|
||||||
def test_auth_select_default_plugin_password_v3(self):
|
def test_auth_select_default_plugin_password_v3(self):
|
||||||
config = {
|
config = {
|
||||||
'identity_api_version': '3',
|
'identity_api_version': '3',
|
||||||
|
@ -55,6 +64,15 @@ class TestOSCConfig(utils.TestCase):
|
||||||
self.assertEqual('v3password', ret_config['auth_type'])
|
self.assertEqual('v3password', ret_config['auth_type'])
|
||||||
self.assertEqual('fred', ret_config['username'])
|
self.assertEqual('fred', ret_config['username'])
|
||||||
|
|
||||||
|
def test_auth_select_default_plugin_password_v3_int(self):
|
||||||
|
config = {
|
||||||
|
'identity_api_version': 3,
|
||||||
|
'username': 'fred',
|
||||||
|
}
|
||||||
|
ret_config = self.cloud._auth_select_default_plugin(config)
|
||||||
|
self.assertEqual('v3password', ret_config['auth_type'])
|
||||||
|
self.assertEqual('fred', ret_config['username'])
|
||||||
|
|
||||||
def test_auth_select_default_plugin_token(self):
|
def test_auth_select_default_plugin_token(self):
|
||||||
config = {
|
config = {
|
||||||
'token': 'subway',
|
'token': 'subway',
|
||||||
|
|
Loading…
Reference in New Issue