@@ -0,0 +1,2656 @@
+# Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A# not use this file except in compliance with the License. You may obtain%0A# a copy of the License at%0A#%0A#      http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A# License for the specific language governing permissions and limitations%0A# under the License.%0A%0Aimport uuid%0A%0Afrom openstack.network.v2 import security_group%0Afrom openstack.network.v2 import security_group_rule%0Afrom openstack.tests.functional import base%0A%0A%0Aclass TestSecurityGroupRule(base.BaseFunctionalTest):%0A%0A    NAME = uuid.uuid4().hex%0A    IPV4 = 'IPv4'%0A    PROTO = 'tcp'%0A    PORT = 22%0A    DIR = 'ingress'%0A    ID = None%0A    RULE_ID = None%0A%0A    @classmethod%0A    def setUpClass(cls):%0A        super(TestSecurityGroupRule, cls).setUpClass()%0A        sot = cls.conn.network.create_security_group(name=cls.NAME)%0A        assert isinstance(sot, security_group.SecurityGroup)%0A        cls.assertIs(cls.NAME, sot.name)%0A        cls.ID = sot.id%0A        rul = cls.conn.network.create_security_group_rule(%0A            direction=cls.DIR, ethertype=cls.IPV4,%0A            port_range_max=cls.PORT, port_range_min=cls.PORT,%0A            protocol=cls.PROTO, security_group_id=cls.ID)%0A        assert isinstance(rul, security_group_rule.SecurityGroupRule)%0A        cls.assertIs(cls.ID, rul.security_group_id)%0A        cls.RULE_ID = rul.id%0A%0A    @classmethod%0A    def tearDownClass(cls):%0A        sot = cls.conn.network.delete_security_group_rule(cls.RULE_ID,%0A                                                          ignore_missing=False)%0A        cls.assertIs(None, sot)%0A        sot = cls.conn.network.delete_security_group(cls.ID,%0A                                                     ignore_missing=False)%0A        cls.assertIs(None, sot)%0A%0A    def test_find(self):%0A        sot = self.conn.network.find_security_group_rule(self.RULE_ID)%0A        self.assertEqual(self.RULE_ID, sot.id)%0A%0A    def test_get(self):%0A        sot = self.conn.network.get_security_group_rule(self.RULE_ID)%0A        self.assertEqual(self.RULE_ID, sot.id)%0A        self.assertEqual(self.DIR, sot.direction)%0A        self.assertEqual(self.PROTO, sot.protocol)%0A        self.assertEqual(self.PORT, sot.port_range_min)%0A        self.assertEqual(self.PORT, sot.port_range_max)%0A        self.assertEqual(self.ID, sot.security_group_id)%0A%0A    def test_list(self):%0A        ids = %5Bo.id for o in self.conn.network.security_group_rules()%5D%0A        self.assertIn(self.RULE_ID, ids)%0A

Add functional tests for security group rule