summaryrefslogtreecommitdiff
path: root/tempest/api/identity/admin
diff options
context:
space:
mode:
authorzhufl <zhu.fanglei@zte.com.cn>2017-04-11 16:02:39 +0800
committerzhufl <zhu.fanglei@zte.com.cn>2017-04-13 11:35:32 +0000
commit75d51a9badb7c3fec1ce6064d3bbff4d767125ba (patch)
tree1d73f556a893ac46f5693566e24f0e3d610be7da /tempest/api/identity/admin
parentb86de8898f60af921980c00991f34248e100ccf9 (diff)
downloadtempest-75d51a9badb7c3fec1ce6064d3bbff4d767125ba.tar.gz
Remove leading underscore in _create_test_user
This is to remove leading underscore in _create_test_user, and to generate some random values for the fields that are not given, so create_test_user can be more widely used to make code clean. Change-Id: Iacb6c1390de3718694dc3a1bb5ec2012e4164b13
Diffstat (limited to 'tempest/api/identity/admin')
-rw-r--r--tempest/api/identity/admin/v2/test_tokens.py21
-rw-r--r--tempest/api/identity/admin/v2/test_users.py66
-rw-r--r--tempest/api/identity/admin/v3/test_groups.py11
-rw-r--r--tempest/api/identity/admin/v3/test_tokens.py12
4 files changed, 24 insertions, 86 deletions
diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py
index 3428c07c1..af76b0055 100644
--- a/tempest/api/identity/admin/v2/test_tokens.py
+++ b/tempest/api/identity/admin/v2/test_tokens.py
@@ -31,12 +31,10 @@ class TokensTestJSON(base.BaseIdentityV2AdminTest):
# Delete the tenant at the end of the test
self.addCleanup(self.tenants_client.delete_tenant, tenant['id'])
# second:create a user
- user = self.users_client.create_user(name=user_name,
- password=user_password,
- tenantId=tenant['id'],
- email='')['user']
- # Delete the user at the end of the test
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(name=user_name,
+ password=user_password,
+ tenantId=tenant['id'],
+ email='')
# then get a token for the user
body = self.token_client.auth(user_name,
user_password,
@@ -65,13 +63,10 @@ class TokensTestJSON(base.BaseIdentityV2AdminTest):
user_name = data_utils.rand_name(name='user')
user_password = data_utils.rand_password()
tenant_id = None # No default tenant so will get unscoped token.
- email = ''
- user = self.users_client.create_user(name=user_name,
- password=user_password,
- tenantId=tenant_id,
- email=email)['user']
- # Delete the user at the end of the test
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(name=user_name,
+ password=user_password,
+ tenantId=tenant_id,
+ email='')
# Create a couple tenants.
tenant1_name = data_utils.rand_name(name='tenant')
diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py
index df4ded85f..af94b5491 100644
--- a/tempest/api/identity/admin/v2/test_users.py
+++ b/tempest/api/identity/admin/v2/test_users.py
@@ -19,7 +19,6 @@ from testtools import matchers
from tempest.api.identity import base
from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
from tempest import test
@@ -30,7 +29,6 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
def resource_setup(cls):
super(UsersTestJSON, cls).resource_setup()
cls.alt_user = data_utils.rand_name('test_user')
- cls.alt_password = data_utils.rand_password()
cls.alt_email = cls.alt_user + '@testmail.tm'
@test.attr(type='smoke')
@@ -38,12 +36,7 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
def test_create_user(self):
# Create a user
tenant = self.setup_test_tenant()
- user = self.users_client.create_user(name=self.alt_user,
- password=self.alt_password,
- tenantId=tenant['id'],
- email=self.alt_email)['user']
- # Delete the User at the end of the test
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(name=self.alt_user, tenantId=tenant['id'])
self.assertEqual(self.alt_user, user['name'])
@decorators.idempotent_id('89d9fdb8-15c2-4304-a429-48715d0af33d')
@@ -51,13 +44,10 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
# Create a user with enabled : False
tenant = self.setup_test_tenant()
name = data_utils.rand_name('test_user')
- user = self.users_client.create_user(name=name,
- password=self.alt_password,
- tenantId=tenant['id'],
- email=self.alt_email,
- enabled=False)['user']
- # Delete the User at the end of the test
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(name=name,
+ tenantId=tenant['id'],
+ email=self.alt_email,
+ enabled=False)
self.assertEqual(name, user['name'])
self.assertEqual(False, user['enabled'])
self.assertEqual(self.alt_email, user['email'])
@@ -65,14 +55,9 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
@decorators.idempotent_id('39d05857-e8a5-4ed4-ba83-0b52d3ab97ee')
def test_update_user(self):
# Test case to check if updating of user attributes is successful.
- test_user = data_utils.rand_name('test_user')
tenant = self.setup_test_tenant()
- user = self.users_client.create_user(name=test_user,
- password=self.alt_password,
- tenantId=tenant['id'],
- email=self.alt_email)['user']
- # Delete the User at the end of this method
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(tenantId=tenant['id'])
+
# Updating user details with new values
u_name2 = data_utils.rand_name('user2')
u_email2 = u_name2 + '@testmail.tm'
@@ -92,15 +77,8 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
@decorators.idempotent_id('29ed26f4-a74e-4425-9a85-fdb49fa269d2')
def test_delete_user(self):
# Delete a user
- test_user = data_utils.rand_name('test_user')
tenant = self.setup_test_tenant()
- user = self.users_client.create_user(name=test_user,
- password=self.alt_password,
- tenantId=tenant['id'],
- email=self.alt_email)['user']
- # Delete the User at the end of the test
- self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- self.users_client.delete_user, user['id'])
+ user = self.create_test_user(tenantId=tenant['id'])
self.users_client.delete_user(user['id'])
@decorators.idempotent_id('aca696c3-d645-4f45-b728-63646045beb1')
@@ -152,24 +130,10 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
tenant = self.setup_test_tenant()
user_ids = list()
fetched_user_ids = list()
- password1 = data_utils.rand_password()
- alt_tenant_user1 = data_utils.rand_name('tenant_user1')
- user1 = self.users_client.create_user(name=alt_tenant_user1,
- password=password1,
- tenantId=tenant['id'],
- email='user1@123')['user']
+ user1 = self.create_test_user(tenantId=tenant['id'])
user_ids.append(user1['id'])
- # Delete the User at the end of the test
- self.addCleanup(self.users_client.delete_user, user1['id'])
- password2 = data_utils.rand_password()
- alt_tenant_user2 = data_utils.rand_name('tenant_user2')
- user2 = self.users_client.create_user(name=alt_tenant_user2,
- password=password2,
- tenantId=tenant['id'],
- email='user2@123')['user']
+ user2 = self.create_test_user(tenantId=tenant['id'])
user_ids.append(user2['id'])
- # Delete the User at the end of the test
- self.addCleanup(self.users_client.delete_user, user2['id'])
# List of users for the respective tenant ID
body = (self.tenants_client.list_tenant_users(tenant['id'])
['users'])
@@ -195,16 +159,8 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
role = self.roles_client.create_user_role_on_project(
tenant['id'], user['id'], role['id'])['role']
- alt_user2 = data_utils.rand_name('second_user')
- alt_password2 = data_utils.rand_password()
- second_user = self.users_client.create_user(
- name=alt_user2,
- password=alt_password2,
- tenantId=tenant['id'],
- email='user2@123')['user']
+ second_user = self.create_test_user(tenantId=tenant['id'])
user_ids.append(second_user['id'])
- # Delete the User at the end of the test
- self.addCleanup(self.users_client.delete_user, second_user['id'])
role = self.roles_client.create_user_role_on_project(
tenant['id'], second_user['id'], role['id'])['role']
# List of users with roles for the respective tenant ID
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index a423a128b..8fdd0ec4f 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -82,12 +82,8 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest):
# add user into group
users = []
for _ in range(3):
- name = data_utils.rand_name('User')
- password = data_utils.rand_password()
- user = self.users_client.create_user(name=name,
- password=password)['user']
+ user = self.create_test_user()
users.append(user)
- self.addCleanup(self.users_client.delete_user, user['id'])
self.groups_client.add_group_user(group['id'], user['id'])
# list users in group
@@ -105,10 +101,7 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest):
@decorators.idempotent_id('64573281-d26a-4a52-b899-503cb0f4e4ec')
def test_list_user_groups(self):
# create a user
- user = self.users_client.create_user(
- name=data_utils.rand_name('User'),
- password=data_utils.rand_password())['user']
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user()
# create two groups, and add user into them
groups = []
for _ in range(2):
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index fabb91c34..c6b562b56 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -32,12 +32,9 @@ class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
# Create a User
u_name = data_utils.rand_name('user')
u_desc = '%s-description' % u_name
- u_email = '%s@testmail.tm' % u_name
u_password = data_utils.rand_password()
- user = self.users_client.create_user(
- name=u_name, description=u_desc, password=u_password,
- email=u_email)['user']
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(
+ name=u_name, description=u_desc, password=u_password)
# Perform Authentication
resp = self.token.auth(user_id=user['id'],
password=u_password).response
@@ -63,11 +60,8 @@ class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
"""
# Create a user.
- user_name = data_utils.rand_name(name='user')
user_password = data_utils.rand_password()
- user = self.users_client.create_user(name=user_name,
- password=user_password)['user']
- self.addCleanup(self.users_client.delete_user, user['id'])
+ user = self.create_test_user(password=user_password)
# Create a couple projects
project1_name = data_utils.rand_name(name='project')