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':
|
elif options.get('auth_version') == '2':
|
||||||
options['auth_version'] = '2.0'
|
options['auth_version'] = '2.0'
|
||||||
|
|
||||||
if (not (options.get('auth') and options.get('user')
|
if options.get('auth_version') not in ('2.0', '3') and not all(
|
||||||
and options.get('key'))
|
options.get(key) for key in ('auth', 'user', 'key')):
|
||||||
and options.get('auth_version') != '3'):
|
# Use keystone auth if any of the new-style args are present
|
||||||
# Use keystone 2.0 auth if any of the old-style args are missing
|
if any(options.get(k) for k in (
|
||||||
options['auth_version'] = '2.0'
|
'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
|
# Use new-style args if old ones not present
|
||||||
if not options['auth'] and options['os_auth_url']:
|
if not options['auth'] and options['os_auth_url']:
|
||||||
|
@ -1197,8 +1197,7 @@ def parse_args(parser, args, enforce_requires=True):
|
|||||||
return options, args
|
return options, args
|
||||||
|
|
||||||
if (options['os_options']['object_storage_url'] and
|
if (options['os_options']['object_storage_url'] and
|
||||||
options['os_options']['auth_token'] and
|
options['os_options']['auth_token']):
|
||||||
options['auth_version'] in ('2.0', '3')):
|
|
||||||
return options, args
|
return options, args
|
||||||
|
|
||||||
if enforce_requires:
|
if enforce_requires:
|
||||||
|
@ -1971,6 +1971,13 @@ class TestKeystoneOptions(MockHttpTest):
|
|||||||
self._test_options(opts, os_opts, flags=self.flags)
|
self._test_options(opts, os_opts, flags=self.flags)
|
||||||
|
|
||||||
opts = {}
|
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)
|
self._test_options(opts, os_opts, flags=self.flags)
|
||||||
|
|
||||||
def test_catalog_options_and_flags_not_required_v3(self):
|
def test_catalog_options_and_flags_not_required_v3(self):
|
||||||
@ -2021,6 +2028,28 @@ class TestKeystoneOptions(MockHttpTest):
|
|||||||
os_opts = self._build_os_opts(keys)
|
os_opts = self._build_os_opts(keys)
|
||||||
self._test_options(opts, os_opts)
|
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):
|
def test_url_and_token_provided_on_command_line(self):
|
||||||
endpoint = 'http://alternate.com:8080/v1/AUTH_another'
|
endpoint = 'http://alternate.com:8080/v1/AUTH_another'
|
||||||
token = 'alternate_auth_token'
|
token = 'alternate_auth_token'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user