]>
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
.assertEquals("127.0.0.1/32", data
["value"][0])
23 def test_config_allow_from_replace_error(self
):
24 """Test the error case, should return 422."""
25 payload
= {'value': ["abcdefgh"]}
27 self
.url("/api/v1/servers/localhost/config/allow-from"),
28 data
=json
.dumps(payload
),
29 headers
={'content-type': 'application/json'})
30 self
.assertEquals(r
.status_code
, 422)
32 self
.assertIn('Unable to convert', data
['error'])