]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.api/test_RecursorConfig.py
Merge pull request #1418 from mind04/bind
[thirdparty/pdns.git] / regression-tests.api / test_RecursorConfig.py
CommitLineData
41942bb3
CH
1import json
2import requests
3import unittest
4from test_helper import ApiTestCase, isRecursor
5
6
7@unittest.skipIf(not isRecursor(), "Only applicable to recursors")
8class RecursorConfig(ApiTestCase):
9
10 def test_ConfigAllowFromGet(self):
11 r = self.session.get(self.url("/servers/localhost/config/allow-from"))
12 self.assertSuccessJson(r)
13
14 def test_ConfigAllowFromReplace(self):
bd0320fe 15 payload = {'value': ["127.0.0.1"]}
41942bb3
CH
16 r = self.session.put(
17 self.url("/servers/localhost/config/allow-from"),
18 data=json.dumps(payload),
19 headers={'content-type': 'application/json'})
20 self.assertSuccessJson(r)
21 data = r.json()
bd0320fe 22 self.assertEquals("127.0.0.1/32", data["value"][0])
35f26cc5
CH
23
24 def test_ConfigAllowFromReplaceError(self):
25 """Test the error case, should return 422."""
26 payload = {'value': ["abcdefgh"]}
27 r = self.session.put(
28 self.url("/servers/localhost/config/allow-from"),
29 data=json.dumps(payload),
30 headers={'content-type': 'application/json'})
31 self.assertEquals(r.status_code, 422)
32 data = r.json()
faa0f891 33 self.assertIn('Unable to convert', data['error'])