summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/network
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/functional/network')
-rw-r--r--openstackclient/tests/functional/network/__init__.py0
-rw-r--r--openstackclient/tests/functional/network/v2/__init__.py0
-rw-r--r--openstackclient/tests/functional/network/v2/test_address_scope.py49
-rw-r--r--openstackclient/tests/functional/network/v2/test_floating_ip.py58
-rw-r--r--openstackclient/tests/functional/network/v2/test_ip_availability.py53
-rw-r--r--openstackclient/tests/functional/network/v2/test_network.py50
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_agent.py41
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_rbac.py69
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_segment.py60
-rw-r--r--openstackclient/tests/functional/network/v2/test_port.py58
-rw-r--r--openstackclient/tests/functional/network/v2/test_router.py50
-rw-r--r--openstackclient/tests/functional/network/v2/test_security_group.py60
-rw-r--r--openstackclient/tests/functional/network/v2/test_security_group_rule.py67
-rw-r--r--openstackclient/tests/functional/network/v2/test_subnet.py66
-rw-r--r--openstackclient/tests/functional/network/v2/test_subnet_pool.py55
15 files changed, 736 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/network/__init__.py b/openstackclient/tests/functional/network/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/openstackclient/tests/functional/network/__init__.py
diff --git a/openstackclient/tests/functional/network/v2/__init__.py b/openstackclient/tests/functional/network/v2/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/__init__.py
diff --git a/openstackclient/tests/functional/network/v2/test_address_scope.py b/openstackclient/tests/functional/network/v2/test_address_scope.py
new file mode 100644
index 00000000..ef4b5756
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_address_scope.py
@@ -0,0 +1,49 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class AddressScopeTests(base.TestCase):
+ """Functional tests for address scope. """
+ NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('address scope create ' + cls.NAME + opts)
+ cls.assertOutput(cls.NAME + "\n", raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('address scope delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_address_scope_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('address scope list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_address_scope_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('address scope show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
+
+ def test_address_scope_set(self):
+ self.openstack('address scope set --share ' + self.NAME)
+ opts = self.get_opts(['shared'])
+ raw_output = self.openstack('address scope show ' + self.NAME + opts)
+ self.assertEqual("True\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_floating_ip.py b/openstackclient/tests/functional/network/v2/test_floating_ip.py
new file mode 100644
index 00000000..f3a1971f
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_floating_ip.py
@@ -0,0 +1,58 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class FloatingIpTests(base.TestCase):
+ """Functional tests for floating ip. """
+ SUBNET_NAME = uuid.uuid4().hex
+ NETWORK_NAME = uuid.uuid4().hex
+ ID = None
+ HEADERS = ['ID']
+ FIELDS = ['id']
+
+ @classmethod
+ def setUpClass(cls):
+ # Create a network for the floating ip.
+ cls.openstack('network create --external ' + cls.NETWORK_NAME)
+ # Create a subnet for the network.
+ cls.openstack(
+ 'subnet create --network ' + cls.NETWORK_NAME +
+ ' --subnet-range 10.10.10.0/24 ' +
+ cls.SUBNET_NAME
+ )
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack(
+ 'floating ip create ' + cls.NETWORK_NAME + opts)
+ cls.ID = raw_output.strip('\n')
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('floating ip delete ' + cls.ID)
+ cls.assertOutput('', raw_output)
+ raw_output = cls.openstack('subnet delete ' + cls.SUBNET_NAME)
+ cls.assertOutput('', raw_output)
+ raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_floating_ip_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('floating ip list' + opts)
+ self.assertIn(self.ID, raw_output)
+
+ def test_floating_ip_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('floating ip show ' + self.ID + opts)
+ self.assertEqual(self.ID + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_ip_availability.py b/openstackclient/tests/functional/network/v2/test_ip_availability.py
new file mode 100644
index 00000000..b5c908f4
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_ip_availability.py
@@ -0,0 +1,53 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class IPAvailabilityTests(base.TestCase):
+ """Functional tests for IP availability. """
+ NAME = uuid.uuid4().hex
+ NETWORK_NAME = uuid.uuid4().hex
+ FIELDS = ['network_name']
+
+ @classmethod
+ def setUpClass(cls):
+ # Create a network for the subnet.
+ cls.openstack('network create ' + cls.NETWORK_NAME)
+ opts = cls.get_opts(['name'])
+ raw_output = cls.openstack(
+ 'subnet create --network ' + cls.NETWORK_NAME +
+ ' --subnet-range 10.10.10.0/24 ' +
+ cls.NAME + opts
+ )
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_subnet = cls.openstack('subnet delete ' + cls.NAME)
+ raw_network = cls.openstack('network delete ' + cls.NETWORK_NAME)
+ cls.assertOutput('', raw_subnet)
+ cls.assertOutput('', raw_network)
+
+ def test_ip_availability_list(self):
+ opts = ' -f csv -c "Network Name"'
+ raw_output = self.openstack('ip availability list' + opts)
+ self.assertIn(self.NETWORK_NAME, raw_output)
+
+ def test_ip_availability_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack(
+ 'ip availability show ' + self.NETWORK_NAME + opts)
+ self.assertEqual(self.NETWORK_NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_network.py b/openstackclient/tests/functional/network/v2/test_network.py
new file mode 100644
index 00000000..c77ff642
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_network.py
@@ -0,0 +1,50 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class NetworkTests(base.TestCase):
+ """Functional tests for network. """
+ NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('network create ' + cls.NAME + opts)
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('network delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_network_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('network list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_network_set(self):
+ raw_output = self.openstack('network set --disable ' + self.NAME)
+ opts = self.get_opts(['name', 'admin_state_up'])
+ raw_output = self.openstack('network show ' + self.NAME + opts)
+ self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
+
+ def test_network_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('network show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_network_agent.py b/openstackclient/tests/functional/network/v2/test_network_agent.py
new file mode 100644
index 00000000..dd6112e7
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_network_agent.py
@@ -0,0 +1,41 @@
+# 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 openstackclient.tests.functional import base
+
+
+class NetworkAgentTests(base.TestCase):
+ """Functional tests for network agent. """
+ IDs = None
+ HEADERS = ['ID']
+ FIELDS = ['id']
+
+ @classmethod
+ def test_network_agent_list(cls):
+ opts = cls.get_opts(cls.HEADERS)
+ raw_output = cls.openstack('network agent list' + opts)
+ # get the list of network agent IDs.
+ cls.IDs = raw_output.split('\n')
+
+ def test_network_agent_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
+ self.assertEqual(self.IDs[0] + "\n", raw_output)
+
+ def test_network_agent_set(self):
+ opts = self.get_opts(['admin_state_up'])
+ self.openstack('network agent set --disable ' + self.IDs[0])
+ raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
+ self.assertEqual("DOWN\n", raw_output)
+ self.openstack('network agent set --enable ' + self.IDs[0])
+ raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
+ self.assertEqual("UP\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_network_rbac.py b/openstackclient/tests/functional/network/v2/test_network_rbac.py
new file mode 100644
index 00000000..6f9f05e7
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_network_rbac.py
@@ -0,0 +1,69 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class NetworkRBACTests(base.TestCase):
+ """Functional tests for network rbac. """
+ NET_NAME = uuid.uuid4().hex
+ PROJECT_NAME = uuid.uuid4().hex
+ OBJECT_ID = None
+ ID = None
+ HEADERS = ['ID']
+ FIELDS = ['id']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('network create ' + cls.NET_NAME + opts)
+ cls.OBJECT_ID = raw_output.strip('\n')
+ opts = cls.get_opts(['id', 'object_id'])
+ raw_output = cls.openstack('network rbac create ' +
+ cls.OBJECT_ID +
+ ' --action access_as_shared' +
+ ' --target-project admin' +
+ ' --type network' + opts)
+ cls.ID, object_id, rol = tuple(raw_output.split('\n'))
+ cls.assertOutput(cls.OBJECT_ID, object_id)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output_rbac = cls.openstack('network rbac delete ' + cls.ID)
+ raw_output_network = cls.openstack('network delete ' + cls.OBJECT_ID)
+ cls.assertOutput('', raw_output_rbac)
+ cls.assertOutput('', raw_output_network)
+
+ def test_network_rbac_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('network rbac list' + opts)
+ self.assertIn(self.ID, raw_output)
+
+ def test_network_rbac_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('network rbac show ' + self.ID + opts)
+ self.assertEqual(self.ID + "\n", raw_output)
+
+ def test_network_rbac_set(self):
+ opts = self.get_opts(self.FIELDS)
+ project_id = self.openstack(
+ 'project create ' + self.PROJECT_NAME + opts)
+ self.openstack('network rbac set ' + self.ID +
+ ' --target-project ' + self.PROJECT_NAME)
+ opts = self.get_opts(['target_project_id'])
+ raw_output_rbac = self.openstack('network rbac show ' + self.ID + opts)
+ raw_output_project = self.openstack(
+ 'project delete ' + self.PROJECT_NAME)
+ self.assertEqual(project_id, raw_output_rbac)
+ self.assertOutput('', raw_output_project)
diff --git a/openstackclient/tests/functional/network/v2/test_network_segment.py b/openstackclient/tests/functional/network/v2/test_network_segment.py
new file mode 100644
index 00000000..f871e88e
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_network_segment.py
@@ -0,0 +1,60 @@
+# 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.
+
+import testtools
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+# NOTE(rtheis): Routed networks is still a WIP and not enabled by default.
+@testtools.skip("bp/routed-networks")
+class NetworkSegmentTests(base.TestCase):
+ """Functional tests for network segment. """
+ NETWORK_NAME = uuid.uuid4().hex
+ PHYSICAL_NETWORK_NAME = uuid.uuid4().hex
+ NETWORK_SEGMENT_ID = None
+ NETWORK_ID = None
+
+ @classmethod
+ def setUpClass(cls):
+ # Create a network for the segment.
+ opts = cls.get_opts(['id'])
+ raw_output = cls.openstack('network create ' + cls.NETWORK_NAME + opts)
+ cls.NETWORK_ID = raw_output.strip('\n')
+
+ # Get the segment for the network.
+ opts = cls.get_opts(['ID', 'Network'])
+ raw_output = cls.openstack('--os-beta-command '
+ 'network segment list '
+ ' --network ' + cls.NETWORK_NAME +
+ ' ' + opts)
+ raw_output_row = raw_output.split('\n')[0]
+ cls.NETWORK_SEGMENT_ID = raw_output_row.split(' ')[0]
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_network_segment_list(self):
+ opts = self.get_opts(['ID'])
+ raw_output = self.openstack('--os-beta-command '
+ 'network segment list' + opts)
+ self.assertIn(self.NETWORK_SEGMENT_ID, raw_output)
+
+ def test_network_segment_show(self):
+ opts = self.get_opts(['network_id'])
+ raw_output = self.openstack('--os-beta-command '
+ 'network segment show ' +
+ self.NETWORK_SEGMENT_ID + opts)
+ self.assertEqual(self.NETWORK_ID + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_port.py b/openstackclient/tests/functional/network/v2/test_port.py
new file mode 100644
index 00000000..decd9553
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_port.py
@@ -0,0 +1,58 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class PortTests(base.TestCase):
+ """Functional tests for port. """
+ NAME = uuid.uuid4().hex
+ NETWORK_NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ # Create a network for the subnet.
+ cls.openstack('network create ' + cls.NETWORK_NAME)
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack(
+ 'port create --network ' + cls.NETWORK_NAME + ' ' +
+ cls.NAME + opts
+ )
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('port delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+ raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_port_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('port list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_port_set(self):
+ self.openstack('port set --disable ' + self.NAME)
+ opts = self.get_opts(['name', 'admin_state_up'])
+ raw_output = self.openstack('port show ' + self.NAME + opts)
+ self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
+
+ def test_port_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('port show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_router.py b/openstackclient/tests/functional/network/v2/test_router.py
new file mode 100644
index 00000000..789c3825
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_router.py
@@ -0,0 +1,50 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class RouterTests(base.TestCase):
+ """Functional tests for router. """
+ NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('router create ' + cls.NAME + opts)
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('router delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_router_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('router list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_router_set(self):
+ self.openstack('router set --disable ' + self.NAME)
+ opts = self.get_opts(['name', 'admin_state_up'])
+ raw_output = self.openstack('router show ' + self.NAME + opts)
+ self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
+
+ def test_router_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('router show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_security_group.py b/openstackclient/tests/functional/network/v2/test_security_group.py
new file mode 100644
index 00000000..debd81df
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_security_group.py
@@ -0,0 +1,60 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class SecurityGroupTests(base.TestCase):
+ """Functional tests for security group. """
+ NAME = uuid.uuid4().hex
+ OTHER_NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('security group create ' + cls.NAME + opts)
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ # Rename test
+ raw_output = cls.openstack('security group set --name ' +
+ cls.OTHER_NAME + ' ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+ # Delete test
+ raw_output = cls.openstack('security group delete ' + cls.OTHER_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_security_group_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('security group list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_security_group_set(self):
+ raw_output = self.openstack(
+ 'security group set --description NSA ' + self.NAME
+ )
+ self.assertEqual('', raw_output)
+
+ opts = self.get_opts(['description'])
+ raw_output = self.openstack('security group show ' + self.NAME + opts)
+ self.assertEqual("NSA\n", raw_output)
+
+ def test_security_group_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('security group show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_security_group_rule.py b/openstackclient/tests/functional/network/v2/test_security_group_rule.py
new file mode 100644
index 00000000..c91de1a5
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_security_group_rule.py
@@ -0,0 +1,67 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class SecurityGroupRuleTests(base.TestCase):
+ """Functional tests for security group rule. """
+ SECURITY_GROUP_NAME = uuid.uuid4().hex
+ SECURITY_GROUP_RULE_ID = None
+ NAME_FIELD = ['name']
+ ID_FIELD = ['id']
+ ID_HEADER = ['ID']
+
+ @classmethod
+ def setUpClass(cls):
+ # Create the security group to hold the rule.
+ opts = cls.get_opts(cls.NAME_FIELD)
+ raw_output = cls.openstack('security group create ' +
+ cls.SECURITY_GROUP_NAME +
+ opts)
+ expected = cls.SECURITY_GROUP_NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ # Create the security group rule.
+ opts = cls.get_opts(cls.ID_FIELD)
+ raw_output = cls.openstack('security group rule create ' +
+ cls.SECURITY_GROUP_NAME +
+ ' --protocol tcp --dst-port 80:80' +
+ ' --ingress --ethertype IPv4' +
+ opts)
+ cls.SECURITY_GROUP_RULE_ID = raw_output.strip('\n')
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('security group rule delete ' +
+ cls.SECURITY_GROUP_RULE_ID)
+ cls.assertOutput('', raw_output)
+
+ raw_output = cls.openstack('security group delete ' +
+ cls.SECURITY_GROUP_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_security_group_rule_list(self):
+ opts = self.get_opts(self.ID_HEADER)
+ raw_output = self.openstack('security group rule list ' +
+ self.SECURITY_GROUP_NAME +
+ opts)
+ self.assertIn(self.SECURITY_GROUP_RULE_ID, raw_output)
+
+ def test_security_group_rule_show(self):
+ opts = self.get_opts(self.ID_FIELD)
+ raw_output = self.openstack('security group rule show ' +
+ self.SECURITY_GROUP_RULE_ID +
+ opts)
+ self.assertEqual(self.SECURITY_GROUP_RULE_ID + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_subnet.py b/openstackclient/tests/functional/network/v2/test_subnet.py
new file mode 100644
index 00000000..231671f3
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_subnet.py
@@ -0,0 +1,66 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class SubnetTests(base.TestCase):
+ """Functional tests for subnet. """
+ NAME = uuid.uuid4().hex
+ NETWORK_NAME = uuid.uuid4().hex
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ # Create a network for the subnet.
+ cls.openstack('network create ' + cls.NETWORK_NAME)
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack(
+ 'subnet create --network ' + cls.NETWORK_NAME +
+ ' --subnet-range 10.10.10.0/24 ' +
+ cls.NAME + opts
+ )
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('subnet delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+ raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_subnet_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('subnet list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_subnet_set(self):
+ self.openstack('subnet set --no-dhcp ' + self.NAME)
+ opts = self.get_opts(['name', 'enable_dhcp'])
+ raw_output = self.openstack('subnet show ' + self.NAME + opts)
+ self.assertEqual("False\n" + self.NAME + "\n", raw_output)
+
+ def test_subnet_set_service_type(self):
+ TYPE = 'network:floatingip_agent_gateway'
+ self.openstack('subnet set --service-type ' + TYPE + ' ' + self.NAME)
+ opts = self.get_opts(['name', 'service_types'])
+ raw_output = self.openstack('subnet show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n" + TYPE + "\n", raw_output)
+
+ def test_subnet_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('subnet show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + "\n", raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_subnet_pool.py b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
new file mode 100644
index 00000000..e52f06fc
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
@@ -0,0 +1,55 @@
+# 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.
+
+import uuid
+
+from openstackclient.tests.functional import base
+
+
+class SubnetPoolTests(base.TestCase):
+ """Functional tests for subnet pool. """
+ NAME = uuid.uuid4().hex
+ CREATE_POOL_PREFIX = '10.100.0.0/24'
+ SET_POOL_PREFIX = '10.100.0.0/16'
+ HEADERS = ['Name']
+ FIELDS = ['name']
+
+ @classmethod
+ def setUpClass(cls):
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack('subnet pool create --pool-prefix ' +
+ cls.CREATE_POOL_PREFIX + ' ' +
+ cls.NAME + opts)
+ cls.assertOutput(cls.NAME + '\n', raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ raw_output = cls.openstack('subnet pool delete ' + cls.NAME)
+ cls.assertOutput('', raw_output)
+
+ def test_subnet_list(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('subnet pool list' + opts)
+ self.assertIn(self.NAME, raw_output)
+
+ def test_subnet_set(self):
+ self.openstack('subnet pool set --pool-prefix ' +
+ self.SET_POOL_PREFIX + ' ' + self.NAME)
+ opts = self.get_opts(['prefixes', 'name'])
+ raw_output = self.openstack('subnet pool show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + '\n' + self.SET_POOL_PREFIX + '\n',
+ raw_output)
+
+ def test_subnet_show(self):
+ opts = self.get_opts(self.FIELDS)
+ raw_output = self.openstack('subnet pool show ' + self.NAME + opts)
+ self.assertEqual(self.NAME + '\n', raw_output)