]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.recursor-dnssec/test_basicNSEC3.py
Merge pull request #13927 from rgacogne/fix-fclose-warnings
[thirdparty/pdns.git] / regression-tests.recursor-dnssec / test_basicNSEC3.py
1 from __future__ import print_function
2 from basicDNSSEC import BasicDNSSEC
3 import os
4 import subprocess
5
6 class basicNSEC3(BasicDNSSEC):
7 __test__ = True
8 _confdir = 'basicNSEC3'
9
10 @classmethod
11 def secureZone(cls, confdir, zonename, key=None):
12 zone = '.' if zonename == 'ROOT' else zonename
13 if not key:
14 pdnsutilCmd = [os.environ['PDNSUTIL'],
15 '--config-dir=%s' % confdir,
16 'secure-zone',
17 zone]
18 else:
19 keyfile = os.path.join(confdir, 'dnssec.key')
20 with open(keyfile, 'w') as fdKeyfile:
21 fdKeyfile.write(key)
22
23 pdnsutilCmd = [os.environ['PDNSUTIL'],
24 '--config-dir=%s' % confdir,
25 'import-zone-key',
26 zone,
27 keyfile,
28 'active',
29 'ksk']
30
31 print(' '.join(pdnsutilCmd))
32 try:
33 subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
34 except subprocess.CalledProcessError as e:
35 raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))
36
37 params = "1 0 50 AABBCCDDEEFF112233"
38
39 if zone == "optout.example":
40 params = "1 1 50 AABBCCDDEEFF112233"
41
42 pdnsutilCmd = [os.environ['PDNSUTIL'],
43 '--config-dir=%s' % confdir,
44 'set-nsec3',
45 zone,
46 params]
47
48 print(' '.join(pdnsutilCmd))
49 try:
50 subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
51 except subprocess.CalledProcessError as e:
52 raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))