]>
git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.api/test_Cache.py
1 from test_helper
import ApiTestCase
, is_auth
, is_recursor
, sdig
5 class Servers(ApiTestCase
):
8 r
= self
.session
.put(self
.url("/api/v1/servers/localhost/cache/flush?domain=example.org."))
9 self
.assert_success_json(r
)
11 self
.assertIn('count', data
)
13 @unittest.skipIf(not is_recursor(), "Not applicable")
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
)
19 self
.assertIn('count', data
)
20 self
.assertEquals(1, data
['count'])
22 @unittest.skipIf(not is_recursor(), "Not applicable")
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
)
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
)
34 self
.assertIn('count', data
)
35 self
.assertEquals(2, data
['count'])
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
)
41 self
.assertIn('count', data
)
42 self
.assertEqual(data
['result'], 'Flushed cache.')
44 def test_flush_no_domain(self
):
46 self
.url("/api/v1/servers/localhost/cache/flush"))
47 self
.assertEquals(r
.status_code
, 422)
49 def test_flush_unqualified(self
):
51 self
.url("/api/v1/servers/localhost/cache/flush?domain=bar"))
52 self
.assertEquals(r
.status_code
, 422)