исправить: закрыть ревью сквозной корреляции
CI / Rust Checks (pull_request) Successful in 8m33s
CI / UI Checks (pull_request) Successful in 5s
CI / Frontend E2E (pull_request) Successful in 6m51s
CI / Community Image Smoke (pull_request) Failing after 9m10s
CI / Deploy (pull_request) Has been skipped

This commit is contained in:
2026-07-31 02:37:45 +03:00
parent 0e8f1ca03a
commit 9a7d60593a
28 changed files with 667 additions and 98 deletions
@@ -518,6 +518,55 @@ async fn approval_http_endpoints_enforce_request_rate_limit() {
assert!(limited.headers().contains_key(header::RETRY_AFTER));
}
#[tokio::test]
async fn unverified_session_ids_do_not_create_approval_rate_limit_buckets() {
let registry = test_registry().await;
let upstream_base_url = spawn_upstream_server().await;
let operation = test_operation(&upstream_base_url, "crm_approval_session_rate_limit");
registry
.create_operation(&test_workspace_id(), &operation, Some("alice"))
.await
.unwrap();
publish_agent_for_operation(&registry, &operation, "sales-approval-session-rate-limit").await;
let approval_key = create_approval_platform_api_key(
&registry,
"sales-approval-session-rate-limit",
"approval-session-rate-limit",
)
.await;
let base_url = spawn_mcp_server(build_test_app_with_rate_limit(
registry,
Duration::from_millis(0),
Some("https://crank.example.com".to_owned()),
RequestRateLimitConfig::new(1, 1).unwrap(),
))
.await;
let approvals_url = format!(
"{}/approvals",
agent_mcp_url(&base_url, "sales-approval-session-rate-limit")
);
let client = reqwest::Client::new();
let allowed = client
.get(&approvals_url)
.header(header::AUTHORIZATION, format!("Bearer {approval_key}"))
.header("MCP-Session-Id", "unverified-session-a")
.send()
.await
.unwrap();
assert_eq!(allowed.status(), reqwest::StatusCode::OK);
let limited = client
.get(&approvals_url)
.header(header::AUTHORIZATION, format!("Bearer {approval_key}"))
.header("MCP-Session-Id", "unverified-session-b")
.send()
.await
.unwrap();
assert_eq!(limited.status(), reqwest::StatusCode::TOO_MANY_REQUESTS);
assert!(limited.headers().contains_key(header::RETRY_AFTER));
}
#[tokio::test]
async fn recovery_does_not_repeat_interrupted_mutating_approval() {
let registry = test_registry().await;
@@ -5,7 +5,7 @@ use std::{
use axum::{
body::Body,
http::{Request, StatusCode},
http::{HeaderValue, Request, StatusCode},
};
use opentelemetry::{
global,
@@ -23,9 +23,11 @@ use tracing_subscriber::layer::SubscriberExt;
use super::common::{build_test_app, test_registry};
const REMOTE_TRACE_ID: &str = "0af7651916cd43dd8448eb211c80319c";
static TRACING_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
#[tokio::test(flavor = "current_thread")]
async fn covers_valid_invalid_and_absent_traceparent_on_mcp_boundary() {
let _tracing_test_guard = TRACING_TEST_LOCK.lock().await;
global::set_text_map_propagator(TraceContextPropagator::new());
let exported = Arc::new(Mutex::new(Vec::new()));
let provider = SdkTracerProvider::builder()
@@ -81,6 +83,37 @@ async fn covers_valid_invalid_and_absent_traceparent_on_mcp_boundary() {
provider.shutdown().unwrap();
}
#[tokio::test]
async fn replaces_multiple_request_id_headers_with_one_uuid_v7() {
let _tracing_test_guard = TRACING_TEST_LOCK.lock().await;
let app = build_test_app(test_registry().await, Duration::ZERO, None);
let mut request = Request::builder()
.uri("/health")
.body(Body::empty())
.unwrap();
request
.headers_mut()
.append("x-request-id", HeaderValue::from_static("first-request-id"));
request.headers_mut().append(
"x-request-id",
HeaderValue::from_static("second-request-id"),
);
let response = app
.oneshot(request)
.with_subscriber(tracing_subscriber::registry())
.await
.unwrap();
let generated = response.headers()["x-request-id"].to_str().unwrap();
assert_ne!(generated, "first-request-id");
assert_ne!(generated, "second-request-id");
assert_eq!(
uuid::Uuid::parse_str(generated).unwrap().get_version(),
Some(uuid::Version::SortRand)
);
}
async fn send_health(
app: axum::Router,
traceparent: Option<&str>,