Skip to content

PPT-2536: external-IdP spec coverage (ID-06/07/08/11) - #13

Merged
camreeves merged 4 commits into
masterfrom
PPT-2536-idp-mapping
Jul 29, 2026
Merged

PPT-2536: external-IdP spec coverage (ID-06/07/08/11)#13
camreeves merged 4 commits into
masterfrom
PPT-2536-idp-mapping

Conversation

@camreeves

Copy link
Copy Markdown
Contributor

P1 work on the external IdP cluster — the thinnest in test-matrix.md and the most UCLA-relevant (SAML/Azure). Test-only; no src/ changes.

Each of these guards a regression that is silent rather than loud.

Row Cases Guards
ID-08 3 info_mappings comma-fallback
ID-07 2 authorize_params merged into the authorize URL
ID-11 1 OAuthUserMapper Link branch
ID-06 1 ensure_matching absent-field → fail closed

ID-08 — Azure/Entra surfaces the email as userPrincipalName, not email. 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.cr restores 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 embedded redirect_uri intact.

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-06oauth_provider_flows_spec.cr already 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

camreeves and others added 4 commits July 29, 2026 15:57
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>
@camreeves
camreeves merged commit eccb818 into master Jul 29, 2026
7 checks passed
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.

1 participant