Browse Source

Merge "Adding description for testcases - identity part3"

changes/37/642237/3
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
40ed7ac833
9 changed files with 115 additions and 58 deletions
  1. +7
    -2
      tempest/api/identity/admin/v2/test_services.py
  2. +11
    -7
      tempest/api/identity/admin/v2/test_tenants.py
  3. +34
    -22
      tempest/api/identity/admin/v2/test_users_negative.py
  4. +8
    -3
      tempest/api/identity/admin/v3/test_domains.py
  5. +13
    -3
      tempest/api/identity/admin/v3/test_domains_negative.py
  6. +5
    -0
      tempest/api/identity/admin/v3/test_endpoints.py
  7. +11
    -5
      tempest/api/identity/admin/v3/test_list_projects.py
  8. +13
    -9
      tempest/api/identity/admin/v3/test_projects.py
  9. +13
    -7
      tempest/api/identity/admin/v3/test_projects_negative.py

+ 7
- 2
tempest/api/identity/admin/v2/test_services.py View File

@@ -20,6 +20,7 @@ from tempest.lib import exceptions as lib_exc


class ServicesTestJSON(base.BaseIdentityV2AdminTest):
"""Test identity services via v2 API"""

def _del_service(self, service_id):
# Deleting the service created in this method
@@ -30,6 +31,7 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('84521085-c6e6-491c-9a08-ec9f70f90110')
def test_create_get_delete_service(self):
"""Test verifies the identity service create/get/delete via v2 API"""
# GET Service
# Creating a Service
name = data_utils.rand_name('service')
@@ -64,7 +66,10 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('5d3252c8-e555-494b-a6c8-e11d7335da42')
def test_create_service_without_description(self):
# Create a service only with name and type
"""Test creating identity service without description via v2 API

Create a service only with name and type.
"""
name = data_utils.rand_name('service')
s_type = data_utils.rand_name('type')
service = self.services_client.create_service(
@@ -79,7 +84,7 @@ class ServicesTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type='smoke')
@decorators.idempotent_id('34ea6489-012d-4a86-9038-1287cadd5eca')
def test_list_services(self):
# Create, List, Verify and Delete Services
"""Test Create/List/Verify/Delete of identity service via v2 API"""
services = []
for _ in range(3):
name = data_utils.rand_name('service')


+ 11
- 7
tempest/api/identity/admin/v2/test_tenants.py View File

@@ -19,10 +19,14 @@ from tempest.lib import decorators


class TenantsTestJSON(base.BaseIdentityV2AdminTest):
"""Test identity tenants via v2 API"""

