Skip to content

fix: adds e2e tests for mcp headers auth, oauth and per-user oauth - #3467

Merged
akshaydeo merged 4 commits into
devfrom
05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth
May 15, 2026
Merged

akshaydeo merged 4 commits into
devfrom
05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth

Conversation

@sammaji

@sammaji sammaji commented May 13, 2026

Copy link
Copy Markdown
Member

Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (auth-demo-server on port 3002 and oauth-demo-server on port 3003).

Changes

  • Added createHeadersAuthClientData, createOAuthClientData, and createPerUserOAuthClientData factory functions in mcp-registry.data.ts for use in auth-related test scenarios.
  • Added three new test.describe blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
  • Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
  • Fixed selectAuthType to convert underscores to hyphens when resolving data-testid attributes (e.g., per_user_oauthauth-type-per-user-oauth).
  • Extended OAuth config form-filling to handle both oauth and per_user_oauth auth types, which share the same input fields.
  • Increased clientExists wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
  • Extended global-setup.ts to automatically build (if not already built) and spawn auth-demo-server and oauth-demo-server as background processes before the test suite runs, with graceful warnings if either server fails to start.
  • Added per_user_oauth to the MCPAuthType union type.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI
  • Tests

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs
  • Tests

How to test

Ensure the demo servers are available under examples/mcps/auth-demo-server and examples/mcps/oauth-demo-server. The global setup will build and start them automatically.

# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the oauth-demo-server using the credentials demo-user. Ensure the server is reachable at http://localhost:3003/mcp before running.

For header auth tests, the auth-demo-server must be reachable at http://localhost:3002/ and configured to accept X-API-Key: super-secret-key and X-Tool-Token: tool-exec-secret.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

Test credentials (super-secret-key, tool-exec-secret, demo-user) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7c513748-b905-4f5c-bf87-da0c5d9c3c24

📥 Commits

Reviewing files that changed from the base of the PR and between 46c15e2 and 8bd0b92.

📒 Files selected for processing (4)
  • tests/e2e/features/mcp-registry/mcp-registry.data.ts
  • tests/e2e/features/mcp-registry/mcp-registry.spec.ts
  • tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
  • tests/e2e/global-setup.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/global-setup.ts
  • tests/e2e/features/mcp-registry/mcp-registry.data.ts

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Expanded end-to-end coverage for MCP registry auth flows: headers, OAuth 2.0, and per-user OAuth 2.0 — includes UI field checks, inline validation assertions, and full creation flows.
    • Added reusable test client factories to simplify creating clients for each auth mode.
  • Chores
    • Enhanced test setup to start local demo servers during e2e runs to validate auth and registration behavior.

Walkthrough

Adds page-object support for per-user OAuth, refactors client action flows, updates MCP registry specs with display/cancel and full creation tests for headers, OAuth, and per-user OAuth, and adjusts form validation assertions and test imports.

Changes

MCP Authentication E2E Test Coverage

Layer / File(s) Summary
Page-object: auth type plumbing & actions
tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
Extend MCPAuthType with per_user_oauth; make clientExists use visibility assertion; normalize selectAuthType testid construction; run OAuth field filling for per_user_oauth; refactor reconnectClient and deleteClient to use row actions menu.
Spec imports & form validation updates
tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Import new client-data factories; remove the "require name" test; change name-format and connection-URL validations to submit the form and assert inline error messages.
Header-auth display + E2E
tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Add headers-auth display-fields + cancel test and a full header-auth client creation test that verifies the client and checks tools in client details.
OAuth 2.0 display + E2E
tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Add OAuth display-fields + cancel test and a full OAuth client creation test that opens the auth popup, completes login, and verifies the client appears in the registry.
Per-user OAuth display + E2E
tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Add per-user OAuth display-fields + cancel test and a full per-user OAuth creation test that uses test-login confirmation and the auth popup, then verifies the client in the registry.
sequenceDiagram
  participant Runner as Test Runner
  participant Setup as Global Setup
  participant Registry as Registry App
  participant Browser as Browser/Popup
  participant AuthDemo as Auth Demo Server (3002)
  participant OAuthDemo as OAuth Demo Server (3003)

  Runner->>Setup: runMCPSetup
  Setup->>AuthDemo: start auth-demo-server (3002)
  Setup->>OAuthDemo: start oauth-demo-server (3003)
  Runner->>Registry: open MCP registry UI
  Runner->>Browser: trigger create-client flows
  Browser->>Registry: submit client creation (headers / oauth / per_user_oauth)
  alt headers auth
    Registry->>AuthDemo: request tools with headers
    AuthDemo-->>Registry: return tool list
  else oauth / per_user_oauth
    Browser->>OAuthDemo: open auth popup / authorize
    OAuthDemo-->>Browser: complete login & redirect
    Browser->>Registry: popup closed, registry refreshed
  end
  Registry-->>Runner: client appears in registry
