Add unit tests#186
Merged
Merged
Conversation
# Conflicts: # src/Provider/Azure.php
Member
|
Awesome! Thanks so much for this! |
Contributor
Author
|
Thanks for the merge! Any idea when the next package release might be? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I've taken the time to add some unit tests. Since I use this package for B2C authentication, most tests that were written test this functionality. I believe it's a good starting point for people to add more tests.
The tests use a MockHandler that returns fake openIdConfig, keys, and tokens. This lets us test the package's code without having to worry about external connections. (See
Fakers/andHelper/)Overview:
test openIdConfig handling
throw RuntimeException when client id is invalid
throw RuntimeException when token is expired
throw RuntimeException when token is from future
throw RuntimeException when issuer is invalid
test getBaseAuthorizationUrl
test getLogoutUrl
test validateAccessToken: ISSUE -> validateAccessToken causes UnexpectedValueException : "kid" invalid, unable to lookup correct key in JWT.php:448. Not sure if this is a bug. This function doesn't seem to be used anywhere else. The same error is thrown when I call validateAccessToken in my personal project.
throw exception for invalid keys: ISSUE -> code only catches JWT_Exception but this class does not exist and also does not catch other exceptions
throw exception for invalid token
test getGrant