API: Differentiate bad TXT update error. #42
Merged
+72
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous to this commit, if the update message had a valid subdomain but
an invalid TXT value the error returned was for a bad subdomain. This can
confuse developers who were POSTing junk TXT records to test
acme-dns
😊Only TXT values that are exactly 43 chars are considered valid:
acme-dns/validation.go
Lines 37 to 40 in 830cceb
This commit adjusts the
webUpdatePost
error handling such that!validSubdomain(input)
and!validTXT(input)
give distinct errors.The
!validSubdomain
case should never happen inwebUpdatePost
because
auth.go
'sAuth
function already vets the post datasubdomain but I retained the error handling code just in case.
Unit tests for an update with an invalid subdomain and an update with an
invalid TXT are included.
I did my best to match the repo style for the code/tests but I admit
to hacking this together quickly without having read most of the codebase
yet! Please critique liberally.