diff --git a/CHANGELOG.md b/CHANGELOG.md index a483afa..cb43eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v1.0.0 - 2024-??-?? - ??? + +### Notedworthy Changes: + +* `SPF` record support removed, records should be migrated to `TXT` before + upgrading. +* DS properties "algorithm", "flags", "public_key", and "protocol" support + removed +* Requires octoDNS >= 1.5.0 + ## v0.0.7 - 2024-08-28 - Less picky about names * Support for fully managing zones with special characters in their names, e.g. diff --git a/octodns_powerdns/__init__.py b/octodns_powerdns/__init__.py index 3110eb4..0b29145 100644 --- a/octodns_powerdns/__init__.py +++ b/octodns_powerdns/__init__.py @@ -12,7 +12,6 @@ from octodns.provider import ProviderException from octodns.provider.base import BaseProvider from octodns.record import Record -from octodns.record.ds import DsValue try: # pragma: no cover from octodns.record.https import HttpsValue @@ -65,7 +64,6 @@ class PowerDnsBaseProvider(BaseProvider): 'NAPTR', 'NS', 'PTR', - 'SPF', 'SSHFP', 'SRV', 'TLSA', @@ -89,10 +87,6 @@ class PowerDnsBaseProvider(BaseProvider): } POWERDNS_LEGACY_MODES_OF_OPERATION = {'native', 'master', 'slave'} - # TODO: once we require octoDNS 2.0 this backwards compatibility code can go - # away - OLD_DS_FIELDS = hasattr(DsValue, 'flags') - def __init__( self, id, @@ -213,20 +207,12 @@ def _data_for_DS(self, rrset): (key_tag, algorithm, digest_type, digest) = record['content'].split( ' ', 3 ) - if self.OLD_DS_FIELDS: - value = { - 'flags': key_tag, - 'protocol': algorithm, - 'algorithm': digest_type, - 'public_key': digest, - } - else: - value = { - 'key_tag': key_tag, - 'algorithm': algorithm, - 'digest_type': digest_type, - 'digest': digest, - } + value = { + 'key_tag': key_tag, + 'algorithm': algorithm, + 'digest_type': digest_type, + 'digest': digest, + } values.append(value) return {'type': rrset['type'], 'values': values, 'ttl': rrset['ttl']} @@ -258,7 +244,6 @@ def _data_for_quoted(self, rrset): 'ttl': rrset['ttl'], } - _data_for_SPF = _data_for_quoted _data_for_TXT = _data_for_quoted def _data_for_LOC(self, rrset): @@ -544,12 +529,7 @@ def _records_for_TLSA(self, record): def _records_for_DS(self, record): data = [] for v in record.values: - if self.OLD_DS_FIELDS: - content = f'{v.flags} {v.protocol} {v.algorithm} {v.public_key}' - else: - content = ( - f'{v.key_tag} {v.algorithm} {v.digest_type} {v.digest}' - ) + content = f'{v.key_tag} {v.algorithm} {v.digest_type} {v.digest}' data.append({'content': content, 'disabled': False}) return data, record._type @@ -570,7 +550,6 @@ def _records_for_quoted(self, record): {'content': f'"{v}"', 'disabled': False} for v in record.values ], record._type - _records_for_SPF = _records_for_quoted _records_for_TXT = _records_for_quoted def _records_for_LOC(self, record): diff --git a/pyproject.toml b/pyproject.toml index a0c748b..73fd2bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,5 @@ sections="FUTURE,STDLIB,THIRDPARTY,OCTODNS,FIRSTPARTY,LOCALFOLDER" [tool.pytest.ini_options] filterwarnings = [ 'error', - # TODO: remove once octodns 2.0 has been released - 'ignore:.*DEPRECATED.*2.0', ] pythonpath = "." diff --git a/setup.py b/setup.py index 9108b0a..579300b 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ def version(): ), 'test': tests_require, }, - install_requires=('octodns>=0.9.17', 'requests>=2.26.0'), + install_requires=('octodns>=1.5.0', 'requests>=2.26.0'), license='MIT', long_description=long_description, long_description_content_type='text/markdown', diff --git a/tests/config/unit.tests.yaml b/tests/config/unit.tests.yaml index 8da6463..bd4884b 100644 --- a/tests/config/unit.tests.yaml +++ b/tests/config/unit.tests.yaml @@ -1,19 +1,6 @@ --- ? '' -: - geo: - AF: - - 2.2.3.4 - - 2.2.3.5 - AS-JP: - - 3.2.3.4 - - 3.2.3.5 - NA-US: - - 4.2.3.4 - - 4.2.3.5 - NA-US-CA: - - 5.2.3.4 - - 5.2.3.5 - ttl: 300 +: - ttl: 300 type: A values: - 1.2.3.4 @@ -39,10 +26,10 @@ value: ca.unit.tests - type: 'DS' values: - - algorithm: 2 - flags: 2371 - protocol: 13 - public_key: 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + - algorithm: 13 + digest: 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + digest_type: 2 + key_tag: 2371 _853._tcp: type: TLSA values: @@ -180,10 +167,6 @@ ptr: ttl: 300 type: PTR values: [foo.bar.com.] -spf: - ttl: 600 - type: SPF - value: v=spf1 ip4:192.168.0.1/16-all sub: - type: 'NS' values: @@ -191,10 +174,10 @@ sub: - 7.2.3.4. - type: 'DS' values: - - algorithm: 2 - flags: 12345 - protocol: 13 - public_key: 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + - algorithm: 13 + digest: 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + digest_type: 2 + key_tag: 12345 svcb: type: SVCB values: diff --git a/tests/fixtures/powerdns-full-data.json b/tests/fixtures/powerdns-full-data.json index 5cb56e9..a712e47 100644 --- a/tests/fixtures/powerdns-full-data.json +++ b/tests/fixtures/powerdns-full-data.json @@ -163,18 +163,6 @@ "ttl": 300, "type": "PTR" }, - { - "comments": [], - "name": "spf.unit.tests.", - "records": [ - { - "content": "\"v=spf1 ip4:192.168.0.1/16-all\"", - "disabled": false - } - ], - "ttl": 600, - "type": "SPF" - }, { "comments": [], "name": "cname.unit.tests.", diff --git a/tests/test_octodns_provider_powerdns.py b/tests/test_octodns_provider_powerdns.py index e66506e..19be814 100644 --- a/tests/test_octodns_provider_powerdns.py +++ b/tests/test_octodns_provider_powerdns.py @@ -295,7 +295,7 @@ def test_provider(self): ) source.populate(expected) expected_n = len(expected.records) - 4 - self.assertEqual(25, expected_n) + self.assertEqual(24, expected_n) # No diffs == no changes with requests_mock() as mock: @@ -303,7 +303,7 @@ def test_provider(self): zone = Zone('unit.tests.', []) provider.populate(zone) - self.assertEqual(25, len(zone.records)) + self.assertEqual(24, len(zone.records)) changes = expected.changes(zone, provider) self.assertEqual(0, len(changes)) @@ -400,7 +400,7 @@ def test_small_change(self): 'test', join(dirname(__file__), 'config'), supports_root_ns=False ) source.populate(expected) - self.assertEqual(29, len(expected.records)) + self.assertEqual(28, len(expected.records)) # A small change to a single record with requests_mock() as mock: @@ -417,7 +417,7 @@ def test_small_change(self): missing = Zone(expected.name, []) # Find and delete the SPF record for record in expected.records: - if record._type != 'SPF': + if record._type != 'SVCB': missing.add_record(record) def assert_delete_callback(request, context): @@ -427,14 +427,18 @@ def assert_delete_callback(request, context): { 'records': [ { - 'content': '"v=spf1 ip4:192.168.0.1/16-all"', + 'content': '1 www.unit.tests.', 'disabled': False, - } + }, + { + 'content': '2 backups.unit.tests.', + 'disabled': False, + }, ], 'changetype': 'DELETE', - 'type': 'SPF', - 'name': 'spf.unit.tests.', - 'ttl': 600, + 'type': 'SVCB', + 'name': 'svcb.unit.tests.', + 'ttl': 3600, } ] }, @@ -478,7 +482,7 @@ def test_notify(self): missing = Zone(expected.name, []) # Find and delete the SPF record for record in expected.records: - if record._type != 'SPF': + if record._type != 'SVCB': missing.add_record(record) plan = provider.plan(missing) @@ -610,21 +614,7 @@ def test_data_for_DS_compat(self): 'type': 'DS', } - # old - provider.OLD_DS_FIELDS = True - value = provider._data_for_DS(rrset)['values'][0] - self.assertEqual( - { - 'algorithm': 'three', - 'flags': 'one', - 'protocol': 'two', - 'public_key': 'four', - }, - value, - ) - # new - provider.OLD_DS_FIELDS = False value = provider._data_for_DS(rrset)['values'][0] self.assertEqual( { @@ -645,14 +635,6 @@ class DummyRecord: def __init__(self, value): self.values = [value] - class OldFields: - flags = 'flags' - protocol = 'protocol' - algorithm = 'algorithm' - public_key = 'public_key' - - old_fields = OldFields() - class NewFields: key_tag = 'key_tag' algorithm = 'algorithm' @@ -661,21 +643,7 @@ class NewFields: new_fields = NewFields() - # old - provider.OLD_DS_FIELDS = True - data = provider._records_for_DS(DummyRecord(old_fields))[0] - self.assertEqual( - [ - { - 'content': 'flags protocol algorithm public_key', - 'disabled': False, - } - ], - data, - ) - # new - provider.OLD_DS_FIELDS = False data = provider._records_for_DS(DummyRecord(new_fields))[0] self.assertEqual( [