Default to v3 auth if we find a (user|project)-domain-(name|id) option
Change-Id: I4616492752b620de0bf90672142f1071ec9bac83
This commit is contained in:
parent
c3766319b9
commit
67f629cdeb
@ -92,11 +92,18 @@ def process_options(options):
|
||||
elif options.get('auth_version') == '2':
|
||||
options['auth_version'] = '2.0'
|
||||
|
||||
if (not (options.get('auth') and options.get('user')
|
||||
and options.get('key'))
|
||||
and options.get('auth_version') != '3'):
|
||||
# Use keystone 2.0 auth if any of the old-style args are missing
|
||||
options['auth_version'] = '2.0'
|
||||
if options.get('auth_version') not in ('2.0', '3') and not all(
|
||||
options.get(key) for key in ('auth', 'user', 'key')):
|
||||
# Use keystone auth if any of the new-style args are present
|
||||
if any(options.get(k) for k in (
|
||||
'os_user_domain_id',
|
||||
'os_user_domain_name',
|
||||
'os_project_domain_id',
|
||||
'os_project_domain_name')):
|
||||
# Use v3 if there's any reference to domains
|
||||
options['auth_version'] = '3'
|
||||
else:
|
||||
options['auth_version'] = '2.0'
|
||||
|
||||
# Use new-style args if old ones not present
|
||||
if not options['auth'] and options['os_auth_url']:
|
||||
|
@ -1197,8 +1197,7 @@ def parse_args(parser, args, enforce_requires=True):
|
||||
return options, args
|
||||
|
||||
if (options['os_options']['object_storage_url'] and
|
||||
options['os_options']['auth_token'] and
|
||||
options['auth_version'] in ('2.0', '3')):
|
||||
options['os_options']['auth_token']):
|
||||
return options, args
|
||||
|
||||
if enforce_requires:
|
||||
|
@ -1971,6 +1971,13 @@ class TestKeystoneOptions(MockHttpTest):
|
||||
self._test_options(opts, os_opts, flags=self.flags)
|
||||
|
||||
opts = {}
|
||||
self.defaults['auth-version'] = '3'
|
||||
self._test_options(opts, os_opts, flags=self.flags)
|
||||
|
||||
for o in ('user-domain-name', 'user-domain-id',
|
||||
'project-domain-name', 'project-domain-id'):
|
||||
os_opts.pop(o)
|
||||
self.defaults['auth-version'] = '2.0'
|
||||
self._test_options(opts, os_opts, flags=self.flags)
|
||||
|
||||
def test_catalog_options_and_flags_not_required_v3(self):
|
||||
@ -2021,6 +2028,28 @@ class TestKeystoneOptions(MockHttpTest):
|
||||
os_opts = self._build_os_opts(keys)
|
||||
self._test_options(opts, os_opts)
|
||||
|
||||
# ...except when it should be 3
|
||||
self.defaults['auth-version'] = '3'
|
||||
keys = ('username', 'user-domain-name', 'password', 'project-name',
|
||||
'auth-url')
|
||||
os_opts = self._build_os_opts(keys)
|
||||
self._test_options(opts, os_opts)
|
||||
|
||||
keys = ('username', 'user-domain-id', 'password', 'project-name',
|
||||
'auth-url')
|
||||
os_opts = self._build_os_opts(keys)
|
||||
self._test_options(opts, os_opts)
|
||||
|
||||
keys = ('username', 'project-domain-name', 'password', 'project-name',
|
||||
'auth-url')
|
||||
os_opts = self._build_os_opts(keys)
|
||||
self._test_options(opts, os_opts)
|
||||
|
||||
keys = ('username', 'project-domain-id', 'password', 'project-name',
|
||||
'auth-url')
|
||||
os_opts = self._build_os_opts(keys)
|
||||
self._test_options(opts, os_opts)
|
||||
|
||||
def test_url_and_token_provided_on_command_line(self):
|
||||
endpoint = 'http://alternate.com:8080/v1/AUTH_another'
|
||||
token = 'alternate_auth_token'
|
||||
|
Loading…
x
Reference in New Issue
Block a user