Loading

🎯 4 (Complex) | ⏱️ ~45 minutes

"🐰
Two servers hum at dawn,
Headers, OAuth — popups spawn,
Tests hop through fields with glee,
Clients found — a tasty tree! 🥕"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding e2e tests for three MCP authentication types (headers auth, OAuth, and per-user OAuth).
Description check ✅ Passed The description comprehensively covers all required template sections: summary, changes, type of change, affected areas, testing instructions, security considerations, and a complete checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth

Comment @coderabbitai help to get the list of available commands and usage tips.

sammaji commented May 13, 2026

Copy link
Copy Markdown
Member Author

@sammaji
sammaji marked this pull request as ready for review May 13, 2026 13:27
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 32cc6f3 to 444c1e7 Compare May 13, 2026 13:29

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/features/mcp-registry/mcp-registry.spec.ts`:
- Around line 409-436: The test is swallowing popup-close failures and only
checks client row existence (mcpRegistryPage.clientExists), causing false
positives; remove the .catch() on popup.waitForEvent('close') and await it
properly (e.g., await popup.waitForEvent('close', { timeout: 15000 })) so
failures surface, and replace or augment the simple existence assertion with a
post-auth success assertion (e.g., call a helper like
mcpRegistryPage.getClientStatus or mcpRegistryPage.clientIsConnected, or assert
a specific table cell/text such as "Connected" or presence of tools/actions for
that client row) after mcpRegistryPage.createClient and the popup flow to ensure
OAuth actually completed.

In `@tests/e2e/global-setup.ts`:
- Around line 324-392: The startup code for auth-demo-server and
oauth-demo-server currently only checks authServer.pid/oauthServer.pid and waits
1s, which can miss early failures; modify the blocks that spawn authServer
(symbol: authServer, auth-demo-server) and oauthServer (symbol: oauthServer,
oauth-demo-server) to call the existing checkServerReady function for ports 3002
and 3003 respectively after spawn and before logging success, and only push the
process into MCP_SERVERS and log "started" once checkServerReady resolves; keep
the existing pid/unref logic but wrap it so failures in binding cause the catch
branch to run and include these servers in the same readiness pattern used for
port 3001.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 92d25dc9-17a0-40dc-a4b2-ac4e80535132

📥 Commits

Reviewing files that changed from the base of the PR and between 6bea147 and 32cc6f3.

📒 Files selected for processing (4)
  • tests/e2e/features/mcp-registry/mcp-registry.data.ts
  • tests/e2e/features/mcp-registry/mcp-registry.spec.ts
  • tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
  • tests/e2e/global-setup.ts

Comment thread tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Comment thread tests/e2e/global-setup.ts
@greptile-apps

greptile-apps Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Test-only changes with no impact on production code; safe to merge once the open reliability concerns from earlier review rounds are resolved.

All changes are confined to the e2e test layer. The new test suites, data factories, and page-object helpers are well-structured. The known reliability issues (missing readiness polling for the new demo servers, unhandled error events on spawned processes, swallowed popup-close timeout, and the getToolsCount race) were identified and flagged in prior review rounds; no new blocking issues were found in this pass.

The open items in global-setup.ts (readiness polling, error-event handlers) and mcp-registry.spec.ts (popup-close assertion, tool-load race) are the areas most likely to cause intermittent CI failures and deserve a follow-up before this suite is relied upon in a CI gate.

Important Files Changed

Filename Overview
tests/e2e/features/mcp-registry/mcp-registry.data.ts Adds three new factory functions (createHeadersAuthClientData, createOAuthClientData, createPerUserOAuthClientData) for MCP auth test scenarios; clean additions with no issues.
tests/e2e/features/mcp-registry/mcp-registry.spec.ts Adds three new test suites for header auth, OAuth 2.0, and Per-User OAuth 2.0; removes a redundant test; popup-close timeout is silently swallowed and getToolsCount() snapshots before tools have loaded (both previously flagged).
tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts Adds per_user_oauth to the auth type union, fixes selectAuthType kebab-case conversion, upgrades clientExists to a Playwright assertion, extracts openClientActions helper, and migrates reconnectClient/deleteClient to the new actions menu; the fixed 5 s timeout in clientExists was previously flagged.
tests/e2e/global-setup.ts Extends global setup to build and spawn auth-demo-server and oauth-demo-server; missing readiness polling and error event handlers were both previously flagged, and the file is missing a trailing newline.

Reviews (8): Last reviewed commit: "fix: adds e2e tests for mcp headers auth..." | Re-trigger Greptile

Comment thread tests/e2e/global-setup.ts
Comment thread tests/e2e/global-setup.ts
Comment thread tests/e2e/features/mcp-registry/mcp-registry.spec.ts
Comment thread tests/e2e/global-setup.ts

@coderabbitai coderabbitai Bot left a comment

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.

♻️ Duplicate comments (1)
tests/e2e/global-setup.ts (1)

343-347: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Gate auth/oauth server startup on actual readiness before marking success.

Line 343 and Line 378 only gate on pid + sleep, so early bind failures can still be reported as “started,” and Line 388-391 then reports “ready” unconditionally. This can make the new auth/OAuth E2E flows flaky.

Suggested patch
+  let authReady = false
+  let oauthReady = false
+
   // Build and start auth-demo-server on port 3002
   try {
@@
     console.log('Starting auth-demo-server on port 3002...')
     const authServer = spawn(authServerExec, [], {
       cwd: authServerDir,
       detached: true,
       stdio: ['ignore', 'pipe', 'pipe'],
     })
     authServer.stdout?.on('data', (data) => console.log(`[Auth Server] ${data.toString().trim()}`))
     authServer.stderr?.on('data', (data) => console.error(`[Auth Server Error] ${data.toString().trim()}`))
-    if (authServer.pid) {
-      authServer.unref()
-      MCP_SERVERS.push(authServer)
-      await setTimeout(1000)
-      console.log('✓ auth-demo-server started on http://localhost:3002/')
-    }
+    if (!authServer.pid) throw new Error('Failed to start auth-demo-server - no PID assigned')
+    authReady = await checkServerReady(3002, 20)
+    if (!authReady) throw new Error('auth-demo-server failed readiness check on :3002')
+    authServer.unref()
+    MCP_SERVERS.push(authServer)
+    console.log('✓ auth-demo-server started on http://localhost:3002/')
   } catch (err) {
     console.warn(`⚠️  Failed to start auth-demo-server (header auth tests may skip): ${(err as Error).message}`)
   }
@@
     console.log('Starting oauth-demo-server on port 3003...')
     const oauthServer = spawn(oauthServerExec, [], {
       cwd: oauthServerDir,
       detached: true,
       stdio: ['ignore', 'pipe', 'pipe'],
     })
     oauthServer.stdout?.on('data', (data) => console.log(`[OAuth Server] ${data.toString().trim()}`))
     oauthServer.stderr?.on('data', (data) => console.error(`[OAuth Server Error] ${data.toString().trim()}`))
-    if (oauthServer.pid) {
-      oauthServer.unref()
-      MCP_SERVERS.push(oauthServer)
-      await setTimeout(1000)
-      console.log('✓ oauth-demo-server started on http://localhost:3003/')
-    }
+    if (!oauthServer.pid) throw new Error('Failed to start oauth-demo-server - no PID assigned')
+    oauthReady = await checkServerReady(3003, 20)
+    if (!oauthReady) throw new Error('oauth-demo-server failed readiness check on :3003')
+    oauthServer.unref()
+    MCP_SERVERS.push(oauthServer)
+    console.log('✓ oauth-demo-server started on http://localhost:3003/')
   } catch (err) {
     console.warn(`⚠️  Failed to start oauth-demo-server (OAuth tests may fail): ${(err as Error).message}`)
   }
@@
   console.log('✓ MCP servers ready')
   console.log('  - HTTP/SSE server: http://localhost:3001/')
-  console.log('  - Auth demo server: http://localhost:3002/')
-  console.log('  - OAuth demo server: http://localhost:3003/')
+  if (authReady) console.log('  - Auth demo server: http://localhost:3002/')
+  if (oauthReady) console.log('  - OAuth demo server: http://localhost:3003/')
   console.log('  - STDIO server: test-tools-server/dist/index.js')

Also applies to: 378-383, 388-391

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/global-setup.ts` around lines 343 - 347, The startup check
currently only verifies authServer.pid and waits a fixed timeout (authServer,
MCP_SERVERS, await setTimeout) which can falsely report success; instead gate
success on actual readiness by waiting for the child/server to emit a listening
event or by polling the server (e.g., an HTTP GET to http://localhost:3002/
until it responds 200 within a timeout) before pushing to MCP_SERVERS and
logging success; update all similar blocks (the ones around authServer usage at
the earlier and later ranges) to use the same readiness probe and fail/timeout
with a clear error if the probe does not succeed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@tests/e2e/global-setup.ts`:
- Around line 343-347: The startup check currently only verifies authServer.pid
and waits a fixed timeout (authServer, MCP_SERVERS, await setTimeout) which can
falsely report success; instead gate success on actual readiness by waiting for
the child/server to emit a listening event or by polling the server (e.g., an
HTTP GET to http://localhost:3002/ until it responds 200 within a timeout)
before pushing to MCP_SERVERS and logging success; update all similar blocks
(the ones around authServer usage at the earlier and later ranges) to use the
same readiness probe and fail/timeout with a clear error if the probe does not
succeed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7346eb59-dc9e-4a40-b014-27076a62437d

📥 Commits

Reviewing files that changed from the base of the PR and between 32cc6f3 and 444c1e7.

📒 Files selected for processing (4)
  • tests/e2e/features/mcp-registry/mcp-registry.data.ts
  • tests/e2e/features/mcp-registry/mcp-registry.spec.ts
  • tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
  • tests/e2e/global-setup.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
  • tests/e2e/features/mcp-registry/mcp-registry.spec.ts

@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 444c1e7 to 77573ac Compare May 13, 2026 13:46
Comment thread tests/e2e/features/mcp-registry/pages/mcp-registry.page.ts
@sammaji
sammaji marked this pull request as draft May 14, 2026 07:25
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 77573ac to fa5d218 Compare May 14, 2026 07:30
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch from 6bea147 to f3772b8 Compare May 14, 2026 07:30
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from fa5d218 to febbbba Compare May 14, 2026 08:08
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch from f3772b8 to 0851234 Compare May 14, 2026 08:08
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from febbbba to 3210390 Compare May 14, 2026 19:02
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch from 0851234 to 0526f0c Compare May 14, 2026 19:02
@sammaji
sammaji marked this pull request as ready for review May 14, 2026 19:03
Comment thread tests/e2e/global-setup.ts
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 3210390 to 1a9fad3 Compare May 14, 2026 19:49
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch 2 times, most recently from 1acb751 to d7445a0 Compare May 14, 2026 19:52
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch 2 times, most recently from 4639d59 to b9741d6 Compare May 14, 2026 19:54
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch 2 times, most recently from a474806 to 73d0466 Compare May 14, 2026 19:55
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from b9741d6 to 1ce451e Compare May 14, 2026 19:55
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch from 73d0466 to d9e850a Compare May 15, 2026 04:10
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 1ce451e to c70246a Compare May 15, 2026 04:10
@sammaji
sammaji force-pushed the 05-13-fix_updates_e2e_ui_tests_for_provider_management branch from d9e850a to 300d027 Compare May 15, 2026 04:24
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from c70246a to 46c15e2 Compare May 15, 2026 04:24
@sammaji
sammaji force-pushed the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch from 46c15e2 to 8bd0b92 Compare May 15, 2026 05:07
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 15, 2026
akshaydeo
akshaydeo previously approved these changes May 15, 2026

akshaydeo commented May 15, 2026

Copy link
Copy Markdown
Contributor

Merge activity

@akshaydeo
akshaydeo changed the base branch from 05-13-fix_updates_e2e_ui_tests_for_provider_management to graphite-base/3467 May 15, 2026 05:53
@akshaydeo
akshaydeo changed the base branch from graphite-base/3467 to dev May 15, 2026 05:53
@akshaydeo
akshaydeo dismissed stale reviews from coderabbitai[bot] and themself May 15, 2026 05:53

The base branch was changed.

@akshaydeo
akshaydeo merged commit 0914e31 into dev May 15, 2026
10 of 11 checks passed
@akshaydeo
akshaydeo deleted the 05-13-fix_adds_e2e_tests_for_mcp_headers_auth_oauth_and_per-user_oauth branch May 15, 2026 05:54
akshaydeo pushed a commit that referenced this pull request May 15, 2026
…3467)

## Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (`auth-demo-server` on port 3002 and `oauth-demo-server` on port 3003).

## Changes

- Added `createHeadersAuthClientData`, `createOAuthClientData`, and `createPerUserOAuthClientData` factory functions in `mcp-registry.data.ts` for use in auth-related test scenarios.
- Added three new `test.describe` blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
- Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
- Fixed `selectAuthType` to convert underscores to hyphens when resolving `data-testid` attributes (e.g., `per_user_oauth` → `auth-type-per-user-oauth`).
- Extended OAuth config form-filling to handle both `oauth` and `per_user_oauth` auth types, which share the same input fields.
- Increased `clientExists` wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
- Extended `global-setup.ts` to automatically build (if not already built) and spawn `auth-demo-server` and `oauth-demo-server` as background processes before the test suite runs, with graceful warnings if either server fails to start.
- Added `per_user_oauth` to the `MCPAuthType` union type.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
- [x] Tests

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
- [x] Tests

## How to test

Ensure the demo servers are available under `examples/mcps/auth-demo-server` and `examples/mcps/oauth-demo-server`. The global setup will build and start them automatically.

```sh
# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts
```

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the `oauth-demo-server` using the credentials `demo-user`. Ensure the server is reachable at `http://localhost:3003/mcp` before running.

