Repository navigation
Fix DNS driver API inconsistencies - #2066
aaron-sierra wants to merge 48 commits into
Conversation
0fe8ec0 to
46c0e4f
Compare
|
The latest batch of updates includes changes from |
46c0e4f to
fcaf113
Compare
|
The latest changes have been through |
micafer
left a comment
There was a problem hiding this comment.
Thanks for the extensive work on making the DNS driver APIs more consistent. The additional HTTP request assertions are particularly valuable.
I found an issue in the new Zone.prefix() implementation that should be addressed before merging.
The expression:
subname.rstrip(".").removesuffix(self.domain).rstrip(".")
removes the zone domain even when it is not preceded by a DNS label separator.
For example, with self.domain == "example.com", calling prefix("notexample.com") returns "not", even though notexample.com is not a hostname within the example.com zone.
Since Zone.hostname() and Zone.fqdn() depend on this method, the issue can silently produce incorrect DNS names.
I suggest checking for an exact domain match or the suffix "." + self.domain before stripping it, and adding regression tests for hostnames that merely share a textual suffix with the zone domain.
Additionally, this PR changes public-facing Record.id, Record.name, and Zone.domain semantics across multiple providers. As we are going to merge this to the new major version these compatibility changes will be explicitly documented and it is not majot issue.
|
Hi Miguel, Thanks for your review. In the example that you described regarding
Presumably all three of the |
|
I probably prefer to return |
I thought a bit on this and probably returning the full DNS name can be the best solution: as in the example |
|
I'm still checking this and I found two issues: Google Cloud DNS — get_record() uses a relative name in the API query. After parsing the normalized record ID, parts.name contains a relative name such as foo. However, the Cloud DNS API expects a fully qualified name such as foo.example.com. in the name query parameter. I believe this should use zone.fqdn(parts.name) instead. The corresponding test currently checks the endpoint URL but does not assert the query parameters. World Wide DNS — update_record() fails when extra=None. The new condition if "entry" in extra raises TypeError when the optional extra argument is omitted. Please guard against None and add a regression test covering an update without extra. |
You're right! I've added API parameter checking to |
I think we need to clarify what should happen when a hostname (unrooted) and an FQDN (rooted) are passed into these functions. In the following examples,
I think that I prefer raising an exception in the unrelated FQDN case, considering how #2065 notes inconsistent usage of |
Ok, so let's go in that direction. But we can create an specific exception (something like |
|
So please make this changes and merge the trunk branch. |
How's |
I'd like to omit this from the current merge request, if you agree. I've spent time trying to implement common/reusable function-call-level API test cases, but it needs review and refinement. I think this warrants a new issue.
|
The Zerigo DNS service was permanently shut down on April 30, 2017.
The DNSimple v1 API was shutdown on May 31, 2018:
https://blog.dnsimple.com/2018/03/api-v1-shutdown-notice/
The RcodeZero v1 API has been shutdown:
https://my.rcodezero.at/openapi/
Enable unit tests to verify HTTP requests they submit.
* Fix test_create_zone_success * Fix test_get_record_success
Include "ID" parameter when reseller_id is set:
https://www.worldwidedns.net/dns_api_protocol_modify_reseller.asp
The update_record() and delete_record() functions require a Record
instance in their respective argument lists to identify the DNS record
to manipulate. Record objects instantiated by this driver contain the
assocated "slot" ID within the .id field, so:
1. There is no need for the user to specify the "slot" ID via
.update_record(..., extra={"entry": ID}). However, since it was
previously required, an "entry" key will be accepted as long as it is
consistent with the Record instance.
2. There is no need for .delete_record() to search the Record's zone for
the "slot" ID of the Record.
The API key is automatically inserted into the request by the ZonomiConnection class.
The MockHttp function was defined, but the corresponding test was not.
Previously, the Zonomi DNS driver could only return the first record for a given host, because it used the name of the host as Record.id. Now, use the new default, <type>[:<name>], format to allow various records to be differentiated for a given host.
DNS drivers share the need to manipulate host/domain names, so let's add utility functions to the common Record and Zone classes to allow redundant code scattered throughout the various drivers to be consolidated into common and consistent implementations. * Record.name - no longer driver-dependent, now the host prefix or "" * Record.hostname - the complete host name, including domain part * Record.fqdn - the fully qualified domain name, including root dot * Zone.domain - no longer driver-dependent, now the unrooted domain * Zone.rooted() - format a (un)rooted domain as a rooted domain * Zone.unrooted() - format a (un)rooted domain as an unrooted domain
Update testing inputs to conform to spec'ed usage.
Leverage common code from DNSDriver, Record, and Zone classes for host name and record ID handling.
Drop RackspaceDNSDriver._to_partial_record_name() and RackspaceDNSDriver._to_full_record_name() in favor of the common support provided by the Record and Zone classes.
fcaf113 to
34d96fa
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #2066 +/- ##
==========================================
- Coverage 83.66% 83.39% -0.27%
==========================================
Files 352 350 -2
Lines 82445 82990 +545
Branches 8890 8867 -23
==========================================
+ Hits 68974 69207 +233
- Misses 10591 10934 +343
+ Partials 2880 2849 -31
🚀 New features to boost your workflow:
|
|
One of the tests are failing:
I prefer that, at least in the drivers modified in this PR that this error is solved. def update_record(self, record, name, type, data, extra=None):
record_id = record.id
if extra and "entry" in extra and str(extra["entry"]) != record_id:
raise WorldWideDNSError(...) |
|
|
||
| @classmethod | ||
| def from_default_id(cls, zone, record_id): | ||
| match = cls.DEFAULT_ID_RE.match(record_id) |
There was a problem hiding this comment.
The current implementation uses re.match() to parse record IDs. Since re.match() only requires a match at the beginning of the string, malformed IDs can be partially accepted.
For example, "A:" matches the "A" prefix because the optional name group cannot match an empty string. As a result, the trailing colon is silently ignored instead of rejecting the invalid ID.
Would it make sense to use re.fullmatch() instead, so the entire record ID must match the expected format?
A regression test for malformed IDs such as "A:" would also be useful.
|
Moved to: #2233 |
Fix DNS driver API inconsistencies
Description
Implement #2065
Summary
In general, commit messages provide necessary background regarding the changes made and why.
<type>[:<name>]-style record IDsRecord.idformat for NS1 and Zonomi providersRecord.idinterpretation for World Wide DNSStatus
Checklist (tick everything that applies)