]>
git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.api/test_RecursorConfig.py
3 from test_helper
import ApiTestCase
, is_recursor
6 @unittest.skipIf(not is_recursor(), "Only applicable to recursors")
7 class RecursorConfig(ApiTestCase
):
9 def test_config_allow_from_get(self
):
10 r
= self
.session
.get(self
.url("/api/v1/servers/localhost/config/allow-from"))
11 self
.assert_success_json(r
)
13 def test_config_allow_from_replace(self
):
14 payload
= {'value': ["127.0.0.1"]}
16 self
.url("/api/v1/servers/localhost/config/allow-from"),
17 data
=json
.dumps(payload
),
18 headers
={'content-type': 'application/json'})
19 self
.assert_success_json(r
)
21 self
.assertIn("value", data
)
22 self
.assertEquals(len(data
["value"]), 1)
23 self
.assertEquals("127.0.0.1/32", data
["value"][0])
25 def test_config_allow_from_replace_error(self
):
26 """Test the error case, should return 422."""
27 payload
= {'value': ["abcdefgh"]}
29 self
.url("/api/v1/servers/localhost/config/allow-from"),
30 data
=json
.dumps(payload
),
31 headers
={'content-type': 'application/json'})
32 self
.assertEquals(r
.status_code
, 422)
34 self
.assertIn('Unable to convert', data
['error'])