For header auth tests, the `auth-demo-server` must be reachable at `http://localhost:3002/` and configured to accept `X-API-Key: super-secret-key` and `X-Tool-Token: tool-exec-secret`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Test credentials (`super-secret-key`, `tool-exec-secret`, `demo-user`) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request May 15, 2026
…3467)

## Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (`auth-demo-server` on port 3002 and `oauth-demo-server` on port 3003).

## Changes

- Added `createHeadersAuthClientData`, `createOAuthClientData`, and `createPerUserOAuthClientData` factory functions in `mcp-registry.data.ts` for use in auth-related test scenarios.
- Added three new `test.describe` blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
- Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
- Fixed `selectAuthType` to convert underscores to hyphens when resolving `data-testid` attributes (e.g., `per_user_oauth` → `auth-type-per-user-oauth`).
- Extended OAuth config form-filling to handle both `oauth` and `per_user_oauth` auth types, which share the same input fields.
- Increased `clientExists` wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
- Extended `global-setup.ts` to automatically build (if not already built) and spawn `auth-demo-server` and `oauth-demo-server` as background processes before the test suite runs, with graceful warnings if either server fails to start.
- Added `per_user_oauth` to the `MCPAuthType` union type.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
- [x] Tests

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
- [x] Tests

## How to test

Ensure the demo servers are available under `examples/mcps/auth-demo-server` and `examples/mcps/oauth-demo-server`. The global setup will build and start them automatically.

