From a261a2f446c5dea91466a866796f39234ad206a0 Mon Sep 17 00:00:00 2001 From: Mykola Yakovliev Date: Wed, 5 Sep 2018 14:27:22 -0500 Subject: [PATCH] Add tests to cover network ip availability API This patch set adds tests to cover the neutron network_ip_availability API [0]. Part of "Increase Neutron RBAC Coverage" initiative [1] [0] https://developer.openstack.org/api-ref/network/v2/index.html#network-ip-availability-and-usage-stats [1] https://storyboard.openstack.org/#!/story/2002641 Change-Id: Idddf5a8bf5214b1fbc079fcf2f5b1a4c2a889a57 Story: 2002641 Task: 22304 --- .../test_network_ip_availability_rbac.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 patrole_tempest_plugin/tests/api/network/test_network_ip_availability_rbac.py diff --git a/patrole_tempest_plugin/tests/api/network/test_network_ip_availability_rbac.py b/patrole_tempest_plugin/tests/api/network/test_network_ip_availability_rbac.py new file mode 100644 index 00000000..b5346d5c --- /dev/null +++ b/patrole_tempest_plugin/tests/api/network/test_network_ip_availability_rbac.py @@ -0,0 +1,63 @@ +# Copyright 2018 AT&T Corporation. +# 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 tempest.common import utils +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators + +from patrole_tempest_plugin import rbac_rule_validation +from patrole_tempest_plugin.tests.api.network import rbac_base as base + + +class NetworkIpAvailabilityExtRbacTest(base.BaseNetworkExtRbacTest): + @classmethod + def skip_checks(cls): + super(NetworkIpAvailabilityExtRbacTest, cls).skip_checks() + if not utils.is_extension_enabled('network-ip-availability', + 'network'): + msg = "network-ip-availability extension not enabled." + raise cls.skipException(msg) + + @rbac_rule_validation.action(service="neutron", + rules=["get_network_ip_availability"], + expected_error_codes=[404]) + @decorators.idempotent_id('93edc5ed-385f-4a8e-9b15-4370ec608253') + def test_get_network_ip_availability(self): + """Get network availability + + RBAC test for the neutron get_network_ip_availability policy + """ + + network_name = data_utils.rand_name( + self.__class__.__name__ + '-Network') + network = self.create_network(network_name=network_name) + + with self.rbac_utils.override_role(self): + self.ntp_client.show_network_ip_availability(network['id']) + + @rbac_rule_validation.action(service="neutron", + rules=["get_network_ip_availabilities"]) + @decorators.idempotent_id('d4ceb5f0-2342-4412-a617-4e1aaf7fcaf0') + def test_get_network_ip_availabilities(self): + """List network ip availabilities + + RBAC test for the neutron get_network_ip_availabilities policy + """ + admin_resources = (self.ntp_client.list_network_ip_availabilities() + ["network_ip_availabilities"]) + with self.rbac_utils.override_role_and_validate_list( + self, admin_resources=admin_resources) as ctx: + ctx.resources = (self.ntp_client.list_network_ip_availabilities() + ["network_ip_availabilities"])