Auth_creds should show the user specified values

Make auth_creds display the user specified credentials
which are project_name and username. Normally
vim configuration yaml file has no project_id and user_id

Change-Id: I987ad7bda04b0a161c56284f77964063490a18e0
Closes-Bug: #1629169
This commit is contained in:
venkatamahesh 2016-11-23 17:37:07 +05:30
parent d26d358145
commit 506f4cc4b9
3 changed files with 9 additions and 13 deletions

View File

@ -24,17 +24,15 @@ def args2body_vim(config_param, vim):
:param vim: vim request object :param vim: vim request object
:return: vim body with args populated :return: vim body with args populated
""" """
vim['vim_project'] = {'id': config_param.pop('project_id', ''), vim['vim_project'] = {'name': config_param.pop('project_name', ''),
'name': config_param.pop('project_name', ''),
'project_domain_name': 'project_domain_name':
config_param.pop('project_domain_name', '')} config_param.pop('project_domain_name', '')}
if not vim['vim_project']['id'] and not vim['vim_project']['name']: if not vim['vim_project']['name']:
raise exceptions.TackerClientException(message='Project Id or name ' raise exceptions.TackerClientException(message='Project name '
'must be specified', 'must be specified',
status_code=404) status_code=404)
vim['auth_cred'] = {'username': config_param.pop('username', ''), vim['auth_cred'] = {'username': config_param.pop('username', ''),
'password': config_param.pop('password', ''), 'password': config_param.pop('password', ''),
'user_id': config_param.pop('user_id', ''),
'user_domain_name': 'user_domain_name':
config_param.pop('user_domain_name', '')} config_param.pop('user_domain_name', '')}

View File

@ -35,10 +35,10 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
plurals = {'vims': 'vim'} plurals = {'vims': 'vim'}
super(CLITestV10VIMJSON, self).setUp(plurals=plurals) super(CLITestV10VIMJSON, self).setUp(plurals=plurals)
self.vim_project = { self.vim_project = {
'name': 'abc', 'id': '', 'name': 'abc',
'project_domain_name': 'prj_domain_name'} 'project_domain_name': 'prj_domain_name'}
self.auth_cred = {'username': 'xyz', 'password': '12345', 'user_id': self.auth_cred = {'username': 'xyz', 'password': '12345',
'', 'user_domain_name': 'user_domain_name'} 'user_domain_name': 'user_domain_name'}
self.auth_url = 'http://1.2.3.4:5000' self.auth_url = 'http://1.2.3.4:5000'
def test_register_vim_all_params(self): def test_register_vim_all_params(self):

View File

@ -24,20 +24,18 @@ from tackerclient.tacker.v1_0.nfvo import vim_utils
class TestVIMUtils(testtools.TestCase): class TestVIMUtils(testtools.TestCase):
def test_args2body_vim(self): def test_args2body_vim(self):
config_param = {'project_id': sentinel.prj_id1, config_param = {'project_name': sentinel.prj_name,
'username': sentinel.usrname1, 'username': sentinel.usrname1,
'password': sentinel.password1, 'password': sentinel.password1,
'project_domain_name': sentinel.prj_domain_name1, 'project_domain_name': sentinel.prj_domain_name1,
'user_domain_name': sentinel.user_domain.name, } 'user_domain_name': sentinel.user_domain.name, }
vim = {} vim = {}
auth_cred = config_param.copy() auth_cred = config_param.copy()
auth_cred.pop('project_id') auth_cred.pop('project_name')
auth_cred.pop('project_domain_name') auth_cred.pop('project_domain_name')
auth_cred.update({'user_id': ''})
expected_vim = {'auth_cred': auth_cred, expected_vim = {'auth_cred': auth_cred,
'vim_project': 'vim_project':
{'id': sentinel.prj_id1, {'name': sentinel.prj_name,
'name': '',
'project_domain_name': sentinel.prj_domain_name1}} 'project_domain_name': sentinel.prj_domain_name1}}
vim_utils.args2body_vim(config_param.copy(), vim) vim_utils.args2body_vim(config_param.copy(), vim)
self.assertEqual(expected_vim, vim) self.assertEqual(expected_vim, vim)