PPT-2536: external-IdP spec coverage (ID-06/07/08/11) - #13
Merged
Conversation
The legacy Ruby `generic_oauth` strategy treated each info_mappings value as a comma-separated FALLBACK LIST and used the first key present in the provider's profile — notably how Azure/Entra surfaces the email as `userPrincipalName` rather than `email`. multi_auth does a single literal lookup, so a comma-list resolves to nil and the email arrives empty. Losing that fallback produced real users with no email, which then duplicated on the next sign-in. multi_auth_patch.cr restores it but nothing pinned the behaviour, so it could regress silently on a shard bump. Three cases, covering both directions plus the blank-value edge: * falls back past absent keys to a later candidate (userPrincipalName) * prefers the FIRST present key over later fallbacks * skips a present-but-EMPTY candidate rather than mapping "" Matrix row ID-08. External IdP is the thinnest cluster and UCLA-relevant. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…der linking
Three more external-IdP rows. This cluster is the thinnest in the matrix and
the most UCLA-relevant (SAML/Azure), and each of these guards a regression
that is silent rather than loud.
ID-07 authorize_params merge — the legacy service merged the strat's
authorize_params into the outbound authorize URL. Google returns NO
refresh_token without access_type=offline, so dropping it means every
session dies at the first expiry with no way to renew. Also asserts the
merge leaves the embedded redirect_uri intact.
ID-06 ensure_matching — the hosted-domain restriction ("Invalid Hosted
Domain"). Dropping it admits any account the IdP will authenticate; for a
multi-tenant IdP that is the whole internet. Covers match, non-match, and
crucially the ABSENT-field case, which must fail closed rather than pass
vacuously.
ID-11 OAuthUserMapper Link branch — an already-signed-in user completing a
callback for an unseen provider identity must have it attached to their
existing account, not forked into a second user. Only the Login and
Created branches were covered.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The assertion read `before_count + 1`, but the count was captured AFTER the fixture user was created — so it demanded that a SECOND account appear, which is precisely the bug the test exists to catch. A correct link leaves the count unchanged. CI caught it: expected 6, got 5, i.e. the mapper behaved correctly and the spec was wrong. Renamed the variable to count_with_existing so the intent can't be misread. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
oauth_provider_flows_spec.cr already asserts the match and non-match cases, so two of the three added here were redundant. The genuine gap was the ABSENT-field case — a required field that is missing entirely must fail closed rather than pass vacuously — and only that one is kept. Also corrects the matrix, which had ID-06 as no-coverage when it was partial. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
P1 work on the external IdP cluster — the thinnest in
test-matrix.mdand the most UCLA-relevant (SAML/Azure). Test-only; nosrc/changes.Each of these guards a regression that is silent rather than loud.
info_mappingscomma-fallbackauthorize_paramsmerged into the authorize URLOAuthUserMapperLink branchensure_matchingabsent-field → fail closedID-08 — Azure/Entra surfaces the email as
userPrincipalName, notemail. The Ruby strategy treated mappings as comma-separated fallback lists; multi_auth does a single literal lookup, so a comma-list resolves to nil. When that was lost it produced users with no email, which then duplicated on next sign-in.multi_auth_patch.crrestores it, but nothing pinned it — a shard bump could silently undo it. Covers both directions plus the present-but-empty edge.ID-07 — Google returns no refresh_token without
access_type=offline, so dropping the merge means every session dies at first expiry with no renewal path. Also asserts the merge leaves the embeddedredirect_uriintact.ID-11 — only the Login and Created branches were covered. Link is what happens when an already-signed-in user attaches a second IdP; get it wrong and the account silently forks.
ID-06 —
oauth_provider_flows_spec.cralready covers match/non-match, so only the genuinely missing case is added: a required field that is absent entirely must fail closed rather than pass vacuously. (The matrix had ID-06 as no-coverage; it was partial. Corrected.)Verification
168 examples, 0 failures(161 + 7). CI and Build both green.One assertion of mine was wrong on the first run and CI caught it: the Link-branch spec demanded the user count go up by one, which is the fork bug it exists to catch. The code was correct; the spec wasn't.
🤖 Generated with Claude Code