]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add tests for empty allow-from and allow-notify-from case
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 5 May 2022 08:19:47 +0000 (10:19 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 5 May 2022 08:19:47 +0000 (10:19 +0200)
regression-tests.api/test_RecursorConfig.py

index 774d366ad089249caf43bfa9d26c3e23c0a15797..242297112111323ed46508330fa0d811f1153b7e 100644 (file)
@@ -22,6 +22,17 @@ class RecursorAllowFromConfig(ApiTestCase):
         self.assertEqual(len(data["value"]), 1)
         self.assertEqual("127.0.0.1/32", data["value"][0])
 
+    def test_config_allow_from_replace_empty(self):
+        payload = {'value': []}
+        r = self.session.put(
+            self.url("/api/v1/servers/localhost/config/allow-from"),
+            data=json.dumps(payload),
+            headers={'content-type': 'application/json'})
+        self.assert_success_json(r)
+        data = r.json()
+        self.assertIn("value", data)
+        self.assertEqual(len(data["value"]), 0)
+
     def test_config_allow_from_replace_error(self):
         """Test the error case, should return 422."""
         payload = {'value': ["abcdefgh"]}
@@ -53,6 +64,17 @@ class RecursorAllowNotifyFromConfig(ApiTestCase):
         self.assertEqual(len(data["value"]), 1)
         self.assertEqual("127.0.0.1/32", data["value"][0])
 
+    def test_config_allow_notify_from_replace_empty(self):
+        payload = {'value': []}
+        r = self.session.put(
+            self.url("/api/v1/servers/localhost/config/allow-notify-from"),
+            data=json.dumps(payload),
+            headers={'content-type': 'application/json'})
+        self.assert_success_json(r)
+        data = r.json()
+        self.assertIn("value", data)
+        self.assertEqual(len(data["value"]), 0)
+
     def test_config_allow_notify_from_replace_error(self):
         """Test the error case, should return 422."""
         payload = {'value': ["abcdefgh"]}