Files
suaveplan/openspec/archive/2026-05-26-testing-integration-oauth-mock/tasks.md
2026-05-27 23:29:53 +01:00

2.6 KiB

Tasks — testing-integration-oauth-mock

1. Package scaffold

  • 1.1 Create packages/testkit/testing/testing-integration-oauth-mock/ with package.json, tsconfig.json, vitest.config.ts, README.md.
  • 1.2 No @suaveplan/* runtime deps (rule 8). Types-only @suaveplan/types allowed if needed.
  • 1.3 package.json exports: . (root), ./testing (conformance helpers if any), ./package.json.

2. Implementation (feature folders per CLAUDE.md)

  • 2.1 src/server/server.ts — createMockOauthIdp(opts) factory; Bun.serve HTTP server; ephemeral port; stop() returns Promise<void>.
  • 2.2 src/endpoints/authorize.ts — GET /authorize (state echo, PKCE challenge capture, redirect with code).
  • 2.3 src/endpoints/token.ts — POST /token (code-exchange, PKCE verify, refresh-token flow, configurable expiry).
  • 2.4 src/endpoints/userinfo.ts — GET /userinfo (bearer auth; primed user payload).
  • 2.5 src/endpoints/openid.ts — /.well-known/openid-configuration + /jwks.json (gated on openid: true).
  • 2.6 src/control/primer.ts — primeUser/primeError queues; FIFO consumption.
  • 2.7 src/control/audit.ts — lastRequest/allRequests snapshot (frozen).
  • 2.8 src/shapes/github.ts, src/shapes/google.ts, src/shapes/generic.ts — default user payloads.
  • 2.9 src/error-codes/ — OAUTH_MOCK_* registry.
  • 2.10 Sibling .md for every implementation file (≥200 words, all sections).

3. Tests

  • 3.1 Each endpoint has a colocated .test.ts exercising happy path + every error path. 100% istanbul on touched modules.
  • 3.2 End-to-end test in src/server/server.test.ts drives a full /authorize → callback → /token → /userinfo round-trip via real HTTP.
  • 3.3 PKCE flow tested with both plain and S256 challenges.
  • 3.4 RFC-6749 error responses tested (access_denied, invalid_grant, invalid_request).
  • 3.5 Test files import from @suaveplan/testing/runner (rule 11). NOTE: this package is rule-8 testing-infrastructure but NOT on the rule-11 exempt allowlist, so the @suaveplan/testing/runner import is required.

4. Pre-publish gate

  • 4.1 bunx turbo lint typecheck test --filter=@suaveplan/testing-integration-oauth-mock green.
  • 4.2 bunx turbo test:coverage --filter=@suaveplan/testing-integration-oauth-mock 100%.
  • 4.3 bun scripts/folder-reorg/generate-manifest.ts to refresh MANIFEST.md.

5. Archive

  • 5.1 Fold delta into openspec/specs/testing-integration-oauth-mock/spec.md.
  • 5.2 Move folder to openspec/archive/2026-05-26-testing-integration-oauth-mock/.