diff options
author | spisarski <s.pisarski@cablelabs.com> | 2018-03-13 08:58:38 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2018-03-14 07:25:53 -0600 |
commit | 9d5a173d158af529169f948b06dd80cd62a99d3e (patch) | |
tree | 9625701352aa1b872c0c5e5484c874d8db60f132 | |
parent | e8a50c9979471856bab56d83a8d67ce47b552990 (diff) |
Added test to ensure a port to the external network can be added to
a router by an 'admin' user.
JIRA: SNAPS-283
Change-Id: I78a48862de5bd48dca7dc38d197c0df315003638
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
-rw-r--r-- | docs/how-to-use/IntegrationTests.rst | 3 | ||||
-rw-r--r-- | snaps/openstack/tests/create_router_tests.py | 42 |
2 files changed, 44 insertions, 1 deletions
diff --git a/docs/how-to-use/IntegrationTests.rst b/docs/how-to-use/IntegrationTests.rst index f79e913..0cf4fc0 100644 --- a/docs/how-to-use/IntegrationTests.rst +++ b/docs/how-to-use/IntegrationTests.rst @@ -272,6 +272,9 @@ create_router_tests.py - CreateRouterSuccessTests | test_create_router_external_network | 2 | Ensures that a router can be created that is connected to | | | | both external and private internal networks | +---------------------------------------+---------------+-----------------------------------------------------------+ +| test_create_router_with_ext_port | 2 | Ensures that a router can be created by an 'admin' user | +| | | with a port to an external network | ++---------------------------------------+---------------+-----------------------------------------------------------+ create_router_tests.py - CreateRouterNegativeTests -------------------------------------------------- diff --git a/snaps/openstack/tests/create_router_tests.py b/snaps/openstack/tests/create_router_tests.py index 439d9e3..30cf31e 100644 --- a/snaps/openstack/tests/create_router_tests.py +++ b/snaps/openstack/tests/create_router_tests.py @@ -24,7 +24,7 @@ from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_router import RouterSettings, OpenStackRouter from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase -from snaps.openstack.utils import neutron_utils, settings_utils +from snaps.openstack.utils import neutron_utils, settings_utils, keystone_utils __author__ = 'mmakati' @@ -381,6 +381,46 @@ class CreateRouterSuccessTests(OSIntegrationTestCase): self.check_router_recreation(router, router_settings) + def test_create_router_with_ext_port(self): + """ + Test creation of a router with a port to an external network as an + 'admin' user. + """ + port_settings = [ + create_network.PortConfig( + name=self.guid + '-port1', + network_name=self.ext_net_name)] + + router_settings = RouterConfig( + name=self.guid + '-pub-router', port_settings=port_settings) + self.router_creator = create_router.OpenStackRouter( + self.admin_os_creds, router_settings) + self.router_creator.create() + + admin_neutron = neutron_utils.neutron_client( + self.admin_os_creds, self.admin_os_session) + admin_keystone = keystone_utils.keystone_client( + self.admin_os_creds, self.admin_os_session) + router = neutron_utils.get_router( + admin_neutron, admin_keystone, router_settings=router_settings, + project_name=self.admin_os_creds.project_name) + + self.assertIsNotNone(router) + self.assertEquals(router, self.router_creator.get_router()) + + ext_net = neutron_utils.get_network( + admin_neutron, admin_keystone, network_name=self.ext_net_name) + + self.assertIsNotNone(ext_net) + self.assertIsNotNone(router.port_subnets) + for port, subnets in router.port_subnets: + self.assertIsNotNone(subnets) + self.assertIsNotNone(port) + self.assertEqual(ext_net.id, port.network_id) + for subnet in subnets: + self.assertIsNotNone(subnet) + self.assertEqual(ext_net.id, subnet.network_id) + def check_router_recreation(self, router, orig_settings): """ Validates the derived RouterConfig with the original |