Skip to content

feat(tests): Add RBAC + multi-transport MCP protocol E2E tests - #3424

Merged
crivetimihai merged 4 commits into
mainfrom
mcp-cli-investigation
Mar 3, 2026
Merged

crivetimihai merged 4 commits into
mainfrom
mcp-cli-investigation

Conversation

@crivetimihai

Copy link
Copy Markdown
Member

Summary

  • Add 40 new E2E tests covering RBAC visibility, token scope enforcement, SSE transport, per-server MCP endpoints, and security deny paths through the MCP JSON-RPC protocol
  • Extract shared MCP test helpers into tests/e2e/mcp_test_helpers.py (used by both existing and new tests)
  • Add register_fast_time_sse docker-compose service for always-available SSE gateway
  • Add make test-mcp-rbac target

Test classes (tests/e2e/test_mcp_rbac_transport.py)

Class Tests Coverage
TestServerVisibilityViaAPI 5 REST API server visibility per role
TestMcpToolsVisibilityByRole 5 MCP tools/list per user role
TestMcpResourcesPromptsByRole 4 MCP resources/list + prompts/list
TestMcpToolCallByRole 6 Tool execution RBAC enforcement
TestMcpScopedTokenPermissions 3 Token scope containment via MCP
TestMcpSSETransport 5 SSE transport end-to-end
TestMcpPerServerEndpoint 4 /servers/{UUID}/mcp scoped access
TestDenyPaths 6 Security invariant deny paths
TestCrossTransportConsistency 2 Cross-transport result consistency

Key design decisions

  • All user/team/role/token setup via real REST API calls (Playwright APIRequestContext), not JWT shortcuts
  • Team membership via POST /teams/{id}/members (admin direct add) for reliability
  • Tests assert actual RBAC behavior: team-scoped roles (developer, viewer) are denied tools.execute on the default /mcp endpoint because it checks global scope only
  • Scoped tokens (scope.permissions) are correctly blocked at HTTP middleware when missing servers.use
  • No changes to application code — all fixes are test expectation corrections

Test plan

  • make test-mcp-cli — 22 existing tests pass (no regression)
  • make test-mcp-rbac — 40 new tests pass
  • Idempotent on re-runs (handles 400/409 for duplicate resources)

Add 40 new E2E tests covering multi-user RBAC visibility, token scope
enforcement, SSE transport, per-server MCP endpoints, and security deny
paths through the MCP JSON-RPC protocol via mcpgateway.wrapper.

- Extract shared helpers into tests/e2e/mcp_test_helpers.py
- Add tests/e2e/test_mcp_rbac_transport.py with 9 test classes:
  TestServerVisibilityViaAPI, TestMcpToolsVisibilityByRole,
  TestMcpResourcesPromptsByRole, TestMcpToolCallByRole,
  TestMcpScopedTokenPermissions, TestMcpSSETransport,
  TestMcpPerServerEndpoint, TestDenyPaths, TestCrossTransportConsistency
- Add register_fast_time_sse docker-compose service for SSE gateway
- Add make test-mcp-rbac target
- Refactor test_mcp_cli_protocol.py to import from shared helpers

Signed-off-by: Mihai Criveti <[email protected]>
@crivetimihai crivetimihai self-assigned this Mar 3, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0-RC2 milestone Mar 3, 2026
…ering

The docker-compose stack now pre-registers an SSE gateway at
http://fast_time_server:8080/sse. The E2E RBAC test fixture cleanup
only matched by name, missing the docker-compose gateway and hitting
a GatewayDuplicateConflictError (409) on re-registration.

Signed-off-by: Mihai Criveti <[email protected]>
@crivetimihai
crivetimihai merged commit b4d8770 into main Mar 3, 2026
6 of 7 checks passed
@crivetimihai
crivetimihai deleted the mcp-cli-investigation branch March 3, 2026 12:25
MohanLaksh pushed a commit that referenced this pull request Mar 12, 2026
* feat(tests): Add RBAC + multi-transport MCP protocol E2E tests

Add 40 new E2E tests covering multi-user RBAC visibility, token scope
enforcement, SSE transport, per-server MCP endpoints, and security deny
paths through the MCP JSON-RPC protocol via mcpgateway.wrapper.

- Extract shared helpers into tests/e2e/mcp_test_helpers.py
- Add tests/e2e/test_mcp_rbac_transport.py with 9 test classes:
  TestServerVisibilityViaAPI, TestMcpToolsVisibilityByRole,
  TestMcpResourcesPromptsByRole, TestMcpToolCallByRole,
  TestMcpScopedTokenPermissions, TestMcpSSETransport,
  TestMcpPerServerEndpoint, TestDenyPaths, TestCrossTransportConsistency
- Add register_fast_time_sse docker-compose service for SSE gateway
- Add make test-mcp-rbac target
- Refactor test_mcp_cli_protocol.py to import from shared helpers

Signed-off-by: Mihai Criveti <[email protected]>

* fix(tests): clean up pre-existing SSE gateway by URL before re-registering

The docker-compose stack now pre-registers an SSE gateway at
http://fast_time_server:8080/sse. The E2E RBAC test fixture cleanup
only matched by name, missing the docker-compose gateway and hitting
a GatewayDuplicateConflictError (409) on re-registration.

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
msureshkumar88 pushed a commit that referenced this pull request May 13, 2026
* feat(tests): Add RBAC + multi-transport MCP protocol E2E tests

Add 40 new E2E tests covering multi-user RBAC visibility, token scope
enforcement, SSE transport, per-server MCP endpoints, and security deny
paths through the MCP JSON-RPC protocol via mcpgateway.wrapper.

- Extract shared helpers into tests/e2e/mcp_test_helpers.py
- Add tests/e2e/test_mcp_rbac_transport.py with 9 test classes:
  TestServerVisibilityViaAPI, TestMcpToolsVisibilityByRole,
  TestMcpResourcesPromptsByRole, TestMcpToolCallByRole,
  TestMcpScopedTokenPermissions, TestMcpSSETransport,
  TestMcpPerServerEndpoint, TestDenyPaths, TestCrossTransportConsistency
- Add register_fast_time_sse docker-compose service for SSE gateway
- Add make test-mcp-rbac target
- Refactor test_mcp_cli_protocol.py to import from shared helpers

Signed-off-by: Mihai Criveti <[email protected]>

* fix(tests): clean up pre-existing SSE gateway by URL before re-registering

The docker-compose stack now pre-registers an SSE gateway at
http://fast_time_server:8080/sse. The E2E RBAC test fixture cleanup
only matched by name, missing the docker-compose gateway and hitting
a GatewayDuplicateConflictError (409) on re-registration.

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
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