forked from PowerDNS/pdns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_RecursorConfig.py
More file actions
32 lines (27 loc) · 1.17 KB
/
test_RecursorConfig.py
File metadata and controls
32 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
import unittest
from test_helper import ApiTestCase, is_recursor
@unittest.skipIf(not is_recursor(), "Only applicable to recursors")
class RecursorConfig(ApiTestCase):
def test_config_allow_from_get(self):
r = self.session.get(self.url("/servers/localhost/config/allow-from"))
self.assert_success_json(r)
def test_config_allow_from_replace(self):
payload = {'value': ["127.0.0.1"]}
r = self.session.put(
self.url("/servers/localhost/config/allow-from"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assert_success_json(r)
data = r.json()
self.assertEquals("127.0.0.1/32", data["value"][0])
def test_config_allow_from_replace_error(self):
"""Test the error case, should return 422."""
payload = {'value': ["abcdefgh"]}
r = self.session.put(
self.url("/servers/localhost/config/allow-from"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEquals(r.status_code, 422)
data = r.json()
self.assertIn('Unable to convert', data['error'])