libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/5] libcloud git commit: Added more test coverage.
Date Sun, 25 Feb 2018 18:05:53 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 5dd4b8e9c -> 85180ab61


Added more test coverage.

Signed-off-by: Quentin Pradet <quentinp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/80d4c615
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/80d4c615
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/80d4c615

Branch: refs/heads/trunk
Commit: 80d4c6153f6d2c4cb15f8b929fc9daae22a4426d
Parents: 2337ab3
Author: Max <maxlip@gmail.com>
Authored: Thu Feb 1 16:25:58 2018 -0800
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Sun Feb 25 21:27:31 2018 +0400

----------------------------------------------------------------------
 .../gce/global_firewalls_lcfirewall-deny.json   | 25 ++++++++
 .../gce/global_firewalls_lcfirewall-egress.json | 25 ++++++++
 .../gce/global_firewalls_lcfirewall.json        |  6 +-
 libcloud/test/compute/test_gce.py               | 63 +++++++++++++++++---
 4 files changed, 108 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d4c615/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-deny.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-deny.json b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-deny.json
new file mode 100644
index 0000000..2d12e95
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-deny.json
@@ -0,0 +1,25 @@
+{
+  "denied": [
+    {
+      "IPProtocol": "tcp",
+      "ports": [
+        "4567"
+      ]
+    }
+  ],
+  "creationTimestamp": "2013-06-26T10:04:43.773-09:00",
+  "description": "Libcloud Deny Firewall",
+  "direction": "INGRESS",
+  "id": "0565629596395414123",
+  "kind": "compute#firewall",
+  "name": "lcfirewall-deny",
+  "network": "https://www.googleapis.com/compute/v1/projects/project_name/global/networks/default",
+  "priority": 900,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/firewalls/lcfirewall-deny",
+  "sourceRanges": [
+    "10.240.100.0/24"
+  ],
+  "sourceTags": [
+    "libcloud"
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d4c615/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-egress.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-egress.json b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-egress.json
new file mode 100644
index 0000000..e4a0c5a
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall-egress.json
@@ -0,0 +1,25 @@
+{
+  "allowed": [
+    {
+      "IPProtocol": "tcp",
+      "ports": [
+        "4567"
+      ]
+    }
+  ],
+  "creationTimestamp": "2013-06-26T10:05:43.773-07:00",
+  "description": "Libcloud Egress Firewall",
+  "direction": "EGRESS",
+  "id": "0565629596395414122",
+  "kind": "compute#firewall",
+  "name": "lcfirewall-egress",
+  "network": "https://www.googleapis.com/compute/v1/projects/project_name/global/networks/default",
+  "priority": 900,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/firewalls/lcfirewall-egress",
+  "targetServiceAccounts": [
+    "lctarget@gserviceaccount.com"
+  ],
+  "destinationRanges": [
+    "8.8.8.8/32"
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d4c615/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall.json b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall.json
index 4517c85..db42d2c 100644
--- a/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall.json
+++ b/libcloud/test/compute/fixtures/gce/global_firewalls_lcfirewall.json
@@ -8,14 +8,16 @@
     }
   ],
   "creationTimestamp": "2013-06-26T10:04:43.773-07:00",
+  "description": "Libcloud Test Firewall",
+  "direction": "INGRESS",
   "id": "0565629596395414121",
   "kind": "compute#firewall",
   "name": "lcfirewall",
   "network": "https://www.googleapis.com/compute/v1/projects/project_name/global/networks/default",
   "priority": 900,
   "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/firewalls/lcfirewall",
-  "sourceTags": [
-    "libcloud"
+  "sourceServiceAccounts": [
+    "lcsource@gserviceaccount.com"
   ],
   "targetTags": [
     "libcloud"

http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d4c615/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index f95d175..3625367 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -855,17 +855,54 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
         self.assertEqual(image.extra['guestOsFeatures'], expected_features)
 
     def test_ex_create_firewall(self):
-        firewall_name = 'lcfirewall'
+        name = 'lcfirewall'
         priority = 900
+        description = "Libcloud Test Firewall"
         allowed = [{'IPProtocol': 'tcp', 'ports': ['4567']}]
-        source_tags = ['libcloud']
+        source_service_accounts = ['lcsource@gserviceaccount.com']
         target_tags = ['libcloud']
-        firewall = self.driver.ex_create_firewall(firewall_name, allowed,
-                                                  priority=priority,
-                                                  target_tags=target_tags,
-                                                  source_tags=source_tags)
+        network = 'default'
+        firewall = self.driver.ex_create_firewall(
+                            name, allowed, description=description,
+                            network=network, priority=priority,
+                            target_tags=target_tags,
+                            source_service_accounts=source_service_accounts)
         self.assertTrue(isinstance(firewall, GCEFirewall))
-        self.assertEqual(firewall.name, firewall_name)
+        self.assertEqual(firewall.name, name)
+
+    def test_ex_create_firewall_egress(self):
+        name = 'lcfirewall-egress'
+        priority = 900
+        direction = 'EGRESS'
+        description = "Libcloud Egress Firewall"
+        allowed = [{'IPProtocol': 'tcp', 'ports': ['4567']}]
+        target_service_accounts = ['lctarget@gserviceaccount.com']
+        target_ranges = ['8.8.8.8/32']
+        network = 'default'
+        firewall = self.driver.ex_create_firewall(
+                            name, allowed,
+                            description=description, network=network,
+                            priority=priority, direction=direction,
+                            target_ranges=target_ranges,
+                            target_service_accounts=target_service_accounts)
+        self.assertTrue(isinstance(firewall, GCEFirewall))
+        self.assertEqual(firewall.name, name)
+
+    def test_ex_create_firewall_deny(self):
+        name = 'lcfirewall-deny'
+        priority = 900
+        denied = [{'IPProtocol': 'tcp', 'ports': ['4567']}]
+        description = "Libcloud Deny Firewall"
+        source_ranges = ['10.240.100.0/24']
+        source_tags = ['libcloud']
+        network = 'default'
+        firewall = self.driver.ex_create_firewall(
+                             name, denied=denied,
+                             description=description, network=network,
+                             priority=priority, source_tags=source_tags,
+                             source_ranges=source_ranges)
+        self.assertTrue(isinstance(firewall, GCEFirewall))
+        self.assertEqual(firewall.name, name)
 
     def test_ex_create_forwarding_rule(self):
         fwr_name = 'lcforwardingrule'
@@ -1447,7 +1484,7 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
         firewall_name = 'lcfirewall'
         firewall = self.driver.ex_get_firewall(firewall_name)
         firewall.source_ranges = ['10.0.0.0/16']
-        firewall.target_service_accounts = ['libcloud@apache.com']
+        firewall.description = "LCFirewall-2"
         firewall2 = self.driver.ex_update_firewall(firewall)
         self.assertTrue(isinstance(firewall2, GCEFirewall))
 
@@ -1713,7 +1750,7 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
         firewall = self.driver.ex_get_firewall(firewall_name)
         self.assertEqual(firewall.name, firewall_name)
         self.assertEqual(firewall.network.name, 'default')
-        self.assertEqual(firewall.source_tags, ['libcloud'])
+        self.assertEqual(firewall.target_tags, ['libcloud'])
 
     def test_ex_get_forwarding_rule(self):
         fwr_name = 'lcforwardingrule'
@@ -2358,6 +2395,14 @@ class GCEMockHttp(MockHttp):
             body = self.fixtures.load('global_firewalls_lcfirewall.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _global_firewalls_lcfirewall_egress(self, method, url, body, headers):
+        body = self.fixtures.load('global_firewalls_lcfirewall-egress.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
+    def _global_firewalls_lcfirewall_deny(self, method, url, body, headers):
+        body = self.fixtures.load('global_firewalls_lcfirewall-deny.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _global_images(self, method, url, body, headers):
         if method == 'POST':
             body = self.fixtures.load('global_images_post.json')


Mime
View raw message