@decorators.idempotent_id('16c6e05c-6112-4b0e-b83f-5e43f221b6b0')
def test_tenant_list_delete(self):
# Create several tenants and delete them
"""Test listing and deleting tenants via v2 API

Create several tenants and delete them
"""
tenants = []
for _ in range(3):
tenant = self.setup_test_tenant()
@@ -41,7 +45,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('d25e9f24-1310-4d29-b61b-d91299c21d6d')
def test_tenant_create_with_description(self):
# Create tenant with a description
"""Test creating tenant with a description via v2 API"""
tenant_desc = data_utils.rand_name(name='desc')
tenant = self.setup_test_tenant(description=tenant_desc)
tenant_id = tenant['id']
@@ -56,7 +60,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('670bdddc-1cd7-41c7-b8e2-751cfb67df50')
def test_tenant_create_enabled(self):
# Create a tenant that is enabled
"""Test creating a tenant that is enabled via v2 API"""
tenant = self.setup_test_tenant(enabled=True)
tenant_id = tenant['id']
self.assertTrue(tenant['enabled'], 'Enable should be True in response')
@@ -66,7 +70,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('3be22093-b30f-499d-b772-38340e5e16fb')
def test_tenant_create_not_enabled(self):
# Create a tenant that is not enabled
"""Test creating a tenant that is not enabled via v2 API"""
tenant = self.setup_test_tenant(enabled=False)
tenant_id = tenant['id']
self.assertFalse(tenant['enabled'],
@@ -78,7 +82,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('781f2266-d128-47f3-8bdb-f70970add238')
def test_tenant_update_name(self):
# Update name attribute of a tenant
"""Test updating name attribute of a tenant via v2 API"""
t_name1 = data_utils.rand_name(name='tenant')
tenant = self.setup_test_tenant(name=t_name1)
t_id = tenant['id']
@@ -100,7 +104,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('859fcfe1-3a03-41ef-86f9-b19a47d1cd87')
def test_tenant_update_desc(self):
# Update description attribute of a tenant
"""Test updating description attribute of a tenant via v2 API"""
t_desc = data_utils.rand_name(name='desc')
tenant = self.setup_test_tenant(description=t_desc)
t_id = tenant['id']
@@ -123,7 +127,7 @@ class TenantsTestJSON(base.BaseIdentityV2AdminTest):

@decorators.idempotent_id('8fc8981f-f12d-4c66-9972-2bdcf2bc2e1a')
def test_tenant_update_enable(self):
# Update the enabled attribute of a tenant
"""Test updating the enabled attribute of a tenant via v2 API"""
t_en = False
tenant = self.setup_test_tenant(enabled=t_en)
t_id = tenant['id']


+ 34
- 22
tempest/api/identity/admin/v2/test_users_negative.py View File

@@ -20,6 +20,7 @@ from tempest.lib import exceptions as lib_exc


class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
"""Negative tests of identity users via v2 API"""

@classmethod
def resource_setup(cls):
@@ -31,7 +32,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('60a1f5fa-5744-4cdf-82bf-60b7de2d29a4')
def test_create_user_by_unauthorized_user(self):
# Non-administrator should not be authorized to create a user
"""Non-admin should not be authorized to create a user via v2 API"""
tenant = self.setup_test_tenant()
self.assertRaises(lib_exc.Forbidden,
self.non_admin_users_client.create_user,
@@ -42,7 +43,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('d80d0c2f-4514-4d1e-806d-0930dfc5a187')
def test_create_user_with_empty_name(self):
# User with an empty name should not be created
"""User with an empty name should not be created via v2 API"""
tenant = self.setup_test_tenant()
self.assertRaises(lib_exc.BadRequest, self.users_client.create_user,
name='', password=self.alt_password,
@@ -52,7 +53,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('7704b4f3-3b75-4b82-87cc-931d41c8f780')
def test_create_user_with_name_length_over_255(self):
# Length of user name filed should be restricted to 255 characters
"""Length of user name should not exceed 255 via v2 API"""
tenant = self.setup_test_tenant()
self.assertRaises(lib_exc.BadRequest, self.users_client.create_user,
name='a' * 256, password=self.alt_password,
@@ -62,7 +63,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('57ae8558-120c-4723-9308-3751474e7ecf')
def test_create_user_with_duplicate_name(self):
# Duplicate user should not be created
"""Duplicate user should not be created via v2 API"""
password = data_utils.rand_password()
user = self.setup_test_user(password)
tenant = self.tenants_client.show_tenant(user['tenantId'])['tenant']
@@ -75,7 +76,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0132cc22-7c4f-42e1-9e50-ac6aad31d59a')
def test_create_user_for_non_existent_tenant(self):
# Attempt to create a user in a non-existent tenant should fail
"""Creating a user in a non-existent tenant via v2 API should fail"""
self.assertRaises(lib_exc.NotFound, self.users_client.create_user,
name=self.alt_user,
password=self.alt_password,
@@ -85,7 +86,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('55bbb103-d1ae-437b-989b-bcdf8175c1f4')
def test_create_user_request_without_a_token(self):
# Request to create a user without a valid token should fail
"""Creating a user without a valid token via v2 API should fail"""
tenant = self.setup_test_tenant()
# Get the token of the current client
token = self.client.auth_provider.get_token()
@@ -103,7 +104,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('23a2f3da-4a1a-41da-abdd-632328a861ad')
def test_create_user_with_enabled_non_bool(self):
# Attempt to create a user with valid enabled para should fail
"""Creating a user with invalid enabled para via v2 API should fail"""
tenant = self.setup_test_tenant()
name = data_utils.rand_name('test_user')
self.assertRaises(lib_exc.BadRequest, self.users_client.create_user,
@@ -114,7 +115,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('3d07e294-27a0-4144-b780-a2a1bf6fee19')
def test_update_user_for_non_existent_user(self):
# Attempt to update a user non-existent user should fail
"""Updating a non-existent user via v2 API should fail"""
user_name = data_utils.rand_name('user')
non_existent_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound, self.users_client.update_user,
@@ -123,7 +124,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('3cc2a64b-83aa-4b02-88f0-d6ab737c4466')
def test_update_user_request_without_a_token(self):
# Request to update a user without a valid token should fail
"""Updating a user without a valid token via v2 API should fail"""

# Get the token of the current client
token = self.client.auth_provider.get_token()
@@ -139,7 +140,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('424868d5-18a7-43e1-8903-a64f95ee3aac')
def test_update_user_by_unauthorized_user(self):
# Non-administrator should not be authorized to update user
"""Non-admin should not be authorized to update user via v2 API"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_users_client.update_user,
self.alt_user)
@@ -147,7 +148,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('d45195d5-33ed-41b9-a452-7d0d6a00f6e9')
def test_delete_users_by_unauthorized_user(self):
# Non-administrator user should not be authorized to delete a user
"""Non-admin should not be authorized to delete a user via v2 API"""
user = self.setup_test_user()
self.assertRaises(lib_exc.Forbidden,
self.non_admin_users_client.delete_user,
@@ -156,14 +157,14 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('7cc82f7e-9998-4f89-abae-23df36495867')
def test_delete_non_existent_user(self):
# Attempt to delete a non-existent user should fail
"""Attempt to delete a non-existent user via v2 API should fail"""
self.assertRaises(lib_exc.NotFound, self.users_client.delete_user,
'junk12345123')

@decorators.attr(type=['negative'])
@decorators.idempotent_id('57fe1df8-0aa7-46c0-ae9f-c2e785c7504a')
def test_delete_user_request_without_a_token(self):
# Request to delete a user without a valid token should fail
"""Deleting a user without a valid token via v2 API should fail"""

# Get the token of the current client
token = self.client.auth_provider.get_token()
@@ -179,7 +180,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('593a4981-f6d4-460a-99a1-57a78bf20829')
def test_authentication_for_disabled_user(self):
# Disabled user's token should not get authenticated
"""Disabled user's token should not get authenticated via v2 API"""
password = data_utils.rand_password()
user = self.setup_test_user(password)
tenant = self.tenants_client.show_tenant(user['tenantId'])['tenant']
@@ -192,7 +193,11 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('440a7a8d-9328-4b7b-83e0-d717010495e4')
def test_authentication_when_tenant_is_disabled(self):
# User's token for a disabled tenant should not be authenticated
"""Test User's token for a disabled tenant via v2 API

User's token for a disabled tenant should not be authenticated via
v2 API.
"""
password = data_utils.rand_password()
user = self.setup_test_user(password)
tenant = self.tenants_client.show_tenant(user['tenantId'])['tenant']
@@ -205,7 +210,11 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('921f1ad6-7907-40b8-853f-637e7ee52178')
def test_authentication_with_invalid_tenant(self):
# User's token for an invalid tenant should not be authenticated
"""Test User's token for an invalid tenant via v2 API

User's token for an invalid tenant should not be authenticated via V2
API.
"""
password = data_utils.rand_password()
user = self.setup_test_user(password)
self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
@@ -216,7 +225,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('bde9aecd-3b1c-4079-858f-beb5deaa5b5e')
def test_authentication_with_invalid_username(self):
# Non-existent user's token should not get authenticated
"""Non-existent user's token should not get authorized via v2 API"""
password = data_utils.rand_password()
user = self.setup_test_user(password)
tenant = self.tenants_client.show_tenant(user['tenantId'])['tenant']
@@ -226,7 +235,11 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('d5308b33-3574-43c3-8d87-1c090c5e1eca')
def test_authentication_with_invalid_password(self):
# User's token with invalid password should not be authenticated
"""Test User's token with invalid password via v2 API

User's token with invalid password should not be authenticated via V2
API.
"""
user = self.setup_test_user()
tenant = self.tenants_client.show_tenant(user['tenantId'])['tenant']
self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
@@ -235,14 +248,14 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('284192ce-fb7c-4909-a63b-9a502e0ddd11')
def test_get_users_by_unauthorized_user(self):
# Non-administrator user should not be authorized to get user list
"""Non-admin should not be authorized to get user list via v2 API"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_users_client.list_users)

@decorators.attr(type=['negative'])
@decorators.idempotent_id('a73591ec-1903-4ffe-be42-282b39fefc9d')
def test_get_users_request_without_token(self):
# Request to get list of users without a valid token should fail
"""Listing users without a valid token via v2 API should fail"""
token = self.client.auth_provider.get_token()
self.client.delete_token(token)

@@ -254,8 +267,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('f5d39046-fc5f-425c-b29e-bac2632da28e')
def test_list_users_with_invalid_tenant(self):
# Should not be able to return a list of all
# users for a non-existent tenant
"""Listing users for a non-existent tenant via v2 API should fail"""
# Assign invalid tenant ids
invalid_id = list()
invalid_id.append(data_utils.rand_name('999'))


+ 8
- 3
tempest/api/identity/admin/v3/test_domains.py View File

@@ -24,6 +24,7 @@ CONF = config.CONF


class DomainsTestJSON(base.BaseIdentityV3AdminTest):
"""Test identity domains"""

@classmethod
def resource_setup(cls):
@@ -37,7 +38,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('8cf516ef-2114-48f1-907b-d32726c734d4')
def test_list_domains(self):
# Test to list domains
"""Test listing domains"""
fetched_ids = list()
# List and Verify Domains
body = self.domains_client.list_domains()['domains']
@@ -49,7 +50,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('c6aee07b-4981-440c-bb0b-eb598f58ffe9')
def test_list_domains_filter_by_name(self):
# List domains filtering by name
"""Test listing domains filtering by name"""
params = {'name': self.setup_domains[0]['name']}
fetched_domains = self.domains_client.list_domains(
**params)['domains']
@@ -61,7 +62,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('3fd19840-65c1-43f8-b48c-51bdd066dff9')
def test_list_domains_filter_by_enabled(self):
# List domains filtering by enabled domains
"""Test listing domains filtering by enabled domains"""
params = {'enabled': True}
fetched_domains = self.domains_client.list_domains(
**params)['domains']
@@ -74,6 +75,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type='smoke')
@decorators.idempotent_id('f2f5b44a-82e8-4dad-8084-0661ea3b18cf')
def test_create_update_delete_domain(self):
"""Test creating, updating and deleting domain"""
# Create domain
d_name = data_utils.rand_name('domain')
d_desc = data_utils.rand_name('domain-desc')
@@ -118,6 +120,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('d8d318b7-d1b3-4c37-94c5-3c5ba0b121ea')
def test_domain_delete_cascades_content(self):
"""Test deleting domain will delete its associated contents"""
# Create a domain with a user and a group in it
domain = self.setup_test_domain()
user = self.create_test_user(domain_id=domain['id'])
@@ -134,6 +137,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('036df86e-bb5d-42c0-a7c2-66b9db3a6046')
def test_create_domain_with_disabled_status(self):
"""Test creating domain with disabled status"""
# Create domain with enabled status as false
d_name = data_utils.rand_name('domain')
d_desc = data_utils.rand_name('domain-desc')
@@ -146,6 +150,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('2abf8764-309a-4fa9-bc58-201b799817ad')
def test_create_domain_without_description(self):
"""Test creating domain without description"""
# Create domain only with name
d_name = data_utils.rand_name('domain')
domain = self.domains_client.create_domain(name=d_name)['domain']


+ 13
- 3
tempest/api/identity/admin/v3/test_domains_negative.py View File

@@ -20,6 +20,8 @@ from tempest.lib import exceptions as lib_exc


class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest):
"""Negative tests of identity domains"""

# NOTE: force_tenant_isolation is true in the base class by default but
# overridden to false here to allow test execution for clouds using the
# pre-provisioned credentials provider.
@@ -28,6 +30,7 @@ class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative', 'gate'])
@decorators.idempotent_id('1f3fbff5-4e44-400d-9ca1-d953f05f609b')
def test_delete_active_domain(self):
"""Test deleting active domain should fail"""
domain = self.create_domain()
domain_id = domain['id']

@@ -40,14 +43,20 @@ class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9018461d-7d24-408d-b3fe-ae37e8cd5c9e')
def test_create_domain_with_empty_name(self):
# Domain name should not be empty
"""Test creating domain with empty name should fail

Domain name should not be empty
"""
self.assertRaises(lib_exc.BadRequest,
self.domains_client.create_domain, name='')

@decorators.attr(type=['negative'])
@decorators.idempotent_id('37b1bbf2-d664-4785-9a11-333438586eae')
def test_create_domain_with_name_length_over_64(self):
# Domain name length should not ne greater than 64 characters
"""Test creating domain with name over length

Domain name length should not ne greater than 64 characters
"""
d_name = 'a' * 65
self.assertRaises(lib_exc.BadRequest,
self.domains_client.create_domain,
@@ -56,13 +65,14 @@ class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('43781c07-764f-4cf2-a405-953c1916f605')
def test_delete_non_existent_domain(self):
# Attempt to delete a non existent domain should fail
"""Test attempting to delete a non existent domain should fail"""
self.assertRaises(lib_exc.NotFound, self.domains_client.delete_domain,
data_utils.rand_uuid_hex())

@decorators.attr(type=['negative'])
@decorators.idempotent_id('e6f9e4a2-4f36-4be8-bdbc-4e199ae29427')
def test_domain_create_duplicate(self):
"""Test creating domain with duplicate name should fail"""
domain_name = data_utils.rand_name('domain-dup')
domain = self.domains_client.create_domain(name=domain_name)['domain']
domain_id = domain['id']


+ 5
- 0
tempest/api/identity/admin/v3/test_endpoints.py View File

@@ -20,6 +20,8 @@ from tempest.lib import decorators


class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
"""Test keystone endpoints"""

# NOTE: force_tenant_isolation is true in the base class by default but
# overridden to false here to allow test execution for clouds using the
# pre-provisioned credentials provider.
@@ -71,6 +73,7 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('c19ecf90-240e-4e23-9966-21cee3f6a618')
def test_list_endpoints(self):
"""Test listing keystone endpoints by filters"""
# Get the list of all the endpoints.
fetched_endpoints = self.client.list_endpoints()['endpoints']
fetched_endpoint_ids = [e['id'] for e in fetched_endpoints]
@@ -111,6 +114,7 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('0e2446d2-c1fd-461b-a729-b9e73e3e3b37')
def test_create_list_show_delete_endpoint(self):
"""Test creating, listing, showing and deleting keystone endpoint"""
region_name = data_utils.rand_name('region')
url = data_utils.rand_url()
interface = 'public'
@@ -152,6 +156,7 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type='smoke')
@decorators.idempotent_id('37e8f15e-ee7c-4657-a1e7-f6b61e375eff')
def test_update_endpoint(self):
"""Test updating keystone endpoint"""
# NOTE(zhufl) Service2 should be created before endpoint_for_update
# is created, because Service2 must be deleted after
# endpoint_for_update is deleted, otherwise we will get a 404 error


+ 11
- 5
tempest/api/identity/admin/v3/test_list_projects.py View File

@@ -40,6 +40,7 @@ class BaseListProjectsTestJSON(base.BaseIdentityV3AdminTest):


class ListProjectsTestJSON(BaseListProjectsTestJSON):
"""Test listing projects"""

@classmethod
def resource_setup(cls):
@@ -65,13 +66,13 @@ class ListProjectsTestJSON(BaseListProjectsTestJSON):

@decorators.idempotent_id('0fe7a334-675a-4509-b00e-1c4b95d5dae8')
def test_list_projects_with_enabled(self):
# List the projects with enabled
"""Test listing the projects with enabled"""
self._list_projects_with_params(
[self.p1], [self.p2, self.p3], {'enabled': False}, 'enabled')

@decorators.idempotent_id('6edc66f5-2941-4a17-9526-4073311c1fac')
def test_list_projects_with_parent(self):
# List projects with parent
"""Test listing projects with parent"""
params = {'parent_id': self.p3['parent_id']}
fetched_projects = self.projects_client.list_projects(
params)['projects']
@@ -81,6 +82,11 @@ class ListProjectsTestJSON(BaseListProjectsTestJSON):


class ListProjectsStaticTestJSON(BaseListProjectsTestJSON):
"""Test listing projects

These tests can be executed in clouds using the pre-provisioned users
"""

# NOTE: force_tenant_isolation is true in the base class by default but
# overridden to false here to allow test execution for clouds using the
# pre-provisioned credentials provider.
@@ -102,7 +108,7 @@ class ListProjectsStaticTestJSON(BaseListProjectsTestJSON):

@decorators.idempotent_id('1d830662-22ad-427c-8c3e-4ec854b0af44')
def test_list_projects(self):
# List projects
"""Test listing projects"""
list_projects = self.projects_client.list_projects()['projects']

for p in [self.p1, self.p2]:
@@ -112,13 +118,13 @@ class ListProjectsStaticTestJSON(BaseListProjectsTestJSON):

@decorators.idempotent_id('fa178524-4e6d-4925-907c-7ab9f42c7e26')
def test_list_projects_with_name(self):
# List projects with name
"""Test listing projects filtered by name"""
self._list_projects_with_params(
[self.p1], [self.p2], {'name': self.p1['name']}, 'name')

@decorators.idempotent_id('fab13f3c-f6a6-4b9f-829b-d32fd44fdf10')
def test_list_projects_with_domains(self):
# Verify project list filtered by domain
"""Test listing projects filtered by domain"""
key = 'domain_id'
for p in [self.p1, self.p2]:
params = {key: p[key]}


+ 13
- 9
tempest/api/identity/admin/v3/test_projects.py View File

@@ -23,6 +23,8 @@ CONF = config.CONF


class ProjectsTestJSON(base.BaseIdentityV3AdminTest):
"""Test identity projects"""

# NOTE: force_tenant_isolation is true in the base class by default but
# overridden to false here to allow test execution for clouds using the
# pre-provisioned credentials provider.
@@ -30,7 +32,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('0ecf465c-0dc4-4532-ab53-91ffeb74d12d')
def test_project_create_with_description(self):
# Create project with a description
"""Test creating project with a description"""
project_desc = data_utils.rand_name('desc')
project = self.setup_test_project(description=project_desc)
project_id = project['id']
@@ -44,7 +46,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('5f50fe07-8166-430b-a882-3b2ee0abe26f')
def test_project_create_with_domain(self):
# Create project with a domain
"""Test creating project with a domain"""
domain = self.setup_test_domain()
project_name = data_utils.rand_name('project')
project = self.setup_test_project(
@@ -58,7 +60,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('1854f9c0-70bc-4d11-a08a-1c789d339e3d')
def test_project_create_with_parent(self):
# Create root project without providing a parent_id
"""Test creating root project without providing a parent_id"""
domain = self.setup_test_domain()
domain_id = domain['id']

@@ -83,6 +85,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('a7eb9416-6f9b-4dbb-b71b-7f73aaef59d5')
def test_create_is_domain_project(self):
"""Test creating is_domain project"""
project = self.setup_test_project(domain_id=None, is_domain=True)
# To delete a domain, we need to disable it first
self.addCleanup(self.projects_client.update_project, project['id'],
@@ -103,7 +106,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('1f66dc76-50cc-4741-a200-af984509e480')
def test_project_create_enabled(self):
# Create a project that is enabled
"""Test creating a project that is enabled"""
project = self.setup_test_project(enabled=True)
project_id = project['id']
self.assertTrue(project['enabled'],
@@ -113,7 +116,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('78f96a9c-e0e0-4ee6-a3ba-fbf6dfd03207')
def test_project_create_not_enabled(self):
# Create a project that is not enabled
"""Test creating a project that is not enabled"""
project = self.setup_test_project(enabled=False)
self.assertFalse(project['enabled'],
'Enable should be False in response')
@@ -123,7 +126,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('f608f368-048c-496b-ad63-d286c26dab6b')
def test_project_update_name(self):
# Update name attribute of a project
"""Test updating name attribute of a project"""
p_name1 = data_utils.rand_name('project')
project = self.setup_test_project(name=p_name1)

@@ -144,7 +147,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('f138b715-255e-4a7d-871d-351e1ef2e153')
def test_project_update_desc(self):
# Update description attribute of a project
"""Test updating description attribute of a project"""
p_desc = data_utils.rand_name('desc')
project = self.setup_test_project(description=p_desc)
resp1_desc = project['description']
@@ -164,7 +167,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('b6b25683-c97f-474d-a595-55d410b68100')
def test_project_update_enable(self):
# Update the enabled attribute of a project
"""Test updating the enabled attribute of a project"""
p_en = False
project = self.setup_test_project(enabled=p_en)

@@ -189,7 +192,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):
'immutable user source and solely '
'provides read-only access to users.')
def test_associate_user_to_project(self):
# Associate a user to a project
"""Test associating a user to a project"""
# Create a Project
project = self.setup_test_project()

@@ -215,6 +218,7 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest):

@decorators.idempotent_id('d1db68b6-aebe-4fa0-b79d-d724d2e21162')
def test_project_get_equals_list(self):
"""Test the result of getting project equals that of listing"""
fields = ['parent_id', 'is_domain', 'description', 'links',
'name', 'enabled', 'domain_id', 'id', 'tags']



+ 13
- 7
tempest/api/identity/admin/v3/test_projects_negative.py View File

@@ -20,11 +20,12 @@ from tempest.lib import exceptions as lib_exc


class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest):
"""Negative tests of projects"""

@decorators.attr(type=['negative'])
@decorators.idempotent_id('8d68c012-89e0-4394-8d6b-ccd7196def97')
def test_project_delete_by_unauthorized_user(self):
# Non-admin user should not be able to delete a project
"""Non-admin user should not be able to delete a project"""
project = self.setup_test_project()
self.assertRaises(
lib_exc.Forbidden, self.non_admin_projects_client.delete_project,
@@ -32,6 +33,11 @@ class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest):


class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest):
"""Negative tests of projects

These tests can be executed in clouds using the pre-provisioned users
"""

# NOTE: force_tenant_isolation is true in the base class by default but
# overridden to false here to allow test execution for clouds using the
# pre-provisioned credentials provider.
@@ -40,14 +46,14 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('24c49279-45dd-4155-887a-cb738c2385aa')
def test_list_projects_by_unauthorized_user(self):
# Non-admin user should not be able to list projects
"""Non-admin user should not be able to list projects"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_projects_client.list_projects)

@decorators.attr(type=['negative'])
@decorators.idempotent_id('874c3e84-d174-4348-a16b-8c01f599561b')
def test_project_create_duplicate(self):
# Project names should be unique
"""Project names should be unique"""
project_name = data_utils.rand_name('project-dup')
self.setup_test_project(name=project_name)

@@ -57,7 +63,7 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('8fba9de2-3e1f-4e77-812a-60cb68f8df13')
def test_create_project_by_unauthorized_user(self):
# Non-admin user should not be authorized to create a project
"""Non-admin user should not be authorized to create a project"""
project_name = data_utils.rand_name('project')
self.assertRaises(
lib_exc.Forbidden, self.non_admin_projects_client.create_project,
@@ -66,14 +72,14 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('7828db17-95e5-475b-9432-9a51b4aa79a9')
def test_create_project_with_empty_name(self):
# Project name should not be empty
"""Project name should not be empty"""
self.assertRaises(lib_exc.BadRequest,
self.projects_client.create_project, name='')

@decorators.attr(type=['negative'])
@decorators.idempotent_id('502b6ceb-b0c8-4422-bf53-f08fdb21e2f0')
def test_create_projects_name_length_over_64(self):
# Project name length should not be greater than 64 characters
"""Project name length should not be greater than 64 characters"""
project_name = 'a' * 65
self.assertRaises(lib_exc.BadRequest,
self.projects_client.create_project, project_name)
@@ -81,7 +87,7 @@ class ProjectsNegativeStaticTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative'])
@decorators.idempotent_id('7965b581-60c1-43b7-8169-95d4ab7fc6fb')
def test_delete_non_existent_project(self):
# Attempt to delete a non existent project should fail
"""Attempt to delete a non existent project should fail"""
self.assertRaises(lib_exc.NotFound,
self.projects_client.delete_project,
data_utils.rand_uuid_hex())

Loading…
Cancel
Save