Skip to content

test(account): cover real Google and Apple ID token payloads - #13697

Merged
Meldiron merged 1 commit into
mainfrom
feat-idtoken-real-claim-shapes
Sep 15, 2026
Merged

Meldiron merged 1 commit into
mainfrom
feat-idtoken-real-claim-shapes

Conversation

@Meldiron

Copy link
Copy Markdown
Contributor

What does this PR do?

The ID token sign-in e2e tests all mint minimal claim sets (sub, email, email_verified), so nothing exercised the payloads Google and Apple actually send. Two shapes were untested:

  • Google's full claim set — azp, hd, at_hash, given_name, family_name and locale ride along with the claims the flow reads. The extras have to be carried without upsetting verification, while name and picture reach the account and its identity.
  • Apple's — email_verified and is_private_email arrive as the strings "true" rather than JSON booleans, the nonce is carried as the SHA-256 of the raw value, and no name or picture claim is ever sent. So the name has to fall back to the request parameter (Apple hands it to the client once, on the first authorization) and the identity is left without a photo.

Create.php already handles both — it filter_var()s the string booleans and defaults the photo to empty — this pins that behaviour down so a future refactor can't quietly drop it. No src/ changes.

iss, aud and picture stay pointed at the mock provider, since the tokens must verify against the mock JWKS and the avatar must be fetchable in CI. Every other claim is the provider's own shape. Apple's test runs against mock-unverified, the mock profile that requires a nonce exactly as Apple's does.

Test Plan

Both new tests run green against the existing mock OAuth2 infrastructure, and the surrounding ID token suite is unaffected:

$ docker exec appwrite vendor/bin/phpunit --filter 'IdToken' \
    tests/e2e/Services/Account/AccountCustomClientTest.php

testCreateIdTokenSessionGoogleShapedClaims ended in 184 milliseconds
testCreateIdTokenSessionAppleShapedClaims ended in 1503 milliseconds
...
OK (19 tests, 238 assertions)

The photo assertions cut both ways against the same helper, so they fail if the behaviour regresses in either direction: the Google payload must resolve to the mock provider's solid #00FF00 avatar, and the Apple payload must not — it has no picture claim, so the chain falls through to a generated avatar.

composer lint (pint) passes on the changed file.

Related PRs and Issues

  • Follows the native ID token sign-in flow added in Account/Http/Account/Sessions/IdToken

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? — N/A, tests only.

🤖 Generated with Claude Code

The ID token e2e tests all mint minimal claim sets, so nothing exercised
the payloads the providers actually send. Two shapes were untested:

- Google's full claim set, where `azp`, `hd`, `at_hash`, `given_name`,
  `family_name` and `locale` ride along with the claims the flow reads,
  and `name` and `picture` have to reach the account and its identity.
- Apple's, where `email_verified` and `is_private_email` arrive as the
  strings "true" rather than JSON booleans, the nonce is carried as the
  SHA-256 of the raw value, and no `name` or `picture` claim is ever
  sent, so the name falls back to the request parameter and the identity
  is left without a photo.

`Create.php` already handles both, filter_var()-ing the string booleans
and defaulting the photo to empty; this pins that behaviour down.

`iss`, `aud` and `picture` stay pointed at the mock provider so the
tokens verify against the mock JWKS and the avatar is fetchable in CI.
Every other claim is the provider's own shape.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The behavioral coverage is useful, but the explicit repository requirement against implementation-coupled assertions must be satisfied before merging.

Fix All in Claude CodeFindings

  1. P2 Avatar checks mirror fixture ▶
Fix with agent prompt
### Issue 1
tests/e2e/Services/Account/AccountCustomClientTest.php:6296
These assertions infer identity-photo selection from one implementation-specific center pixel (`#00FF00`). Changing the mock image while preserving the same observable behavior would break the Google test, while any incorrect non-green image would satisfy the Apple test. This violates the repository directive to test observable behavior rather than mirror source code or configuration, so this requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR adds end-to-end coverage for Google- and Apple-shaped ID-token payloads.

  • Verifies Google claim-derived account names and identity photos.
  • Verifies Apple's string-valued email verification, hashed nonce, request-name fallback, and generated-avatar fallback.
  • Adds an image-inspection helper whose exact fixture-color coupling should be removed.

Reviews (1) · Last reviewed commit: "test(account): cover real Google and App..."

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat-idtoken-real-claim-shapes (after).

Metric Before After Change
🚀 Requests/sec 220.2 223.03 ⚪ +1.3%
⏱️ Latency P50 80.38 ms 78.42 ms ⚪ -2.4%
⏱️ Latency P95 182.01 ms 182.78 ms ⚪ +0.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 78.42 182.78 13,680 223.03 +0.77
Account 150.96 272.99 720 12.4 +10.02
TablesDB 75.34 137.25 7,440 123.69 -10.76
Storage 72.16 154.77 3,600 61.68 +2.51
Functions 115.29 218.73 1,920 33.68 -3.45

Top API waits (after)

API request Max wait (ms)
functions.variables.update 527.34
functions.variables.create 441.93
functions.delete 424.34
functions.create 386.45
account.name.update 366.69

@Meldiron
Meldiron merged commit 9d75c09 into main Sep 15, 2026
90 of 91 checks passed
Meldiron added a commit that referenced this pull request Sep 15, 2026
#13697 landed the Google- and Apple-shaped claim tests on the same tail
of AccountCustomClientTest, which is the only conflict. Both sets of
tests are kept: main's two shape tests and its isMockOAuth2Photo helper,
followed by this branch's testCreateIdTokenSessionStoresIdToken and its
findMockIdentity / decodeJwtPayload helpers.

2.2.0 maps to V25 in Migration.php, so the providerIdToken attribute
stays in the migration it was added to.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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