Skip to content

Commit 7a1a59e

Browse files
committed
Functional tests for security group rule
Add functional tests for the "security group rule" commands. Change-Id: Ia03886e92632f37a3d2625df1c3fa7c2a536c564 Partial-Bug: #1519512 Related-to: blueprint neutron-client
1 parent 49bed38 commit 7a1a59e

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class SecurityGroupRuleTests(test.TestCase):
19+
"""Functional tests for security group rule. """
20+
SECURITY_GROUP_NAME = uuid.uuid4().hex
21+
SECURITY_GROUP_RULE_ID = None
22+
NAME_FIELD = ['name']
23+
ID_FIELD = ['id']
24+
ID_HEADER = ['ID']
25+
26+
@classmethod
27+
def setUpClass(cls):
28+
# Create the security group to hold the rule.
29+
opts = cls.get_show_opts(cls.NAME_FIELD)
30+
raw_output = cls.openstack('security group create ' +
31+
cls.SECURITY_GROUP_NAME +
32+
opts)
33+
expected = cls.SECURITY_GROUP_NAME + '\n'
34+
cls.assertOutput(expected, raw_output)
35+
36+
# Create the security group rule.
37+
opts = cls.get_show_opts(cls.ID_FIELD)
38+
raw_output = cls.openstack('security group rule create ' +
39+
cls.SECURITY_GROUP_NAME +
40+
' --proto tcp --dst-port 80:80' +
41+
opts)
42+
cls.SECURITY_GROUP_RULE_ID = raw_output.strip('\n')
43+
44+
@classmethod
45+
def tearDownClass(cls):
46+
raw_output = cls.openstack('security group rule delete ' +
47+
cls.SECURITY_GROUP_RULE_ID)
48+
cls.assertOutput('', raw_output)
49+
50+
raw_output = cls.openstack('security group delete ' +
51+
cls.SECURITY_GROUP_NAME)
52+
cls.assertOutput('', raw_output)
53+
54+
def test_security_group_rule_list(self):
55+
opts = self.get_list_opts(self.ID_HEADER)
56+
raw_output = self.openstack('security group rule list ' +
57+
self.SECURITY_GROUP_NAME +
58+
opts)
59+
self.assertIn(self.SECURITY_GROUP_RULE_ID, raw_output)

0 commit comments

Comments
 (0)