```sh
# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts
```

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the `oauth-demo-server` using the credentials `demo-user`. Ensure the server is reachable at `http://localhost:3003/mcp` before running.

For header auth tests, the `auth-demo-server` must be reachable at `http://localhost:3002/` and configured to accept `X-API-Key: super-secret-key` and `X-Tool-Token: tool-exec-secret`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Test credentials (`super-secret-key`, `tool-exec-secret`, `demo-user`) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
@coderabbitai coderabbitai Bot mentioned this pull request May 20, 2026
18 tasks
akshaydeo pushed a commit that referenced this pull request May 20, 2026
…3467)

## Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (`auth-demo-server` on port 3002 and `oauth-demo-server` on port 3003).

## Changes

- Added `createHeadersAuthClientData`, `createOAuthClientData`, and `createPerUserOAuthClientData` factory functions in `mcp-registry.data.ts` for use in auth-related test scenarios.
- Added three new `test.describe` blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
- Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
- Fixed `selectAuthType` to convert underscores to hyphens when resolving `data-testid` attributes (e.g., `per_user_oauth` → `auth-type-per-user-oauth`).
- Extended OAuth config form-filling to handle both `oauth` and `per_user_oauth` auth types, which share the same input fields.
- Increased `clientExists` wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
- Extended `global-setup.ts` to automatically build (if not already built) and spawn `auth-demo-server` and `oauth-demo-server` as background processes before the test suite runs, with graceful warnings if either server fails to start.
- Added `per_user_oauth` to the `MCPAuthType` union type.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
- [x] Tests

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
- [x] Tests

