From 31d6e2d4dce0095718a269cfc659d636bec191ad Mon Sep 17 00:00:00 2001 From: David Lyle Date: Thu, 14 Jul 2016 18:08:17 +0000 Subject: [PATCH] Revert "Prevent creation of subnet via RBAC during new network creation" The policy rule to create subnets requires a target to make the policy check. This implementation does not provide a target, so is not a proper place to use the workflow policy checks. To do this, a more involved approach needs to be used that supplies a target. However, this will be challenging because the target is the network_id that has yet to be created. This reverts commit 3befade1411783af088b0e72b08f8ff3701b02c8. Change-Id: I6af1cbd559034bd5635dfb4360b525714225677d --- .../dashboards/project/networks/workflows.py | 4 +--- .../integration_tests/pages/project/network/networkspage.py | 6 ++++-- .../test/integration_tests/tests/test_networks.py | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index bb1f428727..07af80a4c5 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -200,7 +200,6 @@ class CreateSubnetInfoAction(workflows.Action): class Meta(object): name = _("Subnet") - policy_rules = (('network', 'create_subnet'),) help_text = _('Creates a subnet associated with the network.' ' You need to enter a valid "Network Address"' ' and "Gateway IP". If you did not enter the' @@ -363,7 +362,6 @@ class CreateSubnetDetailAction(workflows.Action): class Meta(object): name = _("Subnet Details") - policy_rules = (('network', 'create_subnet'),) help_text = _('Specify additional attributes for the subnet.') def __init__(self, request, context, *args, **kwargs): @@ -588,7 +586,7 @@ class CreateNetwork(workflows.Workflow): if not network: return False # If we do not need to create a subnet, return here. - if not data.get('with_subnet'): + if not data['with_subnet']: return True subnet = self._create_subnet(request, data, network, no_redirect=True) if subnet: diff --git a/openstack_dashboard/test/integration_tests/pages/project/network/networkspage.py b/openstack_dashboard/test/integration_tests/pages/project/network/networkspage.py index 1f3316202a..0471bd4ea3 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/network/networkspage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/network/networkspage.py @@ -38,6 +38,7 @@ class NetworksTable(tables.TableRegion): class NetworksPage(basepage.BaseNavigationPage): DEFAULT_ADMIN_STATE = 'True' + DEFAULT_CREATE_SUBNET = True DEFAULT_IP_VERSION = '4' DEFAULT_DISABLE_GATEWAY = False DEFAULT_ENABLE_DHCP = True @@ -58,8 +59,9 @@ class NetworksPage(basepage.BaseNavigationPage): def networks_table(self): return NetworksTable(self.driver, self.conf) - def create_network(self, network_name, subnet_name=None, + def create_network(self, network_name, subnet_name, admin_state=DEFAULT_ADMIN_STATE, + create_subnet=DEFAULT_CREATE_SUBNET, network_address=None, ip_version=DEFAULT_IP_VERSION, gateway_ip=None, disable_gateway=DEFAULT_DISABLE_GATEWAY, @@ -68,7 +70,7 @@ class NetworksPage(basepage.BaseNavigationPage): create_network_form = self.networks_table.create_network() create_network_form.net_name.text = network_name create_network_form.admin_state.value = admin_state - if subnet_name is None: + if not create_subnet: create_network_form.with_subnet.unmark() else: create_network_form.switch_to(self.SUBNET_TAB_INDEX) diff --git a/openstack_dashboard/test/integration_tests/tests/test_networks.py b/openstack_dashboard/test/integration_tests/tests/test_networks.py index b88ba6fa50..75e6abe10b 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_networks.py +++ b/openstack_dashboard/test/integration_tests/tests/test_networks.py @@ -19,7 +19,7 @@ from openstack_dashboard.test.integration_tests.regions import messages @decorators.services_required("neutron") class TestNetworks(helpers.TestCase): NETWORK_NAME = helpers.gen_random_resource_name("network") - SUBNET_NAME = None + SUBNET_NAME = helpers.gen_random_resource_name("subnet") def test_private_network_create(self): """tests the network creation and deletion functionalities: @@ -45,7 +45,3 @@ class TestNetworks(helpers.TestCase): self.assertFalse( networks_page.find_message_and_dismiss(messages.ERROR)) self.assertFalse(networks_page.is_network_present(self.NETWORK_NAME)) - - -class TestAdminNetworks(helpers.AdminTestCase, TestNetworks): - SUBNET_NAME = helpers.gen_random_resource_name("subnet")