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

Update CredentialManager classes to include IDToken expiration #254

Merged
merged 3 commits into from
Sep 3, 2019

Conversation

lbalmaceda
Copy link
Contributor

Changes

Made both classes aware of the ID Token exp value (when available) to decide when the whole Credentials object can be renewed.

References

Closes #253

Testing

Added more unit tests

  • This change adds unit test coverage

  • [] This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@lbalmaceda lbalmaceda added the medium Medium review label Aug 26, 2019
@lbalmaceda lbalmaceda added this to the v1-Next milestone Aug 26, 2019
@lbalmaceda lbalmaceda requested a review from a team August 26, 2019 17:27
Copy link
Contributor

@stevehobbsdev stevehobbsdev left a comment

Choose a reason for hiding this comment

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

@lbalmaceda Having a test suite for JWTDecoder seems redundant to me. The decoder doesn't do anything except wrap com.auth0.android.jwt.JWT (and I assume that library is also tested - if not, these tests should live there).

The fact that the credentials manager classes make use of the decoded token should be enough to provide coverage and assurance that the decoder class is working as intended. What do you think?

@lbalmaceda
Copy link
Contributor Author

@stevehobbsdev

Having a test suite for JWTDecoder seems redundant to me

The JWT library we use has its own tests, true.. However, because there's a token decoding step inside the process of "saving a token in the manager", I need to be able to test when that step fails or succeeds, given different scenarios. So I'm opening the constructor (package-privately) so that the test classes can see it and use that other signature that receives a "JWT decoder" instance for my tests to mock it.

But since my tests are mocking it, I cannot ensure that the "JWT decoding" step does actually what it is supposed to do: decode a real JWT string into a JWT instance. So I'm adding a simple test for that JWTDecoder package-private class in which I don't mock anything but I assert a token string gets decoded into a real JWT class here.

Say I change this line and I make it return a decoded JWT for a different hardcoded token, and don't make use of the one received as param. If I wouldn't be testing the JWTDecoder class then I wouldn't caught that error.

@lbalmaceda lbalmaceda merged commit e6fef4f into master Sep 3, 2019
@lbalmaceda
Copy link
Contributor Author

Will release this next week. 🏁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

id token not renewed during getCredentials call unless access token is expired.
3 participants