Skip to content

test(e2e): cover enterprise integrations#5868

Merged
BillLeoutsakosvl346 merged 14 commits into
e2e/settings-playwrightfrom
e2e/06b-enterprise-integrations
Jul 23, 2026
Merged

test(e2e): cover enterprise integrations#5868
BillLeoutsakosvl346 merged 14 commits into
e2e/settings-playwrightfrom
e2e/06b-enterprise-integrations

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • harden SSO management with organization-scoped façades, verified-domain rollout controls, schema invariants, migration/audit tooling, safe linking semantics, and SAML/OIDC regression coverage
  • add fail-closed data-retention readiness plus an exact mutation/restoration workflow and trusted post-run probe
  • add a strict multi-session Streamable HTTP MCP fake, isolated profile wiring, request diagnostics, fail-closed MCP readiness, and create/edit/discover/delete browser coverage
  • integrate Step 6b contracts, repeatability support, CI diagnostics, cleanup, leak scanning, and self-hosted rollout documentation

Validation

  • focused SSO, MCP, retention, route, UI, and E2E-adjacent unit tests pass
  • Sim app TypeScript check passes with Node heap raised to 8 GB
  • @sim/db typecheck passes
  • strict API validation, monorepo boundaries, migration safety, Biome, and git diff --check pass
  • all migrations apply on a clean temporary pgvector/Postgres database; the SSO provider audit passes
  • two independent Claude/GPT review conversations accepted the final implementation after iterative fixes

Local browser prerequisite

The repeated Step 6b Playwright command is ready but cannot run on this machine until mcp.e2e.sim.ai resolves to loopback. The runner fails closed and reports the required one-time mapping:

echo "127.0.0.1 e2e.sim.ai mcp.e2e.sim.ai" | sudo tee -a /etc/hosts

CI installs the mapping before running the settings suite.

Follow-up boundary

Better Auth 1.6.13's pre-existing OIDC callback transport does not expose a pinned-fetch injection hook. Callback-time DNS-rebinding hardening should be tracked separately rather than introducing an authentication-protocol fork in this E2E step.

Co-authored-by: Cursor <cursoragent@cursor.com>
@BillLeoutsakosvl346
BillLeoutsakosvl346 requested a review from a team as a code owner July 22, 2026 23:22
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 23, 2026 3:34am

Request Review

@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Touches authentication/SSO registration, linking, and domain trust boundaries with concurrent-operation locking; misconfiguration or flag rollout could block sign-in or provider changes.

Overview
Adds organization-scoped SSO management behind app API routes: Better Auth SSO register/update/delete and domain-verification mutations return 404 on the catch-all handler, while OIDC/SAML callbacks run under withSSOCallbackIntent. Registration and provider CRUD delegate to shared management helpers with mutation locks, domain overlap checks, account-link guards, and optional SSO_DOMAIN_VERIFICATION_ENABLED (DNS request/verify routes, list/register compatibility when off). Enterprise SSO docs and register scripts gain org ID and rollout/audit guidance.

E2E Step 6b wires a loopback Streamable HTTP MCP fake (mcp.e2e.sim.ai), profile env (ALLOWED_MCP_DOMAINS, SSO flags), orchestrator lifecycle/logging, retention seed + post-run probe, --repeat-each, and stricter leak checks. CI/docs map both E2E hostnames.

MCP product tweaks: connection test reports authType: 'none' for headerless success; settings MCP UI waits until server list and allowlist queries succeed before add/edit/test/delete, with clearer a11y labels.

Reviewed by Cursor Bugbot for commit f4c52c4. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands enterprise integration management and its end-to-end coverage. The main changes are:

  • Organization-scoped SSO management and verified-domain rollout controls.
  • SSO schema constraints, migration checks, and audit scripts.
  • Fail-closed data-retention readiness and restoration probes.
  • A session-aware MCP fake with create, edit, discovery, and deletion coverage.
  • CI hostname setup, diagnostics, cleanup, and rollout documentation.

Confidence Score: 4/5

The migration uniqueness window and the Sim runtime dependency need fixes before merging.

  • Active SSO writes can introduce duplicates while the unique indexes are being replaced.
  • A pruned Sim deployment can fail to resolve tldts when loading the SSO domain module.
  • The reviewed authorization, MCP, and retention paths otherwise use defensive guards and cleanup.

packages/db/migrations/0266_zippy_the_phantom.sql; apps/sim/package.json

Important Files Changed

