]>
git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.recursor-dnssec/test_API.py
4 from recursortests
import RecursorTest
6 class APIRecursorTest(RecursorTest
):
11 # we don't need all the auth stuff
15 confdir
= os
.path
.join('configs', cls
._confdir
)
16 cls
.createConfigDir(confdir
)
18 cls
.generateRecursorConfig(confdir
)
19 cls
.startRecursor(confdir
, cls
._recursorPort
)
22 def tearDownClass(cls
):
23 cls
.tearDownRecursor()
25 class APIAllowedRecursorTest(APIRecursorTest
):
29 _wsPassword
= 'secretpassword'
30 _apiKey
= 'secretapikey'
32 _config_template
= """
35 webserver-address=127.0.0.1
37 webserver-allow-from=127.0.0.1
39 """ % (_wsPort
, _wsPassword
, _apiKey
)
42 headers
= {'x-api-key': self
._apiKey
}
43 url
= 'http://127.0.0.1:' + str(self
._wsPort
) + '/api/v1/servers/localhost/statistics'
44 r
= requests
.get(url
, headers
=headers
, timeout
=self
._wsTimeout
)
46 self
.assertEquals(r
.status_code
, 200)
47 self
.assertTrue(r
.json())
49 class APIDeniedRecursorTest(APIRecursorTest
):
53 _wsPassword
= 'secretpassword'
54 _apiKey
= 'secretapikey'
56 _config_template
= """
59 webserver-address=127.0.0.1
61 webserver-allow-from=192.0.2.1
63 """ % (_wsPort
, _wsPassword
, _apiKey
)
66 headers
= {'x-api-key': self
._apiKey
}
67 url
= 'http://127.0.0.1:' + str(self
._wsPort
) + '/api/v1/servers/localhost/statistics'
69 r
= requests
.get(url
, headers
=headers
, timeout
=self
._wsTimeout
)
70 self
.assertTrue(False)
71 except requests
.exceptions
.ConnectionError
as exp
: