]>
git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.dnsdist/test_Console.py
4 from socket
import error
as SocketError
5 from dnsdisttests
import DNSDistTest
7 class TestConsoleAllowed(DNSDistTest
):
9 _consoleKey
= DNSDistTest
.generateConsoleKey()
10 _consoleKeyB64
= base64
.b64encode(_consoleKey
).decode('ascii')
12 _config_params
= ['_consoleKeyB64', '_consolePort', '_testServerPort']
13 _config_template
= """
15 controlSocket("127.0.0.1:%s")
16 newServer{address="127.0.0.1:%d"}
19 def testConsoleAllowed(self
):
23 version
= self
.sendConsoleCommand('showVersion()')
24 self
.assertTrue(version
.startswith('dnsdist '))
26 class TestConsoleNotAllowed(DNSDistTest
):
28 _consoleKey
= DNSDistTest
.generateConsoleKey()
29 _consoleKeyB64
= base64
.b64encode(_consoleKey
).decode('ascii')
31 _config_params
= ['_consoleKeyB64', '_consolePort', '_testServerPort']
32 _config_template
= """
34 controlSocket("127.0.0.1:%s")
35 setConsoleACL({'192.0.2.1'})
36 newServer{address="127.0.0.1:%d"}
39 def testConsoleAllowed(self
):
41 Console: Not allowed by the ACL
43 self
.assertRaises(SocketError
, self
.sendConsoleCommand
, 'showVersion()')
45 class TestConsoleNoKey(DNSDistTest
):
47 _consoleKey
= DNSDistTest
.generateConsoleKey()
48 _consoleKeyB64
= base64
.b64encode(_consoleKey
).decode('ascii')
50 _config_params
= ['_consolePort', '_testServerPort']
51 _config_template
= """
52 controlSocket("127.0.0.1:%s")
53 newServer{address="127.0.0.1:%d"}
56 def testConsoleAllowed(self
):
58 Console: No key, the connection should not be allowed
60 self
.assertRaises(SocketError
, self
.sendConsoleCommand
, 'showVersion()')