Skip to content

Commit 8272cff

Browse files
committed
Merge remote-tracking branch 'origin/main' into utf8_support
2 parents e099db9 + 4153baa commit 8272cff

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Split long TXT values using chunked_value before writing
44
- Correctly handle utf-8 names and zones by writing out idna encoded values and
55
using idna encoded filenames
6+
- When writing RFC2317 zones, convert "/" to "-" in the filename.
67

78
## v0.0.7 - 2025-01-17 - Back to the base
89

octodns_bind/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ def _apply(self, plan):
278278
longest_name = self._longest_name(records)
279279

280280
name = desired.name
281-
filename = join(self.directory, f'{name[:-1]}{self.file_extension}')
281+
filename = join(
282+
self.directory,
283+
f'{name[:-1].replace("/", "-")}{self.file_extension}',
284+
)
282285
with open(filename, 'w') as fh:
283286
fh.write(f'$ORIGIN {name}\n\n')
284287
utf8_name = desired.decoded_name

tests/test_provider_octodns_bind.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,60 @@ def test_utf8(self, serial_mock):
395395
fh.read(),
396396
)
397397

398+
@patch("octodns_bind.ZoneFileProvider._serial")
399+
def test_apply_rfc2317(self, serial_mock):
400+
serial_mock.side_effect = [424344, 454647, 484950]
401+
402+
with TemporaryDirectory() as td:
403+
provider = ZoneFileProvider(
404+
"target", td.dirname, hostmaster_email='webmaster@unit.tests.'
405+
)
406+
407+
# no root NS
408+
desired = Zone("0/25.10.10.10.in-addr.arpa.", [])
409+
410+
# populate as a target, shouldn't find anything, file wouldn't even
411+
# exist
412+
provider.populate(desired, target=True)
413+
self.assertEqual(0, len(desired.records))
414+
415+
ns_record = Record.new(
416+
desired,
417+
"",
418+
{"type": "NS", "ttl": 42, "value": "ns.unit.tests."},
419+
)
420+
desired.add_record(ns_record)
421+
422+
ptr = Record.new(
423+
desired,
424+
"10",
425+
{"type": "PTR", "ttl": 42, "value": "target.unit.tests."},
426+
)
427+
desired.add_record(ptr)
428+
429+
changes = [Create(ptr), Create(ns_record)]
430+
plan = Plan(None, desired, changes, True)
431+
provider._apply(plan)
432+
433+
with open(join(td.dirname, "0-25.10.10.10.in-addr.arpa.")) as fh:
434+
self.assertEqual(
435+
"""$ORIGIN 0/25.10.10.10.in-addr.arpa.
436+
437+
@ 3600 IN SOA ns.unit.tests. webmaster.unit.tests. (
438+
424344 ; Serial
439+
3600 ; Refresh
440+
600 ; Retry
441+
604800 ; Expire
442+
3600 ; NXDOMAIN ttl
443+
)
444+
445+
; Name: 0/25.10.10.10.in-addr.arpa.
446+
@ 42 IN NS ns.unit.tests.
447+
10 42 IN PTR target.unit.tests.
448+
""",
449+
fh.read(),
450+
)
451+
398452
def test_primary_nameserver(self):
399453
# no records (thus no root NS records) we get the placeholder
400454
self.assertEqual(

0 commit comments

Comments
 (0)