-
Notifications
You must be signed in to change notification settings - Fork 1
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
Skip authorization if in development/testing #48
base: main
Are you sure you want to change the base?
Conversation
5caf1a2
to
231ecad
Compare
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.
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 the tests failing - I think they should be fixed by moving the check inside get_access_token
, like so:
def get_access_token(*, http_client: Client) -> str:
"""Get an access token from Auth0."""
+ if SKIP_AUTH:
+ return "DEVELOPMENT"
payload = {
"client_id": Settings.client_id,
"client_secret": Settings.client_secret,
"username": Settings.username,
"password": Settings.password,
"audience": Settings.audience,
"grant_type": "password",
}
res = http_client.post(f"https://{Settings.auth0_domain}/oauth/token", json=payload)
res.raise_for_status()
json = res.json()
return json["access_token"] # type: ignore[no-any-return]
Because currently, the tests except the access token in the request to be whatever is returned by get_access_token
(and reasonably so), however we are overriding it elsewhere which makes the expected mock calls to fail.
That would case test_get_access_token to fail instead because it expects get_access_token to always make a http request to the auth url |
Hmm, yeah, you're right. I think it would be best to have 2 tests for |
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.
forgor to submit this
Closes #47