-
Notifications
You must be signed in to change notification settings - Fork 29
#4152: Use httpx as the api library for dns hosting #4187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4f2c3ef to
3b9bcd4
Compare
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
| self.dns_host_service.register_nameservers(zone_name, nameservers) | ||
| except (RegistryError, RegistrySystemError, Exception) as e: | ||
| logger.error(f"Error updating registry: {e}") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not have the full context here, but why was this error message updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, I was hitting an error that wasn't the original one (RegistrySystemError), so then it wasn't getting caught and the app was crashing. So I added other exceptions to catch it (at it's base it would at least be an Exception). I think error handling has a lot to be desired and I'm hoping to focus on a proper and comprehensive error handling pattern in a future ticket.
| self.dns_record = None | ||
| self.client = Client() | ||
| self.dns_host_service = DnsHostService(client=self.client) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! It makes more flexible for other instances :-D
| }, | ||
| {"test_name": "RequestError", "error": {"exception": RequestError, "message": "Unknown error"}}, | ||
| ] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how you organized the the failure cases here
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
1 similar comment
|
🥳 Successfully deployed to developer sandbox kma. |
6f46df6 to
643e813
Compare
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
| _ = UserDomainRole(user=self.user, domain=domain_contact, role="admin").save() | ||
| page = self.client.get(reverse("domain-security-email", kwargs={"domain_pk": domain_contact.id})) | ||
| _ = UserDomainRole(user=self.user, domain=domain, role="admin").save() | ||
| DomainInformation.objects.get_or_create(requester=self.user, domain=domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test wasn't actually testing what it was supposed to. The page wasn't actually rendering the domain because it was missing the data was not set up properly. Adding DomainInformation sets it up properly.
| self.assertContains(response, "invited", count=5) | ||
| self.assertContains(response, "Invited", count=2) | ||
| self.assertContains(response, "retrieved", count=4) | ||
| self.assertContains(response, "invited", count=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These and the other adjusted counts in this PR are changed because one of the libraries that got updated changed the way the response html shows up. Previous, a lot more cruft (including queries) were showing up. With the updated, there's a lot less included in the response.
The tests in general need some work. They are not very clear what data is created or what data should be expected. For now they are basically serving as a "snapshot", so if something changes, we'll know. In the future, we should adjust the tests to be more effective and focused.
|
🥳 Successfully deployed to developer sandbox kma. |
|
🥳 Successfully deployed to developer sandbox kma. |
* Add httpx library * Update create_account and create_zone to use httpx library * Fix nameserver call and exceptions * Update create_dns_record to use httpx * Update create_account tests * Update create_zone tests * Update create_dns_record tests * Update fetches and tests * Remove context manager and explicitly close client * Update cloudflare_service tests to use new structure with client * Update dns_host_service tests to pass in client * Remove unused helper fn and fix black formatting * Remove test domains from valid_domains list * Remove import of non-exisistent module * Refactor tests and include RequestError tests * Fix linting issues * Mock env't vars in test to pass CI * Move vars into class vars; update test * Fix linting issues * Remove unused import * Update tests to reflect new output of response html after library updates * Update more tests * Fix additional tests * More fixes
Ticket
Resolves #4152
Changes
requeststohttpxin the CloudflareService methodsContext for reviewers
I'm not sure the best pattern for error handling/raising errors, and the error calls could be more granular. I'm open to suggestions, or this can be something we tackle in more depth later (both handling of errors and bubbling up of errors)
Setup
Should be able to use add a dns record to a domain that hasn't had one before and also new records to accounts/zones that already exist. See instructions for running locally
or test in sandbox kma (can use instructions from this PR to test with a new domain name)
Code Review Verification Steps
As the original developer, I have
Satisfied acceptance criteria and met development standards
Ensured code standards are met (Original Developer)
Validated user-facing changes (if applicable)
As a code reviewer, I have
Reviewed, tested, and left feedback about the changes
Validated user-facing changes as a developer
Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.
As a designer reviewer, I have
Verified that the changes match the design intention
Validated user-facing changes as a designer
References
Screenshots