Skip to content

Commit 8f0f9ff

Browse files
committed
fix oidc federation e2e error assertions
1 parent eeec4eb commit 8f0f9ff

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

.claude/CLAUDE-KNOWLEDGE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,6 @@ A: Invalid `tools` entries are rejected by `requestBodySchema` in `apps/backend/
367367

368368
## Q: Why did the internal metrics E2E snapshots need to change in April 2026?
369369
A: The `/api/v1/internal/metrics` response now intentionally includes `analytics_overview.daily_anonymous_visitors_fallback`, `analytics_overview.anonymous_visitors_fallback`, and `active_users_by_country`. Those additions are reflected in `packages/stack-shared/src/interface/admin-metrics.ts` and the backend route, so the E2E snapshots must include them instead of treating them as regressions.
370+
371+
## Q: What body shape should E2E tests expect from backend `StatusError` responses?
372+
A: `StatusError.getBody()` returns the error message as a plain text response body with `Content-Type: text/plain; charset=utf-8`. E2E tests using `niceBackendFetch` should assert against `response.body` directly, for example `expect(response.body).toBe("invalid_grant")`, not `response.body.error`.

apps/e2e/tests/backend/endpoints/api/v1/auth/oidc-federation/exchange.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ it("rejects when no trust policies are enabled", async ({ expect }) => {
179179
const token = await mockIdp.signToken({ sub: "workload-1" }, { audience: "anything" });
180180
const response = await postExchange({ subject_token: token, projectId });
181181
expect(response.status).toBe(400);
182-
expect(response.body.error).toBe("invalid_grant");
182+
expect(response.body).toBe("invalid_grant");
183183
});
184184

185185
it("rejects when the audience doesn't match the policy", async ({ expect }) => {
@@ -217,7 +217,7 @@ it("rejects when a StringEquals claim condition fails", async ({ expect }) => {
217217
);
218218
const response = await postExchange({ subject_token: token, projectId });
219219
expect(response.status).toBe(400);
220-
expect(response.body.error).toBe("invalid_grant");
220+
expect(response.body).toBe("invalid_grant");
221221
expect(JSON.stringify(response.body)).not.toContain("StringEquals");
222222
});
223223

0 commit comments

Comments
 (0)