stack/apps/e2e
Bilal Godil 36d00f2c4d test(e2e): add full SAML SP-initiated round-trip tests via mock IdP
apps/e2e/tests/backend/endpoints/api/v1/auth/saml/round-trip.test.ts
exercises the entire SP-initiated flow against the running mock IdP on
port 8115:

  GET /auth/saml/login → IdP URL with SAMLRequest
  POST mock /idp/[tenant]/login → auto-POST HTML with signed SAMLResponse
  POST /auth/saml/acs → backend verifies + issues OAuth code

Five test cases:

1. Happy path: new user JIT-created, ACS responds with 303/307 + OAuth
   code in the redirect.

2. Wrong audience: mock IdP misbehaves via /test-controls
   { kind: 'wrong-audience' }, backend rejects.

3. Bad signature (cross-tenant forgery): mock signs with another
   tenant's key via { kind: 'bad-signature' }, backend rejects.

4. Expired assertion: NotOnOrAfter in the past via { kind: 'expired' },
   backend rejects.

5. Replay: same SAMLResponse POSTed twice — second attempt rejected
   because SamlOuterInfo was consumed by the first ACS call.

Fetches the mock IdP's cert at test setup time so the SAML
verification chain is real (the mock regenerates keys per startup, so
hardcoded certs would never match).

Test integrity reaffirmed: the test file imports only from helpers,
backend-helpers, and ports — NO imports from apps/backend/src/saml/.
Negative cases come from the mock deliberately misbehaving, never from
injecting bad data into the backend's own validator. Mock IdP uses
samlify; backend uses @node-saml/node-saml — different libraries on
each side mean a bug in either surfaces as a test failure rather than
canceling out.

Tests written and lint/typecheck clean; runtime verification needs the
backend + mock-saml-idp services up (CI workflow already wired).
2026-04-29 16:47:17 -07:00
..
tests test(e2e): add full SAML SP-initiated round-trip tests via mock IdP 2026-04-29 16:47:17 -07:00
.env Upgrade Prisma to v7 (#1064) 2025-12-26 08:13:34 -08:00
.env.development New { type: "hosted" } for page URLs (#1261) 2026-03-27 14:48:01 -07:00
.eslintrc.cjs tsup for stack-shared (#647) 2025-04-28 21:26:52 -07:00
LICENSE Create users & auth endpoints in backend (#85) 2024-07-01 22:42:08 -07:00
package.json chore: update package versions 2026-04-20 19:06:56 -07:00
tsconfig.json In-source unit tests (#429) 2025-02-14 11:47:52 -08:00
vitest.config.ts Email outbox backend (#1030) 2025-12-12 10:26:38 -08:00