Skip to content

Commit e57808d

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add functional tests for security group CRUD"
2 parents 1a45b20 + 46f61c8 commit e57808d

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 SecurityGroupTests(test.TestCase):
19+
"""Functional tests for security group. """
20+
NAME = uuid.uuid4().hex
21+
OTHER_NAME = uuid.uuid4().hex
22+
HEADERS = ['Name']
23+
FIELDS = ['name']
24+
25+
@classmethod
26+
def setUpClass(cls):
27+
opts = cls.get_show_opts(cls.FIELDS)
28+
raw_output = cls.openstack('security group create ' + cls.NAME + opts)
29+
expected = cls.NAME + '\n'
30+
cls.assertOutput(expected, raw_output)
31+
32+
@classmethod
33+
def tearDownClass(cls):
34+
# Rename test
35+
opts = cls.get_show_opts(cls.FIELDS)
36+
raw_output = cls.openstack('security group set --name ' +
37+
cls.OTHER_NAME + ' ' + cls.NAME + opts)
38+
cls.assertOutput(cls.OTHER_NAME + "\n", raw_output)
39+
# Delete test
40+
raw_output = cls.openstack('security group delete ' + cls.OTHER_NAME)
41+
cls.assertOutput('', raw_output)
42+
43+
def test_security_group_list(self):
44+
opts = self.get_list_opts(self.HEADERS)
45+
raw_output = self.openstack('security group list' + opts)
46+
self.assertIn(self.NAME, raw_output)
47+
48+
def test_security_group_set(self):
49+
opts = self.get_show_opts(['description', 'name'])
50+
raw_output = self.openstack('security group set --description NSA ' +
51+
self.NAME + opts)
52+
self.assertEqual("NSA\n" + self.NAME + "\n", raw_output)
53+
54+
def test_security_group_show(self):
55+
opts = self.get_show_opts(self.FIELDS)
56+
raw_output = self.openstack('security group show ' + self.NAME + opts)
57+
self.assertEqual(self.NAME + "\n", raw_output)

0 commit comments

Comments
 (0)