From: Otto Moerbeek Date: Thu, 5 May 2022 08:19:47 +0000 (+0200) Subject: Add tests for empty allow-from and allow-notify-from case X-Git-Tag: auth-4.8.0-alpha0~98^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa1ae26f5c174d6fe237dc0ed9d08043518648f;p=thirdparty%2Fpdns.git Add tests for empty allow-from and allow-notify-from case --- diff --git a/regression-tests.api/test_RecursorConfig.py b/regression-tests.api/test_RecursorConfig.py index 774d366ad0..2422971121 100644 --- a/regression-tests.api/test_RecursorConfig.py +++ b/regression-tests.api/test_RecursorConfig.py @@ -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"]}