Allow to specify user and project domains in CLIclient
Currently it's impossible to provide related parameters to the class, which leads to clients functional tests failures. Change-Id: I50490428f85e264e6b5e3b7c83ff768a986cb8c8 Closes-bug: #1719687
This commit is contained in:
parent
f5eba41158
commit
b441134c58
@ -0,0 +1,17 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Allow to specify new domain parameters:
|
||||
|
||||
* `user_domain_name`
|
||||
* `user_domain_id`
|
||||
* `project_domain_name`
|
||||
* `project_domain_id`
|
||||
|
||||
for CLIClient class, whose values will be substituted to
|
||||
``--os-user-domain-name``, ``--os-user-domain-id``,
|
||||
``--os-project-domain-name`` and ``--os-project-domain-id`` respectively
|
||||
during command execution.
|
||||
|
||||
This allows to prevent possible test failures with authentication in
|
||||
Keystone v3. Bug: #1719687
|
@ -93,10 +93,20 @@ class CLIClient(object):
|
||||
:type insecure: boolean
|
||||
:param prefix: prefix to insert before commands
|
||||
:type prefix: string
|
||||
:param user_domain_name: User's domain name
|
||||
:type user_domain_name: string
|
||||
:param user_domain_id: User's domain ID
|
||||
:type user_domain_id: string
|
||||
:param project_domain_name: Project's domain name
|
||||
:type project_domain_name: string
|
||||
:param project_domain_id: Project's domain ID
|
||||
:type project_domain_id: string
|
||||
"""
|
||||
|
||||
def __init__(self, username='', password='', tenant_name='', uri='',
|
||||
cli_dir='', insecure=False, prefix='', *args, **kwargs):
|
||||
cli_dir='', insecure=False, prefix='', user_domain_name=None,
|
||||
user_domain_id=None, project_domain_name=None,
|
||||
project_domain_id=None, *args, **kwargs):
|
||||
"""Initialize a new CLIClient object."""
|
||||
super(CLIClient, self).__init__()
|
||||
self.cli_dir = cli_dir if cli_dir else '/usr/bin'
|
||||
@ -106,6 +116,10 @@ class CLIClient(object):
|
||||
self.uri = uri
|
||||
self.insecure = insecure
|
||||
self.prefix = prefix
|
||||
self.user_domain_name = user_domain_name
|
||||
self.user_domain_id = user_domain_id
|
||||
self.project_domain_name = project_domain_name
|
||||
self.project_domain_id = project_domain_id
|
||||
|
||||
def nova(self, action, flags='', params='', fail_ok=False,
|
||||
endpoint_type='publicURL', merge_stderr=False):
|
||||
@ -366,6 +380,14 @@ class CLIClient(object):
|
||||
self.tenant_name,
|
||||
self.password,
|
||||
self.uri))
|
||||
if self.user_domain_name is not None:
|
||||
creds += ' --os-user-domain-name %s' % self.user_domain_name
|
||||
if self.user_domain_id is not None:
|
||||
creds += ' --os-user-domain-id %s' % self.user_domain_id
|
||||
if self.project_domain_name is not None:
|
||||
creds += ' --os-project-domain-name %s' % self.project_domain_name
|
||||
if self.project_domain_id is not None:
|
||||
creds += ' --os-project-domain-id %s' % self.project_domain_id
|
||||
if self.insecure:
|
||||
flags = creds + ' --insecure ' + flags
|
||||
else:
|
||||
|
@ -91,3 +91,37 @@ class TestCLIClient(base.TestCase):
|
||||
self.assertEqual(mock_execute.call_count, 1)
|
||||
self.assertEqual(mock_execute.call_args[1],
|
||||
{'prefix': 'env LAC_ALL=C'})
|
||||
|
||||
@mock.patch.object(cli_base, 'execute')
|
||||
def test_execute_with_domain_name(self, mock_execute):
|
||||
cli = cli_base.CLIClient(
|
||||
user_domain_name='default',
|
||||
project_domain_name='default'
|
||||
)
|
||||
cli.glance('action')
|
||||
self.assertEqual(mock_execute.call_count, 1)
|
||||
self.assertIn('--os-user-domain-name default',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertIn('--os-project-domain-name default',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertNotIn('--os-user-domain-id',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertNotIn('--os-project-domain-id',
|
||||
mock_execute.call_args[0][2])
|
||||
|
||||
@mock.patch.object(cli_base, 'execute')
|
||||
def test_execute_with_domain_id(self, mock_execute):
|
||||
cli = cli_base.CLIClient(
|
||||
user_domain_id='default',
|
||||
project_domain_id='default'
|
||||
)
|
||||
cli.glance('action')
|
||||
self.assertEqual(mock_execute.call_count, 1)
|
||||
self.assertIn('--os-user-domain-id default',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertIn('--os-project-domain-id default',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertNotIn('--os-user-domain-name',
|
||||
mock_execute.call_args[0][2])
|
||||
self.assertNotIn('--os-project-domain-name',
|
||||
mock_execute.call_args[0][2])
|
||||
|
Loading…
Reference in New Issue
Block a user