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

fix: AutoRenewService should perform renew if token has expired before service start #1354

Merged
merged 8 commits into from
Dec 7, 2022

Conversation

denysoblohin-okta
Copy link
Contributor

@denysoblohin-okta denysoblohin-okta commented Nov 25, 2022

Fixes issue #1164

Issue description:
Leader election can take some time, AutoRenewService would not start until election is completed and current tab is a leader.
If there is an expired token in storage on the moment OktaAuth service is started, TokenManager would emit EVENT_EXPIRED but AutoRenewService would not catch/process this event because it's not started yet.

Fix:
Process expired tokens on AutoRenewService start.

Internal ref: https://oktainc.atlassian.net/browse/OKTA-549676

expect(client.tokenManager.renew).toHaveBeenCalledTimes(1);
expect(client.tokenManager.renew).toHaveBeenCalledWith('test-idToken');
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test case which includes an expired token in the tokenManager before serviceManager.start is called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@jaredperreault-okta
Copy link
Contributor

Maybe serviceManager.start should not resolve until after a leader has been elected, assuming a leader is required

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2022

Codecov Report

Base: 91.77% // Head: 91.79% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (837f045) compared to base (682a278).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1354      +/-   ##
==========================================
+ Coverage   91.77%   91.79%   +0.02%     
==========================================
  Files         217      217              
  Lines        5206     5219      +13     
  Branches     1098     1100       +2     
==========================================
+ Hits         4778     4791      +13     
  Misses        405      405              
  Partials       23       23              
Impacted Files Coverage Δ
lib/oidc/types/TokenManager.ts 100.00% <ø> (ø)
lib/oidc/TokenManager.ts 95.78% <100.00%> (+0.06%) ⬆️
lib/services/AutoRenewService.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

test/spec/ServiceManager.ts Outdated Show resolved Hide resolved
lib/services/AutoRenewService.ts Outdated Show resolved Hide resolved
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.

4 participants