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

Add fulfill route and tests #280

Merged
merged 3 commits into from
Jan 2, 2024
Merged

Conversation

Apophenia
Copy link
Contributor

@Apophenia Apophenia commented Dec 18, 2023

Does not have 100% test coverage; when everything is hooked up I will add test cases for the positive cases of "yes, this is working" and also figure out how to mock the expired token.

Don't love how much logic lives directly in the Blueprint but given the error structure I'm not sure how to best test it if I were to bundle the auth logic in another file, but open to refactoring.

Comment on lines +36 to +45
except jwt.exceptions.ExpiredSignatureError:
statusCode = 401
responseBody = 'Expired access token'
except (jwt.exceptions.DecodeError, UnicodeDecodeError, IndexError, AttributeError):
statusCode = 401
responseBody = 'Invalid access token'
except ValueError:
logger.warning("Could not deserialize NYPL-issued public key")
statusCode = 500
responseBody = 'Server error'
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to catch all these exception cases

Comment on lines +51 to +52
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA44ilHg/PxcJYsISHMRyoxsmez178qZpkJVXg7rOMVTLZuf05an7Pl+lX4nw/rqcvGQDXyrimciLgLkWu00xhm6h6klTeJSNq2DgseF8OMw2olfuBKq1NBQ/vC8U0l5NJu34oSN4/iipgpovqAHHBGV4zDt0EWSXE5xpnBWi+w1NMAX/muB2QRfRxkkhueDkAmwKvz5MXJPay7FB/WRjf+7r2EN78x5iQKyCw0tpEZ5hpBX831SEnVULCnpFOcJWMPLdg0Ff6tBmgDxKQBVFIQ9RrzMLTqxKnVVn2+hVpk4F/8tMsGCdd4s/AJqEQBy5lsq7ji1B63XYqi5fc1SnJEQIDAQAB
-----END PUBLIC KEY-----
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good addition to the sample compose file for the local environment.

Copy link
Contributor

@mitri-slory mitri-slory left a comment

Choose a reason for hiding this comment

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

The new endpoint looks really good. The logic in the blueprint is fine since some of the other blueprints have a lot of logic as well when calling methods. I would only recommend finishing the rest of the tests you want to implement before fully merging this branch into main.

@Apophenia
Copy link
Contributor Author

I'm going to go ahead and merge this, and add the one test I think I'm missing (need to mock an exception thrown for an expired token) with my next PR so that it can be reviewed.

@Apophenia Apophenia merged commit 43ee8af into main Jan 2, 2024
2 of 3 checks passed
@Apophenia Apophenia deleted the SFR-1827_New_fulfill_endpoint branch January 2, 2024 15:01
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.

3 participants