use axum::{
body::Body,
http::{Request, StatusCode},
};
use tower::ServiceExt; use indodax_cli::mcp::{AppState, handle_http_call};
use axum::{routing::post, Router};
use serde_json::json;
#[cfg(feature = "server")]
#[tokio::test]
async fn test_http_bridge_unauthorized_without_secret() {
let state = AppState {
groups: "market".into(),
allow_dangerous: false,
bridge_secret: Some("top-secret".into()),
};
let app = Router::new()
.route("/call/:tool_name", post(handle_http_call))
.with_state(state);
let response = app
.oneshot(
Request::builder()
.method("POST")
.uri("/call/ticker")
.header("content-type", "application/json")
.body(Body::from(json!({"pair": "btc_idr"}).to_string()))
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
}
#[cfg(feature = "server")]
#[tokio::test]
async fn test_http_bridge_health_simple() {
let state = AppState {
groups: "market".into(),
allow_dangerous: false,
bridge_secret: None,
};
assert_eq!(state.groups, "market");
}