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

Rewrite Mock to handle known authorities #43

Open
mbklein opened this issue Dec 9, 2020 · 0 comments
Open

Rewrite Mock to handle known authorities #43

mbklein opened this issue Dec 9, 2020 · 0 comments
Labels

Comments

@mbklein
Copy link
Contributor

mbklein commented Dec 9, 2020

Description

Authoritex.Mock has no way to know whether a given unregistered URI is from an unknown authority or a missing ID from a known authority.

Current Implementation

Per #42, Authoritex.Mock.search("missing_id_authority:whatever") will return {:error, 404}, while any other unregistered URI will return {:error, :unknown_authority}

Proposed Implementation

  • Update Authoritex.Mock.set_data() to include a list of known authority prefixes along with the map of IDs and labels
  • Update Authoritex.Mock.fetch() to check the given URI against the list of registered authority prefixes (using String.starts_with? is sufficient)
    • If at least one authority prefix matches and the ID is registered, return the result as usual
    • If at least one authority prefix matches but the ID isn't found, the result is {:error, 404}
    • If no authority prefix matches even if the ID is found, the result is {:error, :unknown_authority}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants