Skip to content

Commit ef94194

Browse files
committed
test(gateway): full inbound OAuth E2E proves auth-enabled flow is intact
Adds a real end-to-end test of the AUTH-REQUIRED path so we can guarantee the "disable auth" feature never silently regresses real OAuth. It drives the actual production handlers over HTTP against a gateway with inbound auth required + a JWT secret configured: DCR register → authorize (consent page, request_id) → consent approve (redirect with code) → token exchange (PKCE S256) → authenticated /mcp handshake returns 200; the same handshake with no token returns 401. To mount the flow in a self-contained harness, expose the OAuth handlers (oauth_register/authorize/token/consent_approve) from the server module, the same way the discovery handlers were already exposed for tests. Together with the disabled-side coverage (anonymous real handshake + list_tools, discovery 404 incl. the RFC 9728 /mcp sub-path), both auth modes are now proven end to end. Claude-Session: https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent e73933a commit ef94194

5 files changed

Lines changed: 363 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/mcpmux-gateway/src/server/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ mod startup;
1313
mod state;
1414

1515
// Exposed for integration tests that mount these routes against a real
16-
// ServiceContainer (e.g. asserting the OAuth-discovery endpoints 404 when
17-
// inbound auth is disabled). AppState is also used throughout this module.
18-
pub use handlers::{oauth_metadata, resource_metadata, AppState};
16+
// ServiceContainer — e.g. asserting the OAuth-discovery endpoints 404 when
17+
// inbound auth is disabled, and driving the full inbound OAuth flow
18+
// (register → authorize → consent → token → authenticated /mcp) end to end.
19+
// AppState is also used throughout this module.
20+
pub use handlers::{
21+
oauth_authorize, oauth_consent_approve, oauth_metadata, oauth_register, oauth_token,
22+
resource_metadata, AppState,
23+
};
1924

2025
pub use dependencies::{DependenciesBuilder, GatewayDependencies};
2126
pub use handlers::PendingAuthorization;

tests/rust/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ reqwest = { version = "0.13", features = ["json"] }
4646
# URL parsing for OAuth tests
4747
url = "2.5"
4848

49+
# PKCE + JWT-secret material for the inbound-OAuth end-to-end test
50+
base64 = "0.22"
51+
sha2 = "0.10"
52+
zeroize = "1.8"
53+
4954
# Sync primitives for tests
5055
parking_lot = "0.12"
5156

0 commit comments

Comments
 (0)