Skip to content

fix: early oidc refresh with fake idp tests#22712

Merged
Emyrk merged 4 commits intomainfrom
stevenmasley/oidc_premature_refresh
Mar 6, 2026
Merged

fix: early oidc refresh with fake idp tests#22712
Emyrk merged 4 commits intomainfrom
stevenmasley/oidc_premature_refresh

Conversation

@Emyrk
Copy link
Member

@Emyrk Emyrk commented Mar 6, 2026

Wrote unit tests that implement a fake idp to verify the oauth package actually refreshes the token

if c.refreshExpected {
require.Equal(t, 1, tokenRefreshCount)
} else {
require.Equal(t, 0, tokenRefreshCount)
Copy link
Member

Choose a reason for hiding this comment

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

We need to be able to differentiate between "no calls recorded" versus "no calls attempted"

Copy link
Member Author

Choose a reason for hiding this comment

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

If I understand correctly, I think this is kinda done. TestShouldRefreshOIDCToken tests if shouldRefreshOIDCToken returns true/false. Which is the equivalent of "refresh attempted".

Then this more e2e style test with a real idp is checking if the underlying oauth library actually does the refresh.

What I should add is a check for the updated expiration time + access token change on the db row. Which also addresses your comment

Copy link
Member Author

Choose a reason for hiding this comment

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

I now check if the token actually changed in the db 👍

@Emyrk Emyrk enabled auto-merge (squash) March 6, 2026 16:50
@Emyrk Emyrk merged commit 537260a into main Mar 6, 2026
24 checks passed
@Emyrk Emyrk deleted the stevenmasley/oidc_premature_refresh branch March 6, 2026 16:51
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants