CLI tests: Identity v3 (project name, api version)
Switch to --os-project-name instead of --os-tenant-name, and pass also --os-identity-api-version. All the clients which are wrapped by some method of the CLIClient class and which use cmd_with_auth support the newly introduced flags at least since Liberty. Only exception: the keystone client, which was removed in Newton, so it is not supported anyway (and it has not been fixed). Closes-Bug: #1721553 Change-Id: I6d34e76b4089be024093a75f9e467d273d80f1c2
This commit is contained in:
parent
5895ec110e
commit
d3db306af8
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
other:
|
||||||
|
- |
|
||||||
|
The CLIClient class, when it calls a command line client, uses
|
||||||
|
--os-project-name instead of --os-tenant-name for the project, and
|
||||||
|
passes --os-identity-api-version (default empty).
|
||||||
|
All CLI clients still available in supported releases of OpenStack
|
||||||
|
which are wrapped by the cmd_with_auth() method support those
|
||||||
|
switches.
|
@ -101,12 +101,15 @@ class CLIClient(object):
|
|||||||
:type project_domain_name: string
|
:type project_domain_name: string
|
||||||
:param project_domain_id: Project's domain ID
|
:param project_domain_id: Project's domain ID
|
||||||
:type project_domain_id: string
|
:type project_domain_id: string
|
||||||
|
:param identity_api_version: Version of the Identity API
|
||||||
|
:type identity_api_version: string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, username='', password='', tenant_name='', uri='',
|
def __init__(self, username='', password='', tenant_name='', uri='',
|
||||||
cli_dir='', insecure=False, prefix='', user_domain_name=None,
|
cli_dir='', insecure=False, prefix='', user_domain_name=None,
|
||||||
user_domain_id=None, project_domain_name=None,
|
user_domain_id=None, project_domain_name=None,
|
||||||
project_domain_id=None, *args, **kwargs):
|
project_domain_id=None, identity_api_version=None, *args,
|
||||||
|
**kwargs):
|
||||||
"""Initialize a new CLIClient object."""
|
"""Initialize a new CLIClient object."""
|
||||||
super(CLIClient, self).__init__()
|
super(CLIClient, self).__init__()
|
||||||
self.cli_dir = cli_dir if cli_dir else '/usr/bin'
|
self.cli_dir = cli_dir if cli_dir else '/usr/bin'
|
||||||
@ -120,6 +123,7 @@ class CLIClient(object):
|
|||||||
self.user_domain_id = user_domain_id
|
self.user_domain_id = user_domain_id
|
||||||
self.project_domain_name = project_domain_name
|
self.project_domain_name = project_domain_name
|
||||||
self.project_domain_id = project_domain_id
|
self.project_domain_id = project_domain_id
|
||||||
|
self.identity_api_version = identity_api_version
|
||||||
|
|
||||||
def nova(self, action, flags='', params='', fail_ok=False,
|
def nova(self, action, flags='', params='', fail_ok=False,
|
||||||
endpoint_type='publicURL', merge_stderr=False):
|
endpoint_type='publicURL', merge_stderr=False):
|
||||||
@ -374,12 +378,15 @@ class CLIClient(object):
|
|||||||
:param merge_stderr: if True the stderr buffer is merged into stdout
|
:param merge_stderr: if True the stderr buffer is merged into stdout
|
||||||
:type merge_stderr: boolean
|
:type merge_stderr: boolean
|
||||||
"""
|
"""
|
||||||
creds = ('--os-username %s --os-tenant-name %s --os-password %s '
|
creds = ('--os-username %s --os-project-name %s --os-password %s '
|
||||||
'--os-auth-url %s' %
|
'--os-auth-url %s' %
|
||||||
(self.username,
|
(self.username,
|
||||||
self.tenant_name,
|
self.tenant_name,
|
||||||
self.password,
|
self.password,
|
||||||
self.uri))
|
self.uri))
|
||||||
|
if self.identity_api_version:
|
||||||
|
creds += ' --os-identity-api-version %s' % (
|
||||||
|
self.identity_api_version)
|
||||||
if self.user_domain_name is not None:
|
if self.user_domain_name is not None:
|
||||||
creds += ' --os-user-domain-name %s' % self.user_domain_name
|
creds += ' --os-user-domain-name %s' % self.user_domain_name
|
||||||
if self.user_domain_id is not None:
|
if self.user_domain_id is not None:
|
||||||
|
@ -125,3 +125,27 @@ class TestCLIClient(base.TestCase):
|
|||||||
mock_execute.call_args[0][2])
|
mock_execute.call_args[0][2])
|
||||||
self.assertNotIn('--os-project-domain-name',
|
self.assertNotIn('--os-project-domain-name',
|
||||||
mock_execute.call_args[0][2])
|
mock_execute.call_args[0][2])
|
||||||
|
|
||||||
|
@mock.patch.object(cli_base, 'execute')
|
||||||
|
def test_execute_with_default_api_version(self, mock_execute):
|
||||||
|
cli = cli_base.CLIClient()
|
||||||
|
cli.openstack('action')
|
||||||
|
self.assertEqual(mock_execute.call_count, 1)
|
||||||
|
self.assertNotIn('--os-identity-api-version ',
|
||||||
|
mock_execute.call_args[0][2])
|
||||||
|
|
||||||
|
@mock.patch.object(cli_base, 'execute')
|
||||||
|
def test_execute_with_empty_api_version(self, mock_execute):
|
||||||
|
cli = cli_base.CLIClient(identity_api_version='')
|
||||||
|
cli.openstack('action')
|
||||||
|
self.assertEqual(mock_execute.call_count, 1)
|
||||||
|
self.assertNotIn('--os-identity-api-version ',
|
||||||
|
mock_execute.call_args[0][2])
|
||||||
|
|
||||||
|
@mock.patch.object(cli_base, 'execute')
|
||||||
|
def test_execute_with_explicit_api_version(self, mock_execute):
|
||||||
|
cli = cli_base.CLIClient(identity_api_version='0.0')
|
||||||
|
cli.openstack('action')
|
||||||
|
self.assertEqual(mock_execute.call_count, 1)
|
||||||
|
self.assertIn('--os-identity-api-version 0.0 ',
|
||||||
|
mock_execute.call_args[0][2])
|
||||||
|
Loading…
Reference in New Issue
Block a user