Merge "enhance tests for user v3"
This commit is contained in:
commit
154f4ed347
@ -96,12 +96,14 @@ class IdentityTests(test.TestCase):
|
|||||||
'user create '
|
'user create '
|
||||||
'--domain %(domain)s '
|
'--domain %(domain)s '
|
||||||
'--project %(project)s '
|
'--project %(project)s '
|
||||||
|
'--project-domain %(project_domain)s '
|
||||||
'--password %(password)s '
|
'--password %(password)s '
|
||||||
'--email %(email)s '
|
'--email %(email)s '
|
||||||
'--description %(description)s '
|
'--description %(description)s '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s' % {'domain': self.domain_name,
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
'project': self.project_name,
|
'project': self.project_name,
|
||||||
|
'project_domain': self.domain_name,
|
||||||
'email': email,
|
'email': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
'description': description,
|
'description': description,
|
||||||
|
@ -53,9 +53,43 @@ class UserTests(test_identity.IdentityTests):
|
|||||||
'--domain %(domain)s '
|
'--domain %(domain)s '
|
||||||
'%(name)s' % {'domain': self.domain_name,
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
'name': new_username})
|
'name': new_username})
|
||||||
new_user = self.parse_show_as_object(raw_output)
|
updated_user = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(user['id'], new_user['id'])
|
self.assertEqual(user['id'], updated_user['id'])
|
||||||
self.assertEqual(new_email, new_user['email'])
|
self.assertEqual(new_email, updated_user['email'])
|
||||||
|
|
||||||
|
def test_user_set_default_project_id(self):
|
||||||
|
username = self._create_dummy_user()
|
||||||
|
project_name = self._create_dummy_project()
|
||||||
|
# get original user details
|
||||||
|
raw_output = self.openstack('user show '
|
||||||
|
'--domain %(domain)s '
|
||||||
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
|
'name': username})
|
||||||
|
user = self.parse_show_as_object(raw_output)
|
||||||
|
# update user
|
||||||
|
raw_output = self.openstack('user set '
|
||||||
|
'--project %(project)s '
|
||||||
|
'--project-domain %(project_domain)s '
|
||||||
|
'%(id)s' % {'project': project_name,
|
||||||
|
'project_domain':
|
||||||
|
self.domain_name,
|
||||||
|
'id': user['id']})
|
||||||
|
self.assertEqual(0, len(raw_output))
|
||||||
|
# get updated user details
|
||||||
|
raw_output = self.openstack('user show '
|
||||||
|
'--domain %(domain)s '
|
||||||
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
|
'name': username})
|
||||||
|
updated_user = self.parse_show_as_object(raw_output)
|
||||||
|
# get project details
|
||||||
|
raw_output = self.openstack('project show '
|
||||||
|
'--domain %(domain)s '
|
||||||
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
|
'name': project_name})
|
||||||
|
project = self.parse_show_as_object(raw_output)
|
||||||
|
# check updated user details
|
||||||
|
self.assertEqual(user['id'], updated_user['id'])
|
||||||
|
self.assertEqual(project['id'], updated_user['default_project_id'])
|
||||||
|
|
||||||
def test_user_show(self):
|
def test_user_show(self):
|
||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
|
@ -956,6 +956,39 @@ class TestUserSet(TestUser):
|
|||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_user_set_project_domain(self):
|
||||||
|
arglist = [
|
||||||
|
'--project', identity_fakes.project_id,
|
||||||
|
'--project-domain', identity_fakes.domain_id,
|
||||||
|
identity_fakes.user_name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('name', None),
|
||||||
|
('password', None),
|
||||||
|
('email', None),
|
||||||
|
('project', identity_fakes.project_id),
|
||||||
|
('project_domain', identity_fakes.domain_id),
|
||||||
|
('enable', False),
|
||||||
|
('disable', False),
|
||||||
|
('user', identity_fakes.user_name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
# DisplayCommandBase.take_action() returns two tuples
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
# Set expected values
|
||||||
|
kwargs = {
|
||||||
|
'enabled': True,
|
||||||
|
'default_project': identity_fakes.project_id,
|
||||||
|
}
|
||||||
|
# UserManager.update(user, name=, domain=, project=, password=,
|
||||||
|
# email=, description=, enabled=, default_project=)
|
||||||
|
self.users_mock.update.assert_called_with(
|
||||||
|
identity_fakes.user_id,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
def test_user_set_enable(self):
|
def test_user_set_enable(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--enable',
|
'--enable',
|
||||||
|
Loading…
Reference in New Issue
Block a user