diff --git a/tungsten_tempest_plugin/tests/api/contrail/test_bgpvpn.py b/tungsten_tempest_plugin/tests/api/contrail/test_bgpvpn.py new file mode 100644 index 0000000..2034b27 --- /dev/null +++ b/tungsten_tempest_plugin/tests/api/contrail/test_bgpvpn.py @@ -0,0 +1,101 @@ +"""Tempest Suite for Contrail BGP_VPN.""" +# Copyright 2018 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. + +from patrole_tempest_plugin import rbac_rule_validation +from tempest import config +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators + +from tungsten_tempest_plugin.tests.api.contrail import rbac_base + +CONF = config.CONF + + +class BgpvpnTest(rbac_base.BaseContrailTest): + """Test suite for validating RBAC functionality of 'bgpvpn' API.""" + + @classmethod + def skip_checks(cls): + super(BgpvpnTest, cls).skip_checks() + if float(CONF.sdn.contrail_version) < 4: + msg = "bgpvpn requires Contrail >= 4" + raise cls.skipException(msg) + + @classmethod + def resource_setup(cls): + """Create Bgpvpn to use across the Suite.""" + super(BgpvpnTest, cls).resource_setup() + cls.bgpvpn_uuid = cls._create_bgpvpn() + + @classmethod + def _create_bgpvpn(cls): + """Create Bgpvpn.""" + bgpvpn_name = data_utils.rand_name('test-bgpvpn') + bgpvpn_fq_name = ['default-domain', cls.tenant_name, bgpvpn_name] + resp_body = cls.contrail_client.create_bgpvpn( + parent_type='project', + fq_name=bgpvpn_fq_name) + bgpvpn_uuid = resp_body['bgpvpn']['uuid'] + cls.addClassResourceCleanup( + cls._try_delete_resource, + cls.contrail_client.delete_bgpvpn, + bgpvpn_uuid) + return bgpvpn_uuid + + @rbac_rule_validation.action(service="Contrail", + rules=["list_bgpvpns"]) + @decorators.idempotent_id('65afb5d5-52cb-484c-9e8e-42509be7dd77') + def test_list_bgpvpns(self): + """Test whether current role can list of bgpvpns.""" + with self.rbac_utils.override_role(self): + self.contrail_client.list_bgpvpns() + + @rbac_rule_validation.action(service="Contrail", + rules=["create_bgpvpns"]) + @decorators.idempotent_id('c3a7510c-c8d6-4736-9962-5c1aa032bf79') + def test_create_bgpvpns(self): + """Test whether current role can create bgpvpn.""" + with self.rbac_utils.override_role(self): + self._create_bgpvpn() + + @rbac_rule_validation.action(service="Contrail", + rules=["show_bgpvpn"]) + @decorators.idempotent_id('2fd05ca2-97d8-477c-aead-a881a2ba5e7e') + def test_show_bgpvpn(self): + """Test whether current role can get bgpvpn details.""" + with self.rbac_utils.override_role(self): + self.contrail_client.show_bgpvpn( + self.bgpvpn_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["delete_bgpvpn"]) + @decorators.idempotent_id('919aa2bb-1556-4dcf-bbef-0a31f9c6464b') + def test_delete_bgpvpn(self): + """Test whether current role can delete bgpvpn details.""" + new_bgpvpn_uuid = self._create_bgpvpn() + with self.rbac_utils.override_role(self): + self.contrail_client.delete_bgpvpn( + new_bgpvpn_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["update_bgpvpn"]) + @decorators.idempotent_id('ae734791-eaeb-4ca9-908a-59d0eac1a3c0') + def test_update_bgpvpn(self): + """Test whether current role can update bgpvpn.""" + with self.rbac_utils.override_role(self): + self.contrail_client.update_bgpvpn( + self.bgpvpn_uuid, + display_name=data_utils.rand_name('test-bgpvpn')) diff --git a/tungsten_tempest_plugin/tests/api/contrail/test_policy_management.py b/tungsten_tempest_plugin/tests/api/contrail/test_policy_management.py new file mode 100644 index 0000000..b8faad9 --- /dev/null +++ b/tungsten_tempest_plugin/tests/api/contrail/test_policy_management.py @@ -0,0 +1,121 @@ +"""Tempest Suite for Policy Management of Contrail.""" +# Copyright 2018 AT&T Corp +# All 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. + +from patrole_tempest_plugin import rbac_rule_validation +from tempest import config +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators + +from tungsten_tempest_plugin.tests.api.contrail import rbac_base + +CONF = config.CONF + + +class PolicyManagementTest(rbac_base.BaseContrailTest): + """Class to test the Policy Management of Contrail.""" + + @classmethod + def skip_checks(cls): + """Skip the Suite if the Contrail version is less than five.""" + super(PolicyManagementTest, cls).skip_checks() + if float(CONF.sdn.contrail_version) < 5: + msg = "policy_management requires Contrail >= 5" + raise cls.skipException(msg) + + @classmethod + def resource_setup(cls): + """Create Policy Management to use across the Suite.""" + super(PolicyManagementTest, cls).resource_setup() + cls.policy_management_uuid = cls._create_policy_management() + + @classmethod + def _create_policy_management(cls): + """Create a Policy Management.""" + fq_name = data_utils.rand_name('policy-management') + post_body = { + 'parent_type': 'project', + 'fq_name': ["default-domain", cls.tenant_name, fq_name] + } + resp_body = cls.contrail_client.create_policy_management( + **post_body) + policy_management_uuid = resp_body['policy-management']['uuid'] + cls.addClassResourceCleanup( + cls._try_delete_resource, + cls.contrail_client.delete_policy_management, + policy_management_uuid) + return policy_management_uuid + + @rbac_rule_validation.action(service="Contrail", + rules=["create_policy_management"]) + @decorators.idempotent_id('8fc56caa-fe8c-487f-8da6-579ae56dc831') + def test_create_policy_management(self): + """Create policy_management. + + RBAC test for the Contrail create_policy_management policy + """ + with self.rbac_utils.override_role(self): + self._create_policy_management() + + @rbac_rule_validation.action(service="Contrail", + rules=["list_policy_management"]) + @decorators.idempotent_id('5bfb007b-70d3-48f2-91ce-dc2ff471fe34') + def test_list_policy_managements(self): + """List policy_managements. + + RBAC test for the Contrail list_policy_managements policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.list_policy_managements() + + @rbac_rule_validation.action(service="Contrail", + rules=["show_policy_management"]) + @decorators.idempotent_id('a62737ec-dae9-4c26-8474-c4352c578607') + def test_show_policy_management(self): + """Show policy_management. + + RBAC test for the Contrail show_policy_management policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.\ + show_policy_management(self.policy_management_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["delete_policy_management"]) + @decorators.idempotent_id('1a3515ce-ce89-42e0-a4aa-a6c80eed4a7e') + def test_delete_policy_management(self): + """Delete policy_management. + + RBAC test for the Contrail delete_policy_management policy + """ + obj_uuid = self._create_policy_management() + with self.rbac_utils.override_role(self): + self.contrail_client.\ + delete_policy_management(obj_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["update_policy_management"]) + @decorators.idempotent_id('833de029-cd09-4929-a40e-ddf521381474') + def test_update_policy_management(self): + """Update policy_management. + + RBAC test for the Contrail update_policy_management policy + """ + put_body = { + 'display_name': data_utils.rand_name( + 'update_policy_management')} + with self.rbac_utils.override_role(self): + self.contrail_client.update_policy_management( + self.policy_management_uuid, **put_body) diff --git a/tungsten_tempest_plugin/tests/api/contrail/test_service_object.py b/tungsten_tempest_plugin/tests/api/contrail/test_service_object.py new file mode 100644 index 0000000..23412fb --- /dev/null +++ b/tungsten_tempest_plugin/tests/api/contrail/test_service_object.py @@ -0,0 +1,116 @@ +"""Tempest Suite for Contrail Service Objects.""" +# Copyright 2018 AT&T Corp +# All 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. + +from patrole_tempest_plugin import rbac_rule_validation +from tempest import config +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators + +from tungsten_tempest_plugin.tests.api.contrail import rbac_base + +CONF = config.CONF + + +class ServiceObjectContrailTest(rbac_base.BaseContrailTest): + """Class to test the Service objects of Contrail.""" + + @classmethod + def skip_checks(cls): + """Skip the suite if the Contrail version is less than 4.1.""" + super(ServiceObjectContrailTest, cls).skip_checks() + if float(CONF.sdn.contrail_version) < 4.1: + msg = "service_object requires Contrail >= 4.1" + raise cls.skipException(msg) + + @classmethod + def resource_setup(cls): + """Create Service object to use it across the suite.""" + super(ServiceObjectContrailTest, cls).resource_setup() + cls.service_object_uuid = cls._create_service_object() + + @classmethod + def _create_service_object(cls): + """Create service object.""" + display_name = data_utils.rand_name('service_object') + post_body = {'display_name': display_name} + post_body['fq_name'] = [display_name] + resp_body = cls.contrail_client.create_service_object(**post_body) + service_object_uuid = resp_body['service-object']['uuid'] + cls.addClassResourceCleanup( + cls._try_delete_resource, + cls.contrail_client.delete_service_object, + service_object_uuid) + return service_object_uuid + + @rbac_rule_validation.action(service="Contrail", + rules=["list_service_objects"]) + @decorators.idempotent_id('05458fa1-ba09-4772-91aa-ca06243b5f5e') + def test_list_service_objects(self): + """List service_objects. + + RBAC test for the Contrail list_service_objects policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.list_service_objects() + + @rbac_rule_validation.action(service="Contrail", + rules=["create_service_object"]) + @decorators.idempotent_id('8be0e381-3abb-4256-858d-5930db4ceafb') + def test_create_service_object(self): + """Create service_object. + + RBAC test for the Contrail create_service_object policy + """ + with self.rbac_utils.override_role(self): + self._create_service_object() + + @rbac_rule_validation.action(service="Contrail", + rules=["show_service_object"]) + @decorators.idempotent_id('bb570ddd-c5fa-4691-899e-00a64568f736') + def test_show_service_object(self): + """Show service_object. + + RBAC test for the Contrail show_service_object policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.show_service_object(self.service_object_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["delete_service_object"]) + @decorators.idempotent_id('15a4d6dc-f16b-11e8-8e54-080027758b73') + def test_delete_service_object(self): + """Delete service_object. + + RBAC test for the Contrail delete_service_object policy + """ + obj_uuid = self._create_service_object() + with self.rbac_utils.override_role(self): + self.contrail_client.delete_service_object(obj_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["update_service_object"]) + @decorators.idempotent_id('a6eaee65-9ead-4df5-9aa0-5329ee9a26f2') + def test_update_service_object(self): + """Update service_object. + + RBAC test for the Contrail update_service_object policy + """ + put_body = { + 'display_name': data_utils.rand_name( + 'update_service_object')} + with self.rbac_utils.override_role(self): + self.contrail_client.update_service_object( + self.service_object_uuid, **put_body) diff --git a/tungsten_tempest_plugin/tests/api/contrail/test_tag_type.py b/tungsten_tempest_plugin/tests/api/contrail/test_tag_type.py new file mode 100644 index 0000000..9755ce2 --- /dev/null +++ b/tungsten_tempest_plugin/tests/api/contrail/test_tag_type.py @@ -0,0 +1,115 @@ +"""Tempest Suite for Tag Type of Contrail.""" +# Copyright 2018 AT&T Corp +# All 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. + +from patrole_tempest_plugin import rbac_rule_validation +from tempest import config +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators + +from tungsten_tempest_plugin.tests.api.contrail import rbac_base + +CONF = config.CONF + + +class ContrailTagTypeTest(rbac_base.BaseContrailTest): + """Test suite for validating RBAC functionality of 'tag-type' API.""" + + @classmethod + def skip_checks(cls): + """Skip the checks if contrail Version is less than 4.1.""" + super(ContrailTagTypeTest, cls).skip_checks() + if float(CONF.sdn.contrail_version) < 4.1: + msg = "tag-type requires Contrail >= 4.1" + raise cls.skipException(msg) + + @classmethod + def resource_setup(cls): + """Create Tag type to use it across the Suite.""" + super(ContrailTagTypeTest, cls).resource_setup() + cls.tag_type_uuid = cls._create_tag_type() + + @classmethod + def _create_tag_type(cls): + """Create Tag type.""" + tag_type_name = data_utils.rand_name('tag-type') + fq_name = [tag_type_name] + post_data = {'fq_name': fq_name} + new_tag_type = cls.contrail_client.create_tag_type( + **post_data)['tag-type'] + tag_type_uuid = new_tag_type['uuid'] + cls.addClassResourceCleanup( + cls._try_delete_resource, + cls.contrail_client.delete_tag_type, + tag_type_uuid) + return tag_type_uuid + + @rbac_rule_validation.action(service="Contrail", + rules=["list_tag_types"]) + @decorators.idempotent_id('53c34f3a-f426-11e8-8eb2-f2801f1b9fd1') + def test_list_tag_types(self): + """List tag-type. + + RBAC test for contrail list tag_type policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.list_tag_types() + + @rbac_rule_validation.action(service="Contrail", + rules=["show_tag_type"]) + @decorators.idempotent_id('64cf8892-f427-11e8-8eb2-f2801f1b9fd1') + def test_show_tag_type(self): + """Show tag-type. + + RBAC test for contrail show tag_type policy + """ + with self.rbac_utils.override_role(self): + self.contrail_client.show_tag_type(self.tag_type_uuid) + + @rbac_rule_validation.action(service="Contrail", + rules=["create_tag_types"]) + @decorators.idempotent_id('7e602032-f427-11e8-8eb2-f2801f1b9fd1') + def test_create_tag_types(self): + """Create tag-type. + + RBAC test for contrail create tag_type policy + """ + with self.rbac_utils.override_role(self): + self._create_tag_type() + + @rbac_rule_validation.action(service="Contrail", + rules=["update_tag_type"]) + @decorators.idempotent_id('98f6beba-f427-11e8-8eb2-f2801f1b9fd1') + def test_update_tag_type(self): + """Update tag-type. + + RBAC test for contrail update tag_type policy + """ + update_name = data_utils.rand_name('new_name') + with self.rbac_utils.override_role(self): + self.contrail_client.update_tag_type( + self.tag_type_uuid, name=update_name) + + @rbac_rule_validation.action(service="Contrail", + rules=["delete_tag_type"]) + @decorators.idempotent_id('b0f81fae-f427-11e8-8eb2-f2801f1b9fd1') + def test_delete_tag_type(self): + """Delete tag-type. + + RBAC test for contrail delete tag_type policy + """ + new_tag_type_uuid = self._create_tag_type() + with self.rbac_utils.override_role(self): + self.contrail_client.delete_tag_type(new_tag_type_uuid)