From 53f3640094e97d3b3dba460ba944e84192193d2b Mon Sep 17 00:00:00 2001 From: Pawel Kowalik Date: Wed, 1 Apr 2026 00:10:30 +0200 Subject: [PATCH] BUGFIX: Same record not recognised, if existing record has _dc entry Fixes #36 --- domainconnectzone/DomainConnectImpl.py | 3 +-- test/harness_utils.py | 6 ++---- .../process_records_tests.yaml | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/domainconnectzone/DomainConnectImpl.py b/domainconnectzone/DomainConnectImpl.py index 8ff2061..9ade03b 100644 --- a/domainconnectzone/DomainConnectImpl.py +++ b/domainconnectzone/DomainConnectImpl.py @@ -629,8 +629,6 @@ def check_conflict_with_self(new_record, new_records): if error: raise InvalidData(f"Template record {new_record['type']} {new_record['name']} conflicts with other tempate record {zone_record['type']} {zone_record['name']}") -_RECORD_COMPARE_SKIP = {'_delete', '_replace', 'ttl'} - _CORE_TYPES = {'A', 'AAAA', 'CNAME', 'MX', 'NS', 'SRV', 'TXT', 'SPFM', 'REDIR301', 'REDIR302'} @@ -687,6 +685,7 @@ def _normalise_record(record): result[k] = v return result +_RECORD_COMPARE_SKIP = {'_delete', '_replace', 'ttl', "_dc"} def _find_identical_zone_record(new_record, zone_records): """Return the zone record identical to new_record, or None. diff --git a/test/harness_utils.py b/test/harness_utils.py index b70af11..b335953 100644 --- a/test/harness_utils.py +++ b/test/harness_utils.py @@ -45,8 +45,6 @@ "priority", "protocol", "service", "weight", "port", "_dc", } -_DC_KEYS = {"id", "providerId", "serviceId", "host", "essential"} - # --------------------------------------------------------------------------- # Key-validation helpers @@ -63,8 +61,8 @@ def check_keys(mapping, allowed, context): def validate_zone_record(record, context): """Validate a single zone record (input or expected output).""" check_keys(record, _ZONE_RECORD_KEYS, context) - if "_dc" in record: - check_keys(record["_dc"], _DC_KEYS, "_dc of {}".format(context)) + if "_dc" in record and not isinstance(record["_dc"], object): + raise ValueError("_dc not an object: {}".format(record["_dc"])) def validate_common_case(case, inp, ctx, input_keys): diff --git a/test/test_definitions/process_records_tests.yaml b/test/test_definitions/process_records_tests.yaml index 2afd012..490e8c1 100644 --- a/test/test_definitions/process_records_tests.yaml +++ b/test/test_definitions/process_records_tests.yaml @@ -4109,6 +4109,24 @@ tests: records: - {type: TXT, name: "@", data: '"Hello World"', ttl: 1800} + - id: duplicate_skip_txt_dc + description: "TXT: identical record already in zone is not added again (no conflict rule, existing has _dc)" + input: + zone_records: + - {data: 'Hello World', name: '@', ttl: 1800, type: 'TXT', _dc: {record_id: '74688294'}} + template_records: + - {type: TXT, host: "@", data: '%RANDOMTEXT%', ttl: 600} + domain: example.com + host: "" + params: { RANDOMTEXT: 'Hello World'} + expect: + new_count: 0 + delete_count: 0 + records: + - {data: 'Hello World', name: '@', ttl: 1800, type: 'TXT', _dc: {record_id: '74688294'}} + + + - id: duplicate_skip_txt_case_diff description: "TXT: identical record already in zone is not added again (no conflict rule, case diff)" input: