Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions crates/contextforge-data-plane-lib/tests/gateway_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rmcp::{
model::{
CallToolRequestParams, CallToolResult, ClientCapabilities, ClientRequest, ContentBlock, ErrorCode,
GetPromptRequestParams, GetPromptResult, Implementation, InitializeRequestParams, ProgressNotificationParam,
ReadResourceRequestParams, Request, ResourceContents, Role as McpRole, ServerResult,
ProtocolVersion, ReadResourceRequestParams, Request, ResourceContents, Role as McpRole, ServerResult,
},
service::{NotificationContext, PeerRequestOptions, RequestHandle, RoleClient, RunningService},
};
Expand Down Expand Up @@ -667,8 +667,7 @@ async fn secrets_detection_pre_hook_respects_field_allowlist() {
assert_eq!(Some(&Value::from(ignored_secret)), args.get("ignored"));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn secrets_detection_resource_post_hook_redacts_password_resource() {
async fn assert_secrets_detection_redacts_password_resource(protocol_version: ProtocolVersion) {
let runtime = runtime_with_secrets_detection(
vec![cmf_hook_names::RESOURCE_POST_FETCH],
json!({
Expand All @@ -679,7 +678,14 @@ async fn secrets_detection_resource_post_hook_redacts_password_resource() {
)
.await;
let gateway = start_gateway(TEST_USER_ID, true, runtime).await;
let service = gateway.connect(TEST_USER_ID).await;
let client = support::create_client(TEST_USER_ID);
let service = if protocol_version == ProtocolVersion::V_2026_07_28 {
support::connect_modern_client(gateway.gateway_url(), client, support::modern_client_info()).await
} else {
support::connect_client_with_protocol(gateway.gateway_url().to_owned(), client, protocol_version)
.await
.expect("supported client connects")
};

for downstream_uri in ["file:///password.env".to_owned(), format!("{}__file:///password.env", gateway.backend_name)]
{
Expand All @@ -695,6 +701,16 @@ async fn secrets_detection_resource_post_hook_redacts_password_resource() {
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn secrets_detection_redacts_password_resource_for_2026_07_28() {
assert_secrets_detection_redacts_password_resource(ProtocolVersion::V_2026_07_28).await;
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn secrets_detection_redacts_password_resource_for_2025_11_25() {
assert_secrets_detection_redacts_password_resource(ProtocolVersion::V_2025_11_25).await;
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn pre_hook_rewrites_payload_without_changing_forwarded_parameter_headers() {
let plugin = Arc::new(TestPlugin::new("pre", vec![cmf_hook_names::TOOL_PRE_INVOKE]).with_pre_rewrite());
Expand Down
Loading