libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [10/14] libcloud git commit: Add tests for more extension methods.
Date Sun, 06 Dec 2015 06:32:48 GMT
Add tests for more extension methods.


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

Branch: refs/heads/trunk
Commit: a442ffb5df357207643f2ad14e60fb2ce59a6476
Parents: 66ff9d4
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Sun Dec 6 13:52:00 2015 +0800
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Sun Dec 6 14:11:44 2015 +0800

----------------------------------------------------------------------
 libcloud/dns/drivers/cloudflare.py              |   4 +-
 libcloud/test/dns/fixtures/cloudflare/ban.json  |  10 ++
 .../test/dns/fixtures/cloudflare/cache_lvl.json |   4 +
 .../test/dns/fixtures/cloudflare/devmode.json   |   4 +
 .../test/dns/fixtures/cloudflare/fpurge_ts.json |  10 ++
 .../test/dns/fixtures/cloudflare/ipv46.json     |   4 +
 libcloud/test/dns/fixtures/cloudflare/nul.json  |  10 ++
 .../test/dns/fixtures/cloudflare/sec_lvl.json   |   4 +
 libcloud/test/dns/fixtures/cloudflare/wl.json   |  10 ++
 .../fixtures/cloudflare/zone_file_purge.json    |  15 +++
 libcloud/test/dns/test_cloudflare.py            | 131 +++++++++++++++++++
 11 files changed, 204 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/dns/drivers/cloudflare.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/cloudflare.py b/libcloud/dns/drivers/cloudflare.py
index d12c122..5812d60 100644
--- a/libcloud/dns/drivers/cloudflare.py
+++ b/libcloud/dns/drivers/cloudflare.py
@@ -294,7 +294,7 @@ class CloudFlareDNSDriver(DNSDriver):
         result = resp.object
         return result.get('result', None) == 'success'
 
-    def ex_purge_cache_files(self, zone):
+    def ex_purge_cached_files(self, zone):
         """
         Purge CloudFlare of any cached files.
         """
@@ -304,7 +304,7 @@ class CloudFlareDNSDriver(DNSDriver):
         result = resp.object
         return result.get('result', None) == 'success'
 
-    def ex_purge_cache_file(self, zone, url):
+    def ex_purge_cached_file(self, zone, url):
         """
         Purgle single file from CloudFlare's cache.
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/ban.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/ban.json b/libcloud/test/dns/fixtures/cloudflare/ban.json
new file mode 100644
index 0000000..1dbf1bf
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/ban.json
@@ -0,0 +1,10 @@
+{
+  "response": {
+    "result": {
+      "ip": "127.0.0.1",
+      "action": "BAN"
+    }
+  },
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/cache_lvl.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/cache_lvl.json b/libcloud/test/dns/fixtures/cloudflare/cache_lvl.json
new file mode 100644
index 0000000..15abe82
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/cache_lvl.json
@@ -0,0 +1,4 @@
+{
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/devmode.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/devmode.json b/libcloud/test/dns/fixtures/cloudflare/devmode.json
new file mode 100644
index 0000000..15abe82
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/devmode.json
@@ -0,0 +1,4 @@
+{
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/fpurge_ts.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/fpurge_ts.json b/libcloud/test/dns/fixtures/cloudflare/fpurge_ts.json
new file mode 100644
index 0000000..e88b55c
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/fpurge_ts.json
@@ -0,0 +1,10 @@
+{
+  "response": {
+    "fpurge_ts": 1449381662
+  },
+  "result": "success",
+  "msg": null,
+  "attributes": {
+    "cooldown": 20
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/ipv46.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/ipv46.json b/libcloud/test/dns/fixtures/cloudflare/ipv46.json
new file mode 100644
index 0000000..15abe82
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/ipv46.json
@@ -0,0 +1,4 @@
+{
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/nul.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/nul.json b/libcloud/test/dns/fixtures/cloudflare/nul.json
new file mode 100644
index 0000000..6762b7c
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/nul.json
@@ -0,0 +1,10 @@
+{
+  "response": {
+    "result": {
+      "ip": "127.0.0.1",
+      "action": "NUL"
+    }
+  },
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/sec_lvl.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/sec_lvl.json b/libcloud/test/dns/fixtures/cloudflare/sec_lvl.json
new file mode 100644
index 0000000..15abe82
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/sec_lvl.json
@@ -0,0 +1,4 @@
+{
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/wl.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/wl.json b/libcloud/test/dns/fixtures/cloudflare/wl.json
new file mode 100644
index 0000000..777b392
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/wl.json
@@ -0,0 +1,10 @@
+{
+  "response": {
+    "result": {
+      "ip": "127.0.0.1",
+      "action": "WL"
+    }
+  },
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/fixtures/cloudflare/zone_file_purge.json
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/cloudflare/zone_file_purge.json b/libcloud/test/dns/fixtures/cloudflare/zone_file_purge.json
new file mode 100644
index 0000000..086925b
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/zone_file_purge.json
@@ -0,0 +1,15 @@
+{
+  "request": {
+    "act": "zone_file_purge",
+    "url": "https:\/\/www.example.com\/aaaaa.html",
+    "tkn": "maybeno",
+    "z": "example.com",
+    "a": "zone_file_purge",
+    "email": "example@example.com"
+  },
+  "response": {
+    "url": "https:\/\/www.example.com\/test.html"
+  },
+  "result": "success",
+  "msg": null
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a442ffb5/libcloud/test/dns/test_cloudflare.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_cloudflare.py b/libcloud/test/dns/test_cloudflare.py
index abb99c9..b9f9227 100644
--- a/libcloud/test/dns/test_cloudflare.py
+++ b/libcloud/test/dns/test_cloudflare.py
@@ -143,6 +143,65 @@ class CloudFlareDNSDriverTestCase(unittest.TestCase):
         self.assertTrue('email_filter' in result)
         self.assertTrue('secureheader_settings' in result)
 
+    def test_ex_set_one_security_level(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_set_zone_security_level(zone=zone, level='med')
+        self.assertTrue(result)
+
+    def test_ex_set_zone_cache_level(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_set_zone_cache_level(zone=zone, level='agg')
+        self.assertTrue(result)
+
+    def test_ex_enable_development_mode(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_enable_development_mode(zone=zone)
+        self.assertTrue(result)
+
+    def test_ex_disable_development_mode(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_disable_development_mode(zone=zone)
+        self.assertTrue(result)
+
+    def test_ex_purge_cached_files(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_purge_cached_files(zone=zone)
+        self.assertTrue(result)
+
+    def test_ex_purge_cached_file(self):
+        zone = self.driver.list_zones()[0]
+        url = 'https://www.example.com/test.html'
+        result = self.driver.ex_purge_cached_file(zone=zone, url=url)
+        self.assertTrue(result)
+
+    def test_ex_whitelist_ip(self):
+        zone = self.driver.list_zones()[0]
+        ip = '127.0.0.1'
+        result = self.driver.ex_whitelist_ip(zone=zone, ip=ip)
+        self.assertTrue(result)
+
+    def test_ex_blacklist_ip(self):
+        zone = self.driver.list_zones()[0]
+        ip = '127.0.0.1'
+        result = self.driver.ex_blacklist_ip(zone=zone, ip=ip)
+        self.assertTrue(result)
+
+    def test_ex_unlist_ip(self):
+        zone = self.driver.list_zones()[0]
+        ip = '127.0.0.1'
+        result = self.driver.ex_unlist_ip(zone=zone, ip=ip)
+        self.assertTrue(result)
+
+    def test_enable_ipv6_support(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_enable_development_mode(zone=zone)
+        self.assertTrue(result)
+
+    def test_ex_disable_ipv6_support(self):
+        zone = self.driver.list_zones()[0]
+        result = self.driver.ex_disable_development_mode(zone=zone)
+        self.assertTrue(result)
+
 
 class CloudFlareMockHttp(MockHttp):
     fixtures = DNSFileFixtures('cloudflare')
@@ -219,6 +278,78 @@ class CloudFlareMockHttp(MockHttp):
             raise AssertionError('Unsupported method')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _api_json_html_sec_lvl(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('sec_lvl.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_cache_lvl(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('cache_lvl.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_devmode(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('devmode.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_fpurge_ts(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('fpurge_ts.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_zone_file_purge(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('zone_file_purge.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_wl(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('wl.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_ban(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('ban.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_nul(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('nul.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _api_json_html_ipv46(
+            self, method, url, body, headers):
+        if method == 'GET':
+            body = self.fixtures.load('ipv46.json')
+        else:
+            raise AssertionError('Unsupported method')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
 
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message