//! End-to-end test for `mcptest run --insecure-skip-verify`.
//!
//! The flag exists for self-signed staging endpoints and is dangerous in
//! production, so the runner emits a loud WARNING banner on stderr whenever
//! it is set. This test pins the banner so a future change cannot silence
//! it without updating the test.

use assert_cmd::Command;
use predicates::prelude::*;
use tempfile::tempdir;

fn mcptest() -> Command {
    Command::cargo_bin("mcptest").expect("binary builds")
}

#[test]
fn run_with_insecure_skip_verify_emits_warning_banner() {
    let dir = tempdir().unwrap();
    mcptest()
        .current_dir(dir.path())
        .args(["--insecure-skip-verify", "run"])
        .assert()
        .success()
        .stdout(predicate::str::contains("--insecure-skip-verify"))
        .stderr(predicate::str::contains("WARNING"))
        .stderr(predicate::str::contains("verification is OFF"));
}

#[test]
fn run_without_flag_does_not_emit_warning_banner() {
    let dir = tempdir().unwrap();
    mcptest()
        .current_dir(dir.path())
        .args(["run"])
        .assert()
        .success()
        .stderr(predicate::str::contains("WARNING").not());
}

#[test]
fn run_with_ca_bundle_and_http_timeouts_names_each_flag_in_banner() {
    let dir = tempdir().unwrap();
    mcptest()
        .current_dir(dir.path())
        .args([
            "--ca-bundle",
            "/tmp/ca.pem",
            "--http-timeout",
            "45",
            "--connect-timeout",
            "3",
            "run",
        ])
        .assert()
        .success()
        .stdout(predicate::str::contains("--ca-bundle"))
        .stdout(predicate::str::contains("--http-timeout"))
        .stdout(predicate::str::contains("--connect-timeout"));
}
