Browse Source

Cameron & Ed | Fix EC2RuleTransformer constructor use, updated security group rule integration test

changes/85/139985/1
cameron-r 4 years ago
parent
commit
693c165a73
2 changed files with 9 additions and 9 deletions
  1. 1
    1
      ec2driver.py
  2. 8
    8
      tests/integration/test_security_groups.py

+ 1
- 1
ec2driver.py View File

@@ -173,7 +173,7 @@ class EC2Driver(driver.ComputeDriver):
173 173
                 ),
174 174
                 ec2_rule_service=EC2RuleService(
175 175
                     ec2_connection=self.ec2_conn,
176
-                    ec2_rule_transformer=EC2RuleTransformer()
176
+                    ec2_rule_transformer=EC2RuleTransformer(self.ec2_conn)
177 177
                 )
178 178
             )
179 179
         )

+ 8
- 8
tests/integration/test_security_groups.py View File

@@ -3,7 +3,7 @@ import unittest
3 3
 from random import randint
4 4
 
5 5
 from ...ec2driver_config import *
6
-from tests.integration.ec2_test_base import EC2TestBase
6
+from ec2_test_base import EC2TestBase
7 7
 
8 8
 
9 9
 class TestSecurityGroups(EC2TestBase):
@@ -36,9 +36,9 @@ class TestSecurityGroups(EC2TestBase):
36 36
 
37 37
         updated_matching_ec2_security_group = self._wait_for_ec2_group_to_have_no_instances(self.security_group)
38 38
         self.assertEqual(updated_matching_ec2_security_group.instances(), [])
39
-
40
-    def test_should_add_rule_to_ec2_security_group_when_group_is_added_to_an_instance(self):
41
-
39
+        
40
+    @unittest.skipIf(os.environ.get('MOCK_EC2'), 'Not supported by moto')
41
+    def test_should_add_rule_to_ec2_security_group_when_rule_is_added_to_openstack_group_associated_with_instance(self):
42 42
         security_group_rule = self.nova.security_group_rules.create(
43 43
             parent_group_id=self.security_group.id,
44 44
             ip_protocol='tcp',
@@ -47,13 +47,13 @@ class TestSecurityGroups(EC2TestBase):
47 47
             cidr='0.0.0.0/0'
48 48
         )
49 49
 
50
-        updated_security_group = self.nova.security_groups.get(self.security_group.id)
51
-
52 50
         ec2_security_group = self.ec2_conn.get_all_security_groups(groupnames=self.security_group.name)[0]
53 51
         ec2_rule = ec2_security_group.rules[0]
54 52
 
55
-        self.assertEqual(ec2_rule.ip_protocol, security_group_rule.ip_protocol)
56
-        #etc
53
+        self.assertEqual(ec2_rule.ip_protocol, security_group_rule['ip_protocol'])
54
+        self.assertEqual(ec2_rule.from_port, security_group_rule['from_port'])
55
+        self.assertEqual(ec2_rule.to_port, security_group_rule['to_port'])
56
+        self.assertEqual(ec2_rule.grants[0].cidr_ip, security_group_rule['ip_range']['cidr'])
57 57
 
58 58
     def _destroy_security_group(self):
59 59
         print "Cleanup: Destroying security group"

Loading…
Cancel
Save