## How to test

Ensure the demo servers are available under `examples/mcps/auth-demo-server` and `examples/mcps/oauth-demo-server`. The global setup will build and start them automatically.

```sh
# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts
```

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the `oauth-demo-server` using the credentials `demo-user`. Ensure the server is reachable at `http://localhost:3003/mcp` before running.

For header auth tests, the `auth-demo-server` must be reachable at `http://localhost:3002/` and configured to accept `X-API-Key: super-secret-key` and `X-Tool-Token: tool-exec-secret`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Test credentials (`super-secret-key`, `tool-exec-secret`, `demo-user`) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…aximhq#3467)

## Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (`auth-demo-server` on port 3002 and `oauth-demo-server` on port 3003).

## Changes

- Added `createHeadersAuthClientData`, `createOAuthClientData`, and `createPerUserOAuthClientData` factory functions in `mcp-registry.data.ts` for use in auth-related test scenarios.
- Added three new `test.describe` blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
- Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
- Fixed `selectAuthType` to convert underscores to hyphens when resolving `data-testid` attributes (e.g., `per_user_oauth` → `auth-type-per-user-oauth`).
- Extended OAuth config form-filling to handle both `oauth` and `per_user_oauth` auth types, which share the same input fields.
- Increased `clientExists` wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
- Extended `global-setup.ts` to automatically build (if not already built) and spawn `auth-demo-server` and `oauth-demo-server` as background processes before the test suite runs, with graceful warnings if either server fails to start.
- Added `per_user_oauth` to the `MCPAuthType` union type.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
- [x] Tests

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
- [x] Tests

