Skip to content
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

2589: RDAP API endpoint [rh] #2843

Merged
merged 11 commits into from
Sep 30, 2024
Merged

2589: RDAP API endpoint [rh] #2843

merged 11 commits into from
Sep 30, 2024

Conversation

erinysong
Copy link
Contributor

@erinysong erinysong commented Sep 23, 2024

Ticket

Resolves #2589

Changes

  • Adds public API endpoint /rdap/?domain= that fetches RDAP data of a domain from Cloudflare's RDAP API.
  • Adds appropriate tests for RDAP API functionality.
  • Remove _domains an artifact of old availability API that is no longer used

Context for reviewers

Adding manage.get.gov API endpoint to fetch domain RDAP in order to mediate fetching Cloudflare data from other .gov projects.

Setup

Go https://getgov-rh.app.cloud.gov/api/v1/rdap/?domain=... and replace ... with different domains. The API should respond to the following use cases:

  • Valid RDAP domain names (eg whitehouse.gov) will output a JSON of the domain's RDAP data from Cloudflare.
  • Valid RDAP domain names that exclude the .gov TLD (eg whitehouse) will output a JSOn of the domain's RDAP from Cloudflare.

Invalid domain names will be handled by Cloudflare's API handling and error codes which are then used on get.gov's end.

  • Domains that have a TLD (top-level-domain) that is not .gov will output JSON with the error message that the TLD does not exist under our registry.
  • Domains that have more than one part above the TLD (manage.get.gov) will output JSON with the error message that domains must have exactly one part above their TLD. Open to discussing if we should follow Cloudflare's protocol here or if our use cases warrant handling it differently.
  • Domain names that are not .gov domains (eg hello.gov) will output JSON with the error message that the .gov domain searched was not found.

Also confirmed that this API successfully displays RDAP JSON on GFEs and would like someone else to verify these steps work on their GFE.

Code Review Verification Steps

As the original developer, I have

Satisfied acceptance criteria and met development standards

  • Met the acceptance criteria, or will meet them in a subsequent PR
  • Created/modified automated tests
  • Added at least 2 developers as PR reviewers (only 1 will need to approve)
  • Messaged on Slack or in standup to notify the team that a PR is ready for review
  • Changes to “how we do things” are documented in READMEs and or onboarding guide
  • If any model was updated to modify/add/delete columns, makemigrations was ran and the associated migrations file has been commited.

Ensured code standards are met (Original Developer)

  • All new functions and methods are commented using plain language
  • Did dependency updates in Pipfile also get changed in requirements.txt?
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values

Validated user-facing changes (if applicable)

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
  • Add at least 1 designer as PR reviewer

As a code reviewer, I have

Reviewed, tested, and left feedback about the changes

  • Pulled this branch locally and tested it
  • Reviewed this code and left comments
  • Checked that all code is adequately covered by tests
  • Made it clear which comments need to be addressed before this work is merged
  • If any model was updated to modify/add/delete columns, makemigrations was ran and the associated migrations file has been commited.

Ensured code standards are met (Code reviewer)

  • All new functions and methods are commented using plain language
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values
  • (Rarely needed) Did dependency updates in Pipfile also get changed in requirements.txt?

Validated user-facing changes as a developer

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing

  • Checked keyboard navigability

  • Meets all designs and user flows provided by design/product

  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)

  • Tested with multiple browsers, the suggestion is to use ones that the developer didn't (check off which ones were used)

    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

Note: Multiple code reviewers can share the checklists above, a second reviewers should not make a duplicate checklist

As a designer reviewer, I have

Verified that the changes match the design intention

  • Checked that the design translated visually
  • Checked behavior
  • Checked different states (empty, one, some, error)
  • Checked for landmarks, page heading structure, and links
  • Tried to break the intended flow

Validated user-facing changes as a designer

  • Checked keyboard navigability

  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)

  • Tested with multiple browsers (check off which ones were used)

    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

Screenshots

Copy link

🥳 Successfully deployed to developer sandbox es.

Copy link

🥳 Successfully deployed to developer sandbox es.

Copy link

🥳 Successfully deployed to developer sandbox es.

1 similar comment
Copy link

🥳 Successfully deployed to developer sandbox es.

@erinysong erinysong marked this pull request as ready for review September 25, 2024 00:02
@erinysong erinysong changed the title 2589: RDAP API endpoint [draft] 2589: RDAP API endpoint Sep 25, 2024
Copy link

🥳 Successfully deployed to developer sandbox es.

@erinysong erinysong marked this pull request as draft September 25, 2024 00:07
@erinysong erinysong changed the title [draft] 2589: RDAP API endpoint 2589: RDAP API endpoint Sep 25, 2024
@erinysong erinysong marked this pull request as ready for review September 25, 2024 16:19
Copy link

🥳 Successfully deployed to developer sandbox es.

API_BASE_PATH = "/api/v1/rdap/?domain="


class RDapViewTest(TestCase):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abroddrick Since we don't call the RDAP API in any of manage.get.gov's views, I had our tests inherit from TestCase rather than create a mock RDAP library since it would go unused unless we find a reason to add RDAP views into the registrar. I can add a mock RDAP library class if we want to follow availability standards but it will likely go unused until we use RDAP in manage.get.gov and not just get.gov

API_BASE_PATH = "/api/v1/rdap/?domain="


class RdapViewTest(TestCase):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abroddrick Since we don't call the RDAP API in any of manage.get.gov's views, I had our tests inherit from TestCase rather than create a mock RDAP library since it would go unused unless we find a reason to add RDAP views into the registrar. I can add a mock RDAP library class if we want to follow availability standards but it will likely go unused until we use RDAP in manage.get.gov and not just get.gov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense

src/api/views.py Outdated
@@ -19,6 +19,7 @@


DOMAIN_FILE_URL = "https://raw.githubusercontent.com/cisagov/dotgov-data/main/current-full.csv"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this and any uses of this while your in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abroddrick sure! I'm not as familiar with where this is used but is current-full no longer referenced in manage.get.gov?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope it isn't

@ttl_cache(ttl=600)
def rdap(request, domain=""):
"""Returns JSON dictionary of a domain's RDAP data from Cloudflare API"""
domain = request.GET.get("domain", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm! I was just wondering why the ttl is 600 seconds? Is that standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think generally 5 minutes is one of the standard defaults for caching which we also use in the availability endpoint! If there ends up being a cache time that makes more sense for this data we can also always update it if the need arises :")

Copy link
Contributor

@asaki222 asaki222 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, LGTM. 600 seconds is 10 minutes. Was that intentional for this cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack you're right, did not math that math correctly :")

@erinysong erinysong changed the title 2589: RDAP API endpoint 2589: RDAP API endpoint [rh] Sep 26, 2024
Copy link

🥳 Successfully deployed to developer sandbox es.

@erinysong erinysong merged commit ab5cd2c into main Sep 30, 2024
10 checks passed
@erinysong erinysong deleted the es/2589-rdap-api branch September 30, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add RDAP data endpoint in manage.get.gov API
3 participants