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/12/06 13:02:45 UTC

[libcloud] 02/03: Add a regression test case for it.

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 d3dec976c580f6612235907e46f4f9cbf72c7416
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Dec 6 14:01:47 2020 +0100

    Add a regression test case for it.
---
 libcloud/test/dns/test_auroradns.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libcloud/test/dns/test_auroradns.py b/libcloud/test/dns/test_auroradns.py
index 56ef20c..205c544 100644
--- a/libcloud/test/dns/test_auroradns.py
+++ b/libcloud/test/dns/test_auroradns.py
@@ -15,6 +15,7 @@
 import sys
 import json
 
+from libcloud.common.types import ProviderError
 from libcloud.dns.drivers.auroradns import AuroraDNSDriver
 from libcloud.dns.drivers.auroradns import AuroraDNSHealthCheckType
 from libcloud.dns.types import RecordType
@@ -37,6 +38,15 @@ class AuroraDNSDriverTests(LibcloudTestCase):
         AuroraDNSDriverMockHttp.type = None
         self.driver = AuroraDNSDriver(*DNS_PARAMS_AURORADNS)
 
+    def test_403_status_code(self):
+        AuroraDNSDriverMockHttp.type = "HTTP_FORBIDDEN"
+
+        with self.assertRaises(ProviderError) as ctx:
+            self.driver.list_zones()
+
+        self.assertEqual(ctx.exception.value, "Authorization failed")
+        self.assertEqual(ctx.exception.http_code, 403)
+
     def test_merge_extra_data(self):
         rdata = {
             'name': 'localhost',
@@ -262,6 +272,10 @@ class AuroraDNSDriverMockHttp(MockHttp):
             body = self.fixtures.load('zone_list.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _zones_HTTP_FORBIDDEN(self, method, url, body, headers):
+        body = "{}"
+        return (httplib.FORBIDDEN, body, {}, httplib.responses[httplib.FORBIDDEN])
+
     def _zones_example_com(self, method, url, body, headers):
         body = None
         if method == 'GET':