]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.api/test_Cache.py
Make sure we can install unsigned packages.
[thirdparty/pdns.git] / regression-tests.api / test_Cache.py
CommitLineData
d19c22a1 1from test_helper import ApiTestCase, is_auth, is_recursor, sdig
92144233 2import unittest
c0f6a1da
CH
3
4
5class Servers(ApiTestCase):
6
7 def test_flush(self):
8 r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=example.org."))
9 self.assert_success_json(r)
10 data = r.json()
11 self.assertIn('count', data)
12
92144233 13 @unittest.skipIf(not is_recursor(), "Not applicable")
d19c22a1
CHB
14 def test_flush_count(self):
15 sdig("ns1.example.com", 'A')
16 r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=ns1.example.com."))
17 self.assert_success_json(r)
18 data = r.json()
19 self.assertIn('count', data)
20 self.assertEquals(1, data['count'])
21
92144233 22 @unittest.skipIf(not is_recursor(), "Not applicable")
d19c22a1
CHB
23 def test_flush_subtree(self):
24 sdig("ns1.example.com", 'A')
25 sdig("ns2.example.com", 'A')
26 r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=example.com.&subtree=false"))
27 self.assert_success_json(r)
28 data = r.json()
29 self.assertIn('count', data)
30 self.assertEquals(1, data['count'])
31 r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=example.com.&subtree=true"))
32 self.assert_success_json(r)
33 data = r.json()
34 self.assertIn('count', data)
35 self.assertEquals(2, data['count'])
36
c0f6a1da
CH
37 def test_flush_root(self):
38 r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=."))
39 self.assert_success_json(r)
40 data = r.json()
41 self.assertIn('count', data)
42 self.assertEqual(data['result'], 'Flushed cache.')
43
44 def test_flush_no_domain(self):
45 r = self.session.put(
46 self.url("/api/v1/servers/localhost/cache/flush"))
47 self.assertEquals(r.status_code, 422)
48
49 def test_flush_unqualified(self):
50 r = self.session.put(
51 self.url("/api/v1/servers/localhost/cache/flush?domain=bar"))
52 self.assertEquals(r.status_code, 422)