Merge "Extend test cases for customer service"
This commit is contained in:
commit
f79ac16d20
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
import uuid
|
||||||
|
|
||||||
from ranger_tempest_plugin.data_utils import data_utils
|
from ranger_tempest_plugin.data_utils import data_utils
|
||||||
from ranger_tempest_plugin.tests.api import cms_base
|
from ranger_tempest_plugin.tests.api import cms_base
|
||||||
@ -68,6 +69,14 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
|||||||
region_name)
|
region_name)
|
||||||
return region
|
return region
|
||||||
|
|
||||||
|
def _create_customer(self, post_body):
|
||||||
|
customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
|
||||||
|
**post_body)
|
||||||
|
self.addCleanup(
|
||||||
|
self._del_cust_validate_deletion_on_dcp_and_lcp,
|
||||||
|
customer_id)
|
||||||
|
return customer_id
|
||||||
|
|
||||||
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89')
|
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89')
|
||||||
def test_get_customer(self):
|
def test_get_customer(self):
|
||||||
"""Execute 'get_customer' using the following options
|
"""Execute 'get_customer' using the following options
|
||||||
@ -88,6 +97,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
|||||||
|
|
||||||
- no filter (i.e. list all customers)
|
- no filter (i.e. list all customers)
|
||||||
- filter by metadata key
|
- filter by metadata key
|
||||||
|
- filter by metadata key value pair
|
||||||
- filter by region
|
- filter by region
|
||||||
- filter by default user id
|
- filter by default user id
|
||||||
- customer name contains a substring
|
- customer name contains a substring
|
||||||
@ -103,18 +113,23 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
|||||||
|
|
||||||
# get the first key from metadata as the metadata key filter
|
# get the first key from metadata as the metadata key filter
|
||||||
metadata_key = list(self.setup_customer['metadata'].keys())[0]
|
metadata_key = list(self.setup_customer['metadata'].keys())[0]
|
||||||
|
metadata_value = self.setup_customer['metadata'][metadata_key]
|
||||||
|
|
||||||
# define the list customer filters to be used for this test
|
# define the list customer filters to be used for this test
|
||||||
no_filter = None
|
no_filter = None
|
||||||
metadata_filter = {'metadata': metadata_key}
|
metadata_filter = {'metadata': metadata_key}
|
||||||
|
metadata_kv_filter = {
|
||||||
|
'metadata': '%s:%s' % (metadata_key, metadata_value)
|
||||||
|
}
|
||||||
region_filter = {'region': region_name[0]}
|
region_filter = {'region': region_name[0]}
|
||||||
user_filter = {'user': userid[0]}
|
user_filter = {'user': userid[0]}
|
||||||
contains_filter = {'contains': cust_name[substr_name:]}
|
contains_filter = {'contains': cust_name[substr_name:]}
|
||||||
startswith_filter = {'starts_with': cust_name[:substr_name]}
|
startswith_filter = {'starts_with': cust_name[:substr_name]}
|
||||||
|
|
||||||
# execute list_customers with the available filters
|
# execute list_customers with the available filters
|
||||||
for list_filter in [no_filter, metadata_filter, region_filter,
|
for list_filter in [no_filter, metadata_filter, metadata_kv_filter,
|
||||||
user_filter, contains_filter, startswith_filter]:
|
region_filter, user_filter,
|
||||||
|
contains_filter, startswith_filter]:
|
||||||
_, body = self.client.list_customers(list_filter)
|
_, body = self.client.list_customers(list_filter)
|
||||||
customers = [cust['id'] for cust in body['customers']]
|
customers = [cust['id'] for cust in body['customers']]
|
||||||
self.assertIn(self.setup_customer_id, customers)
|
self.assertIn(self.setup_customer_id, customers)
|
||||||
@ -354,12 +369,14 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
|||||||
def test_replace_customer(self):
|
def test_replace_customer(self):
|
||||||
customer = self._get_bare_customer_params()
|
customer = self._get_bare_customer_params()
|
||||||
customer['name'] = self.setup_customer['name']
|
customer['name'] = self.setup_customer['name']
|
||||||
|
customer['description'] = 'test customer'
|
||||||
customer['regions'] = [{'name': CONF.identity.region}]
|
customer['regions'] = [{'name': CONF.identity.region}]
|
||||||
_, body = self.client.update_customer(self.setup_customer_id,
|
_, body = self.client.update_customer(self.setup_customer_id,
|
||||||
customer)
|
customer)
|
||||||
self._wait_for_status(self.setup_customer_id, 'Success')
|
self._wait_for_status(self.setup_customer_id, 'Success')
|
||||||
_, body = self.client.get_customer(self.setup_customer_id)
|
_, body = self.client.get_customer(self.setup_customer_id)
|
||||||
self.assert_expected(customer, body, ['name', 'regions'])
|
self.assert_expected(customer, body,
|
||||||
|
['name', 'description', 'regions'])
|
||||||
for region in customer['regions']:
|
for region in customer['regions']:
|
||||||
self.assertIn(region['name'], [x['name'] for x in body['regions']])
|
self.assertIn(region['name'], [x['name'] for x in body['regions']])
|
||||||
|
|
||||||
@ -425,3 +442,40 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
|||||||
# Notification to ORD failed
|
# Notification to ORD failed
|
||||||
self.assertEqual(body['status'], 'Error')
|
self.assertEqual(body['status'], 'Error')
|
||||||
self.assertEqual(body['custId'], test_customer_id)
|
self.assertEqual(body['custId'], test_customer_id)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('49e08cd0-4d33-4ec4-95a0-500974b3a9bf')
|
||||||
|
def test_list_customer_additional_fields(self):
|
||||||
|
_, customer = self.client.get_customer(self.setup_customer_id)
|
||||||
|
self.assertIn('status', customer)
|
||||||
|
self.assertIn('regions', customer)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('edf3a30a-fca8-49d0-acc6-c3190c6feb43')
|
||||||
|
def test_disable_customer(self):
|
||||||
|
self.client.enable_customer(self.setup_customer_id, False)
|
||||||
|
self._wait_for_status(self.setup_customer_id, 'Success')
|
||||||
|
_, body = self.client.get_customer(self.setup_customer_id)
|
||||||
|
self.assertFalse(body['enabled'])
|
||||||
|
|
||||||
|
@decorators.idempotent_id('7787b712-c398-47b6-8bf6-345be85e6daa')
|
||||||
|
def test_create_customer_with_uuid(self):
|
||||||
|
post_body = self._get_customer_params(quota=False)
|
||||||
|
uuid_ = uuid.uuid4().hex
|
||||||
|
post_body['uuid'] = uuid_
|
||||||
|
test_customer_id = self._create_customer(post_body)
|
||||||
|
_, customer = self.client.get_customer(test_customer_id)
|
||||||
|
self.assertEqual(customer['uuid'], uuid_)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('8bd31cee-825a-4542-aa1d-bf2d79dbac62')
|
||||||
|
def test_replace_customer_quota(self):
|
||||||
|
customer = self._get_bare_customer_params()
|
||||||
|
customer['name'] = self.setup_customer['name']
|
||||||
|
customer['regions'] = [{'name': CONF.identity.region}]
|
||||||
|
quota = self.setup_customer['defaultQuotas'][0]
|
||||||
|
quota['compute'][0]['ram'] = '20'
|
||||||
|
customer['defaultQuotas'] = [quota]
|
||||||
|
_, body = self.client.update_customer(self.setup_customer_id,
|
||||||
|
customer)
|
||||||
|
self._wait_for_status(self.setup_customer_id, 'Success')
|
||||||
|
_, body = self.client.get_customer(self.setup_customer_id)
|
||||||
|
self.assertEqual(len(body['defaultQuotas']), 1)
|
||||||
|
self.assertDictEqual(quota, body['defaultQuotas'][0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user