Ansuman Bebarta 47db4235c3 Make change to support rbac testing
- Change client manager to create different clients for
  hitting ranger apis from rbac tests
- Change base client to use appropriate credential which
  role has been changed by patrole
- Add basic rbac test for customer

Change-Id: I9338bf3a31e3ca6e2b2e30859084d1561a70633c
2019-12-17 19:07:56 +05:30

69 lines
2.6 KiB
Python

# Copyright (c) 2019 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-ancestors
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin import rbac_utils
from ranger_tempest_plugin.tests.api import test_customers
from tempest import config
from tempest.lib import decorators
CONF = config.CONF
class TestCustomer(rbac_utils.RbacUtilsMixin, test_customers.TestTempestCms):
@classmethod
def setup_clients(cls):
super(TestCustomer, cls).setup_clients()
cls.client = cls.os_primary.cms_rbac_client
@rbac_rule_validation.action(service="ranger",
rules=['customers:get_one'],
expected_error_codes=[403])
@decorators.idempotent_id('c28cca7b-99ab-4d8d-bef9-f1fe1a1e86cc')
def test_get_customer(self):
with self.override_role():
self.client.get_customer(self.setup_customer_id)
@rbac_rule_validation.action(service="ranger",
rules=['customers:get_all'],
expected_error_codes=[403])
@decorators.idempotent_id('5f1e6d5b-f7b8-4e19-a30e-95afa3902827')
def test_list_customer(self):
with self.override_role():
# List customers without any filters
self.client.list_customers(None)
@rbac_rule_validation.action(service='ranger',
rules=['customers:create'],
expected_error_codes=[403])
@decorators.idempotent_id('021ada0a-3638-4075-8220-76ff4cbfc9ce')
def test_create_customer(self):
post_body = self._get_customer_params(
quota=False,
region_users=False,
default_users=False
)
with self.override_role():
_, body = self.client.create_customer(**post_body)
test_customer_id = body['customer']['id']
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
self._wait_for_status(test_customer_id, 'Success')