stack/apps/e2e/tests/backend/endpoints/api/v1
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
..
__snapshots__ Dashboard: DataGrid refactor + layout (stacked on overview-revamp) (#1338) 2026-04-27 13:50:24 -07:00
auth test(e2e): add full SAML SP-initiated round-trip tests via mock IdP 2026-04-29 16:47:17 -07:00
contact-channels Sign up rules (#1138) 2026-02-03 11:08:24 -08:00
emails More lenient email processing pause 2026-04-12 15:37:33 -07:00
integrations [codex] Fix Neon malformed Basic auth validation (#1381) 2026-04-24 11:59:18 -07:00
internal Move internal MCP server to backend, use Mintlify MCP for docs tools (#1389) 2026-04-29 09:45:52 -07:00
payments Payments bulldozer txn rework (#1315) 2026-04-17 22:11:21 +00:00
ai-query.test.ts Dashboard: DataGrid refactor + layout (stacked on overview-revamp) (#1338) 2026-04-27 13:50:24 -07:00
analytics-config.test.ts Queries view (#1145) 2026-02-16 11:39:21 -08:00
analytics-events-batch.test.ts fix clickhouse surrogate pair bug (#1270) 2026-03-23 10:09:04 -07:00
analytics-events.test.ts clickhouse user sync (#1159) 2026-02-12 16:52:20 -08:00
analytics-query.test.ts Classify ClickHouse NO_COMMON_TYPE (386) as unsafe (#1380) 2026-04-24 12:07:16 -07:00
api-keys.test.ts Email outbox backend (#1030) 2025-12-12 10:26:38 -08:00
auth-flows.test.ts Fix tests 2025-07-16 11:42:25 -07:00
check-feature-support.test.ts More backend endpoint implementations (#126) 2024-07-13 22:04:53 -07:00
connected-accounts.test.ts More connected accounts (#1165) 2026-02-18 15:19:35 -08:00
data-vault.test.ts Speed up tests (#1063) 2025-12-28 11:25:04 -08:00
email-themes.test.ts [Refactor][Feat][Fix] Rework Email Section With New Sent Page, Better Drafts Page, and Settings Page (#1221) 2026-03-11 12:01:36 -07:00
external-db-sync-advanced.test.ts Turnstile integration for fraud protection (#1239) 2026-03-20 21:26:45 +00:00
external-db-sync-basics.test.ts Sync engine should ignore missing tenancies 2026-04-09 23:31:21 -07:00
external-db-sync-high-volume.test.ts Turnstile integration for fraud protection (#1239) 2026-03-20 21:26:45 +00:00
external-db-sync-race.test.ts Turnstile integration for fraud protection (#1239) 2026-03-20 21:26:45 +00:00
external-db-sync-utils.ts clickhouse new syncs and verify-data (#1304) 2026-04-08 14:43:22 -07:00
index.test.ts "Require publishable client key" toggle (#1158) 2026-02-19 10:23:16 -08:00
internal-metrics.test.ts Dashboard: DataGrid refactor + layout (stacked on overview-revamp) (#1338) 2026-04-27 13:50:24 -07:00
notification-preferences.test.ts Speed up tests (#1063) 2025-12-28 11:25:04 -08:00
oauth-providers.test.ts Fix OAuth provider disablement 2026-02-24 12:43:41 -08:00
project-permission-definitions.test.ts Config DB migration step 2 (#629) 2025-04-29 14:52:45 -07:00
project-permissions.test.ts Add onboarding status to Project model and implement related database… (#1246) 2026-03-13 12:00:40 -07:00
projects.test.ts Add onboarding status to Project model and implement related database… (#1246) 2026-03-13 12:00:40 -07:00
render-email.test.ts [Refactor] [Fix] Email Rendering Pipeline Refactor, Error Handling, and Bug Fixes (#1140) 2026-02-02 17:35:51 -08:00
restricted-users.test.ts Sign up rules (#1138) 2026-02-03 11:08:24 -08:00
risk-scores.test.ts private files n sm build shit (#1276) 2026-03-23 12:31:36 -07:00
send-email.test.ts Email outbox backend (#1030) 2025-12-12 10:26:38 -08:00
session-replays.test.ts [Dashboard][Backend][SDK] - Adds sharable session replay ids. (#1294) 2026-04-28 17:57:07 -05:00
stripe-webhooks.test.ts fix product route access (#1134) 2026-01-27 18:30:14 +00:00
team-invitations.test.ts Payments bulldozer txn rework (#1315) 2026-04-17 22:11:21 +00:00
team-member-profiles.test.ts Speed up tests (#1063) 2025-12-28 11:25:04 -08:00
team-memberships.test.ts Turnstile integration for fraud protection (#1239) 2026-03-20 21:26:45 +00:00
team-permission-definitions.test.ts Fix error where deleting a team creator default permission would make the dashboard crash 2025-08-11 17:42:54 -07:00
team-permissions.test.ts Add onboarding status to Project model and implement related database… (#1246) 2026-03-13 12:00:40 -07:00
teams.test.ts Speed up tests (#1063) 2025-12-28 11:25:04 -08:00
token-refresh-events.test.ts Reduce number of token refresh events 2026-01-28 14:56:11 -08:00
unsubscribe-link.test.ts Emails redesign (#1076) 2026-02-16 14:57:17 -08:00
users-primary-email.test.ts Onboarding app & restricted users (#1069) 2026-01-11 17:22:14 -08:00
users.test.ts Add server-side flags for anonymous users 2026-04-03 10:43:34 -07:00