mod common;
use common::TestRig;
use reqwest::StatusCode;
#[tokio::test]
async fn delete_then_post_returns_404() {
let rig = TestRig::new(vec![]).await;
let http = reqwest::Client::new();
let init_resp = http
.post(&rig.proxy.url)
.header("Content-Type", "application/json")
.header("Accept", "application/json, text/event-stream")
.body(
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{
"protocolVersion":"2025-06-18",
"capabilities":{},
"clientInfo":{"name":"t","version":"0"}
}}"#,
)
.send()
.await
.unwrap();
assert_eq!(init_resp.status(), StatusCode::OK);
let session_id = init_resp
.headers()
.get("Mcp-Session-Id")
.expect("Mcp-Session-Id on initialize response")
.to_str()
.unwrap()
.to_string();
let _ = init_resp.text().await.unwrap();
let del_resp = http
.delete(&rig.proxy.url)
.header("Mcp-Session-Id", &session_id)
.send()
.await
.unwrap();
assert_eq!(del_resp.status(), StatusCode::OK);
let post_resp = http
.post(&rig.proxy.url)
.header("Content-Type", "application/json")
.header("Accept", "application/json, text/event-stream")
.header("Mcp-Session-Id", &session_id)
.body(r#"{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}"#)
.send()
.await
.unwrap();
assert_eq!(post_resp.status(), StatusCode::NOT_FOUND);
let del2_resp = http
.delete(&rig.proxy.url)
.header("Mcp-Session-Id", &session_id)
.send()
.await
.unwrap();
assert_eq!(del2_resp.status(), StatusCode::NOT_FOUND);
}