From 293b7115986b0458926e3f970f46ce200d3b1082 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Thu, 3 Sep 2026 11:22:27 +0100 Subject: [PATCH] test: cover resource hooks across MCP versions Signed-off-by: lucarlig --- .../tests/secrets_detection_e2e.rs | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/crates/contextforge-data-plane/tests/secrets_detection_e2e.rs b/crates/contextforge-data-plane/tests/secrets_detection_e2e.rs index 12475d5..3ad34b6 100644 --- a/crates/contextforge-data-plane/tests/secrets_detection_e2e.rs +++ b/crates/contextforge-data-plane/tests/secrets_detection_e2e.rs @@ -25,8 +25,8 @@ use rmcp::{ ErrorData, RoleClient, RoleServer, ServerHandler, ServiceExt, model::{ CallToolRequestParams, CallToolResponse, CallToolResult, ClientCapabilities, ContentBlock, ErrorCode, - Implementation, InitializeRequestParams, InitializeResult, ReadResourceRequestParams, ReadResourceResponse, - ReadResourceResult, ResourceContents, ServerCapabilities, + Implementation, InitializeRequestParams, InitializeResult, ProtocolVersion, ReadResourceRequestParams, + ReadResourceResponse, ReadResourceResult, ResourceContents, ServerCapabilities, }, service::{RequestContext, ServiceError}, transport::{ @@ -187,7 +187,7 @@ struct E2eEnvironment { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "spawns redis-server and the contextforge-data-plane binary"] -async fn binary_e2e_redacts_tool_arguments_results_and_resources() { +async fn binary_e2e_redacts_tool_arguments_and_results() { let backend = start_backend().await; let env = start_environment( backend, @@ -221,6 +221,32 @@ async fn binary_e2e_redacts_tool_arguments_results_and_resources() { .expect("secret result is redacted and call succeeds"); assert_eq!(REDACTED, tool_text(&result)); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "spawns redis-server and the contextforge-data-plane binary"] +async fn binary_e2e_redacts_resource_for_2026_07_28() { + assert_binary_e2e_redacts_resource(ProtocolVersion::V_2026_07_28).await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "spawns redis-server and the contextforge-data-plane binary"] +async fn binary_e2e_redacts_resource_for_2025_11_25() { + assert_binary_e2e_redacts_resource(ProtocolVersion::V_2025_11_25).await; +} + +async fn assert_binary_e2e_redacts_resource(protocol_version: ProtocolVersion) { + let backend = start_backend().await; + let env = start_environment( + backend, + json!({ + "redact": true, + "redaction_text": REDACTED, + "block_on_detection": false, + }), + ) + .await; + let service = connect_client_with_protocol(&env.gateway_url, protocol_version).await; let result = service .read_resource(ReadResourceRequestParams::new("file:///password.env")) @@ -457,6 +483,13 @@ async fn write_runtime_plugin_config(redis_port: u16, plugin_config: Value) { } async fn connect_client(gateway_url: &str) -> rmcp::service::RunningService { + connect_client_with_protocol(gateway_url, ProtocolVersion::V_2026_07_28).await +} + +async fn connect_client_with_protocol( + gateway_url: &str, + protocol_version: ProtocolVersion, +) -> rmcp::service::RunningService { let mut headers = HeaderMap::new(); headers.insert( http::header::AUTHORIZATION, @@ -467,10 +500,20 @@ async fn connect_client(gateway_url: &str) -> rmcp::service::RunningService CallToolRequestParams {