Filename Overview
packages/db/migrations/0266_zippy_the_phantom.sql Adds SSO validation and constraints, but the index replacement sequence temporarily removes database uniqueness enforcement.
apps/sim/lib/auth/sso/domain.ts Adds registrable-domain normalization through tldts, which is not directly declared by the Sim workspace.
apps/sim/lib/auth/sso/management.ts Centralizes organization authorization, provider availability checks, account-link safety, configuration building, and error mapping.
apps/sim/app/api/auth/sso/providers/[id]/route.ts Adds guarded provider updates and deletion with immutable provider types and account-link checks.
apps/sim/e2e/fakes/mcp/server.ts Adds a session-aware Streamable HTTP MCP fake with request diagnostics and explicit shutdown handling.
apps/sim/e2e/scripts/run.ts Extends E2E orchestration with MCP startup, diagnostics, cleanup, retention restoration, and leak scanning.
apps/sim/ee/data-retention/components/data-retention-settings.tsx Adds fail-closed readiness and exact retention mutation and restoration behavior.

Sequence Diagram

sequenceDiagram
    participant Admin as Organization Admin
    participant API as SSO Facade
    participant Guard as Authorization Guards
    participant DB as PostgreSQL
    participant Auth as Better Auth

    Admin->>API: Manage SSO provider
    API->>Guard: Check session, role, plan, and ownership
    Guard->>DB: Load membership and provider
    DB-->>Guard: Organization-scoped context
    API->>DB: Check provider and domain availability
    API->>Auth: Run guarded mutation
    Auth->>DB: Persist provider state
    DB-->>Auth: Updated verification state
    Auth-->>API: Mutation result
    API-->>Admin: Redacted provider response
Loading

Reviews (1): Last reviewed commit: "test(e2e): cover enterprise integrations" | Re-trigger Greptile

Comment on lines +88 to +93
DROP INDEX CONCURRENTLY IF EXISTS "sso_provider_provider_id_unique";--> statement-breakpoint
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "sso_provider_provider_id_unique" ON "sso_provider" USING btree ("provider_id");--> statement-breakpoint
DROP INDEX CONCURRENTLY IF EXISTS "sso_provider_domain_lower_unique";--> statement-breakpoint
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "sso_provider_domain_lower_unique" ON "sso_provider" USING btree (lower("domain"));--> statement-breakpoint
DROP INDEX CONCURRENTLY IF EXISTS "sso_provider_organization_id_unique";--> statement-breakpoint
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "sso_provider_organization_id_unique" ON "sso_provider" USING btree ("organization_id") WHERE "organization_id" IS NOT NULL;--> statement-breakpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Uniqueness Gap During Index Rebuild

These statements drop the existing unique indexes before their replacements finish building. If SSO writes continue during that window, concurrent registrations can persist duplicate provider IDs, domains, or organization IDs; the subsequent unique-index build then fails and leaves the rollout incomplete. Keep the old indexes active until replacement indexes are valid, or enforce the documented write quiescence for the entire sequence.

@@ -1,28 +1,35 @@
import { domainToASCII } from 'node:url'
import { parse } from 'tldts'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Runtime Dependency Belongs To Sibling Package

This production module imports tldts, but the PR declares that dependency only in packages/db/package.json. A pruned or isolated Sim installation will not include a sibling workspace's dependency, so loading this SSO module fails with an unresolved package and auth-dependent routes cannot start. Declare tldts in apps/sim/package.json as well.

Comment thread apps/sim/lib/auth/sso/management.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/lib/auth/sso/management.ts
Comment thread apps/sim/app/api/auth/sso/providers/[id]/route.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/app/api/auth/sso/register/route.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/ee/sso/components/sso-settings.tsx
Comment thread apps/sim/app/api/auth/sso/providers/[id]/route.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/lib/auth/sso/management.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/lib/auth/sso/management.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/app/api/auth/sso/providers/[id]/route.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/app/api/auth/sso/providers/[id]/route.ts
Comment thread apps/sim/app/api/auth/sso/providers/[id]/route.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/app/api/auth/[...all]/route.ts
Comment thread packages/db/scripts/register-sso-provider.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a499ecd. Configure here.

Comment thread packages/db/scripts/audit-sso-providers.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@BillLeoutsakosvl346
BillLeoutsakosvl346 merged commit 1a631d9 into e2e/settings-playwright Jul 23, 2026
19 checks passed
@waleedlatif1
waleedlatif1 deleted the e2e/06b-enterprise-integrations branch July 23, 2026 06:42
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