use std::{collections::BTreeMap, sync::Arc};
use pretty_assertions::assert_eq;
use super::*;
fn map(pairs: &[(&str, &str)]) -> BTreeMap<String, String> {
pairs
.iter()
.map(|(name, value)| ((*name).to_owned(), (*value).to_owned()))
.collect()
}
#[test]
fn a_probe_hides_the_values_each_transport_is_given() {
let environment = Ambient::Client(Arc::new(map(&[
("STDIO_VAR", "stdio-from-env"),
("HTTP_VAR", "http-from-env"),
])));
let cases = [
(
"stdio",
McpTransport::Stdio {
command: "server".to_owned(),
args: Vec::new(),
cwd: None,
env: map(&[("LITERAL", "stdio-literal")]),
env_from_env: map(&[("FROM", "STDIO_VAR"), ("UNSET", "NOT_SET")]),
env_from_secret: vec!["SECRET".to_owned()],
},
vec!["stdio-literal", "stdio-from-env"],
),
(
"streamable http",
McpTransport::StreamableHttp {
url: "https://example.com/mcp".to_owned(),
headers: map(&[("X-Literal", "http-literal")]),
headers_from_env: map(&[("X-From", "HTTP_VAR")]),
headers_from_secret: vec!["Authorization".to_owned()],
oauth: None,
allow_insecure_http: false,
},
vec!["http-literal", "http-from-env"],
),
];
for (name, transport, expected) in cases {
assert_eq!(given_values(&transport, &environment), expected, "{name}");
}
}