[test-quarantine] Fix the UserManagerWillUseTokenProviderInstanceOverDefaults test failure - #68081
Open
karmegams02 wants to merge 2 commits into
Open
[test-quarantine] Fix the UserManagerWillUseTokenProviderInstanceOverDefaults test failure#68081karmegams02 wants to merge 2 commits into
karmegams02 wants to merge 2 commits into
Conversation
Contributor
|
Thanks for your PR, @karmegams02. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
karmegams02
marked this pull request as ready for review
July 29, 2026 10:26
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an Identity token-provider resolution regression where IdentityBuilder.AddTokenProvider discarded a developer-supplied TokenProviderDescriptor.ProviderInstance when a provider name was already present (e.g., after AddDefaultTokenProviders). The change preserves the existing multi-UserType behavior (provider type stacking) while ensuring an explicitly configured provider instance takes precedence.
Changes:
- Stop clearing
TokenProviderDescriptor.ProviderInstancewhenAddTokenProviderencounters an existing provider-name entry; continue stacking provider types for multi-UserTypesupport. - Re-enable
UserManagerWillUseTokenProviderInstanceOverDefaultsnow that the framework correctly prefers the configured instance over default provider types.
Show a summary per file
| File | Description |
|---|---|
| src/Identity/Extensions.Core/src/IdentityBuilder.cs | Preserves ProviderInstance when stacking provider types for an existing provider name. |
| src/Identity/test/Identity.Test/UserManagerTest.cs | Unskips a test that verifies ProviderInstance wins over default token provider registrations. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
kotlarmilos
reviewed
Aug 7, 2026
4 tasks
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.
Summary
Preserve user-supplied
ProviderInstanceinIdentityBuilder.AddTokenProviderinstead of nulling it out.Description
IdentityBuilder.AddTokenProviderpreviously setdescriptor.ProviderInstance = nullwhenever a token provider with the same name had already been registered (e.g. byAddDefaultTokenProviders). The intent of that assignment was to keep multipleUserTypes working side by side, but the side effect was that anyProviderInstancethe developer had explicitly attached to the descriptor was discarded. A custom token provider instance registered viao.Tokens.ProviderMap[name] = new TokenProviderDescriptor(...) { ProviderInstance = ... }was therefore ignored, and the framework fell back to the default provider type registered byAddDefaultTokenProviders.This change preserves the multi-
UserTypesupport (provided by the type stack inTokenProviderDescriptor.AddProviderType) while allowing an explicitProviderInstanceto take precedence over the default provider type.Changes
src/Identity/Extensions.Core/src/IdentityBuilder.cs: dropdescriptor.ProviderInstance = null;inside theConfigure<IdentityOptions>block; update the explanatory comment to describe the new contract (type stack is preserved, an explicitProviderInstancewins over the default type).src/Identity/test/Identity.Test/UserManagerTest.cs: un-skipUserManagerWillUseTokenProviderInstanceOverDefaults. With the regression fixed, the test now passes and continues to assert that a user-suppliedProviderInstanceis preferred over the default token provider type.Why this is safe
UserTypebehavior is preserved by the provider type stack inTokenProviderDescriptor.AddProviderType, which is unchanged.ProviderInstanceare unaffected: they continue to get the default type fromAddDefaultTokenProvidersfollowed by any additionalAddTokenProvider<…>(name)calls.ProviderInstanceon aTokenProviderDescriptorsee a behavior change, and that change is the documented and tested behavior.Fixes #57361