You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2020/11/01 20:54:45 UTC

[libcloud] 06/06: Add additional test case and assertions.

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit d9c1701b856b93d875599523158b3d2273f6f762
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:52:42 2020 +0100

    Add additional test case and assertions.
---
 .../fixtures/cloudflare/records_POST_sshfp.json    | 24 +++++++++++++++++
 libcloud/test/dns/test_cloudflare.py               | 30 ++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json b/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json
new file mode 100644
index 0000000..a1eaaf6
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json
@@ -0,0 +1,24 @@
+{
+  "result": {
+    "id": "200",
+    "type": "SSHFP",
+    "name": "test_sshfp.example.com",
+    "content": "2 1 ABCDEF12345",
+    "proxiable": true,
+    "proxied": true,
+    "ttl": 1,
+    "locked": false,
+    "zone_id": "1234",
+    "zone_name": "example.com",
+    "modified_on": "2018-12-22T21:28:00.801892Z",
+    "created_on": "2018-12-22T21:28:00.801892Z",
+    "meta": {
+      "auto_added": false,
+      "managed_by_apps": false,
+      "managed_by_argo_tunnel": false
+    }
+  },
+  "success": true,
+  "errors": [],
+  "messages": []
+}
diff --git a/libcloud/test/dns/test_cloudflare.py b/libcloud/test/dns/test_cloudflare.py
index e851be8..125edf2 100644
--- a/libcloud/test/dns/test_cloudflare.py
+++ b/libcloud/test/dns/test_cloudflare.py
@@ -137,6 +137,18 @@ class CloudFlareDNSDriverTestCase(unittest.TestCase):
         self.assertEqual(record.type, 'A')
         self.assertEqual(record.data, '127.0.0.3')
 
+    def test_create_record_SSHFP_record_type(self):
+        zone = self.driver.list_zones()[0]
+
+        CloudFlareMockHttp.type = 'sshfp_record_type'
+        record = self.driver.create_record(name='test_sshfp', zone=zone,
+                                           type=RecordType.SSHFP,
+                                           data='2 1 ABCDEF12345')
+        self.assertEqual(record.id, '200')
+        self.assertEqual(record.name, 'test_sshfp')
+        self.assertEqual(record.type, 'SSHFP')
+        self.assertEqual(record.data, '2 1 ABCDEF12345')
+
     def test_create_record_CAA_record_type(self):
         zone = self.driver.list_zones()[0]
 
@@ -353,6 +365,24 @@ class CloudFlareMockHttp(MockHttp, unittest.TestCase):
 
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _client_v4_zones_1234_dns_records_sshfp_record_type(self, method, url, body, headers):
+        if method not in ['POST']:
+            raise AssertionError('Unsupported method: %s' % (method))
+
+        url = urlparse.urlparse(url)
+        # Verify record data has been correctly normalized
+        body = json.loads(body)
+        expected_data = {
+            "algorithm": "2",
+            "type": "1",
+            "fingerprint": "ABCDEF12345"
+        }
+        self.assertEqual(body['data'], expected_data)
+
+        body = self.fixtures.load('records_{}_sshfp.json'.format(method))
+
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _client_v4_zones_1234_dns_records_error_chain_error(self, method, url, body, headers):
         if method not in ['POST']:
             raise AssertionError('Unsupported method: %s' % (method))