## How to test

Ensure the demo servers are available under `examples/mcps/auth-demo-server` and `examples/mcps/oauth-demo-server`. The global setup will build and start them automatically.

```sh
# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts
```

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the `oauth-demo-server` using the credentials `demo-user`. Ensure the server is reachable at `http://localhost:3003/mcp` before running.

For header auth tests, the `auth-demo-server` must be reachable at `http://localhost:3002/` and configured to accept `X-API-Key: super-secret-key` and `X-Tool-Token: tool-exec-secret`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Test credentials (`super-secret-key`, `tool-exec-secret`, `demo-user`) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…aximhq#3467)

## Summary

Adds end-to-end test coverage for MCP header-based authentication, OAuth 2.0, and Per-User OAuth 2.0 auth flows. This includes new test data factories, test suites exercising the full authorization flow (including popup-based browser consent), and global setup automation to build and start the required demo servers (`auth-demo-server` on port 3002 and `oauth-demo-server` on port 3003).

## Changes

- Added `createHeadersAuthClientData`, `createOAuthClientData`, and `createPerUserOAuthClientData` factory functions in `mcp-registry.data.ts` for use in auth-related test scenarios.
- Added three new `test.describe` blocks covering header auth UI visibility, header auth client creation and tool discovery, OAuth 2.0 field display and full browser popup authorization flow, and Per-User OAuth 2.0 field display and consent-then-popup authorization flow.
- Removed the redundant "should require name for client" test that duplicated coverage already provided by the name format validation test.
- Fixed `selectAuthType` to convert underscores to hyphens when resolving `data-testid` attributes (e.g., `per_user_oauth` → `auth-type-per-user-oauth`).
- Extended OAuth config form-filling to handle both `oauth` and `per_user_oauth` auth types, which share the same input fields.
- Increased `clientExists` wait time from 500 ms to 5000 ms to accommodate the latency introduced by OAuth redirect flows.
- Extended `global-setup.ts` to automatically build (if not already built) and spawn `auth-demo-server` and `oauth-demo-server` as background processes before the test suite runs, with graceful warnings if either server fails to start.
- Added `per_user_oauth` to the `MCPAuthType` union type.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
- [x] Tests

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
- [x] Tests

## How to test

Ensure the demo servers are available under `examples/mcps/auth-demo-server` and `examples/mcps/oauth-demo-server`. The global setup will build and start them automatically.

```sh
# Run the full e2e suite (global setup handles server lifecycle)
cd tests/e2e
pnpm exec playwright test features/mcp-registry/mcp-registry.spec.ts
```

For the OAuth and Per-User OAuth tests, the suite opens a browser popup and completes a login form on the `oauth-demo-server` using the credentials `demo-user`. Ensure the server is reachable at `http://localhost:3003/mcp` before running.

For header auth tests, the `auth-demo-server` must be reachable at `http://localhost:3002/` and configured to accept `X-API-Key: super-secret-key` and `X-Tool-Token: tool-exec-secret`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Test credentials (`super-secret-key`, `tool-exec-secret`, `demo-user`) are hardcoded exclusively for local demo servers used in the e2e test environment and are not used in any production path.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
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.

2 participants