]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.auth-py/test_SVCB.py
dnsdist: Properly increase the HTTP connections counter w/ nghttp2
[thirdparty/pdns.git] / regression-tests.auth-py / test_SVCB.py
CommitLineData
2e69049f
PL
1from authtests import AuthTest
2import dns
3
4
5class TestSVCBRecords(AuthTest):
6 _config_template = """
7launch=bind
cb5b662f 8svc-autohints
2e69049f
PL
9"""
10
11 _zones = {
12 'example.org': """
13example.org. 3600 IN SOA {soa}
14example.org. 3600 IN NS ns1.example.org.
15example.org. 3600 IN NS ns2.example.org.
16
17example.org. 3600 IN HTTPS 0 www.example.org.
18www.example.org. 3600 IN HTTPS 1 . ipv4hint=auto ipv6hint=auto
19www.example.org. 3600 IN A 192.0.2.80
20www.example.org. 3600 IN AAAA 2001:db8::80
21
22no-a.example.org. 3600 IN HTTPS 1 . ipv4hint=auto ipv6hint=auto
23no-a.example.org. 3600 IN AAAA 2001:db8::81
24
25no-aaaa.example.org. 3600 IN HTTPS 1 . ipv4hint=auto ipv6hint=auto
26no-aaaa.example.org. 3600 IN A 192.0.2.81
607d1296
PL
27
28auto-a.example.org. 3600 IN HTTPS 1 . ipv4hint=auto ipv6hint=2001:db8::81
29auto-a.example.org. 3600 IN A 192.0.2.80
30auto-a.example.org. 3600 IN AAAA 2001:db8::80
31
32no-auto.example.org. 3600 IN HTTPS 1 . ipv4hint=192.0.2.81 ipv6hint=2001:db8::81
33no-auto.example.org. 3600 IN A 192.0.2.80
34no-auto.example.org. 3600 IN AAAA 2001:db8::80
35
36auto-aaaa.example.org. 3600 IN HTTPS 1 . ipv4hint=192.0.2.81 ipv6hint=auto
37auto-aaaa.example.org. 3600 IN A 192.0.2.80
38auto-aaaa.example.org. 3600 IN AAAA 2001:db8::80
2e69049f
PL
39 """,
40 }
41
42 def testWithoutAlias(self):
43 query = dns.message.make_query('www.example.org', 'HTTPS')
44 res = self.sendUDPQuery(query)
45 expected_ans = dns.rrset.from_text(
46 'www.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
47 '1 . ipv4hint="192.0.2.80" ipv6hint="2001:db8::80"'
48 )
49 self.assertRcodeEqual(res, dns.rcode.NOERROR)
50 self.assertRRsetInAnswer(res, expected_ans)
51 self.assertEqual(len(res.additional), 2)
52
53 def testWithAlias(self):
54 """
55 Ensure additional processing happens for HTTPS AliasMode
56 """
57 query = dns.message.make_query('example.org', 'HTTPS')
58 res = self.sendUDPQuery(query)
59 expected_addl = dns.rrset.from_text(
60 'www.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
61 '1 . ipv4hint="192.0.2.80" ipv6hint="2001:db8::80"'
62 )
63 expected_ans = dns.rrset.from_text(
64 'example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
65 '0 www.example.org'
66 )
67 print(res.answer)
68 self.assertRcodeEqual(res, dns.rcode.NOERROR)
69 self.assertRRsetInAnswer(res, expected_ans)
70 self.assertRRsetInAdditional(res, expected_addl)
71 self.assertEqual(len(res.additional), 3)
72
73 def testWithMissingA(self):
74 """
75 Ensure PowerDNS removes the ipv4hint if there's no A record
76 """
77 query = dns.message.make_query('no-a.example.org', 'HTTPS')
78 res = self.sendUDPQuery(query)
79 expected_ans = dns.rrset.from_text(
80 'no-a.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
81 '1 . ipv6hint="2001:db8::81"'
82 )
83 self.assertRcodeEqual(res, dns.rcode.NOERROR)
84 self.assertRRsetInAnswer(res, expected_ans)
85 self.assertEqual(len(res.additional), 1)
86
87 def testWithMissingAAAA(self):
88 """
89 Ensure PowerDNS removes the ipv6hint if there's no AAAA record
90 """
91 query = dns.message.make_query('no-aaaa.example.org', 'HTTPS')
92 res = self.sendUDPQuery(query)
93 expected_ans = dns.rrset.from_text(
94 'no-aaaa.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
95 '1 . ipv4hint="192.0.2.81"'
96 )
97 self.assertRcodeEqual(res, dns.rcode.NOERROR)
98 self.assertRRsetInAnswer(res, expected_ans)
99 self.assertEqual(len(res.additional), 1)
607d1296
PL
100
101 def testNoAuto(self):
102 """
103 Ensure we send the actual hints, not generated ones
104 """
105 query = dns.message.make_query('no-auto.example.org', 'HTTPS')
106 res = self.sendUDPQuery(query)
107 expected_ans = dns.rrset.from_text(
108 'no-auto.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
109 '1 . ipv4hint="192.0.2.81" ipv6hint="2001:db8::81"'
110 )
111 self.assertRcodeEqual(res, dns.rcode.NOERROR)
112 print(res)
113 self.assertRRsetInAnswer(res, expected_ans)
114 self.assertEqual(len(res.additional), 2)
115
116 def testAutoA(self):
117 """
118 Ensure we send a generated A hint, but keep the existing AAAA hint
119 """
120 query = dns.message.make_query('auto-a.example.org', 'HTTPS')
121 res = self.sendUDPQuery(query)
122 expected_ans = dns.rrset.from_text(
123 'auto-a.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
124 '1 . ipv4hint="192.0.2.80" ipv6hint="2001:db8::81"'
125 )
126 self.assertRcodeEqual(res, dns.rcode.NOERROR)
127 print(res)
128 self.assertRRsetInAnswer(res, expected_ans)
129 self.assertEqual(len(res.additional), 2)
130
131 def testAutoAAAA(self):
132 """
133 Ensure we send a generated AAAA hint, but keep the existing A hint
134 """
135 query = dns.message.make_query('auto-aaaa.example.org', 'HTTPS')
136 res = self.sendUDPQuery(query)
137 expected_ans = dns.rrset.from_text(
138 'auto-aaaa.example.org.', 3600, dns.rdataclass.IN, 'HTTPS',
139 '1 . ipv4hint="192.0.2.81" ipv6hint="2001:db8::80"'
140 )
141 self.assertRcodeEqual(res, dns.rcode.NOERROR)
142 print(res)
143 self.assertRRsetInAnswer(res, expected_ans)
144 self.assertEqual(len(res.additional), 2)