Normalize endpoint API root handling

This commit is contained in:
fawney19
2026-05-29 02:29:33 +08:00
parent ef2953038e
commit b59c724455
46 changed files with 1179 additions and 205 deletions
@@ -365,7 +365,7 @@ async fn gateway_executes_openai_chat_sync_upstream_stream_via_local_finalize_re
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
vec![sample_provider_catalog_provider()],
vec![sample_provider_catalog_endpoint(
"https://api.openai.example",
"https://api.openai.example/v1",
)],
vec![sample_provider_catalog_key()],
));
@@ -126,7 +126,7 @@ fn sample_local_openai_endpoint() -> StoredProviderCatalogEndpoint {
)
.expect("endpoint should build")
.with_transport_fields(
"https://api.openai.example".to_string(),
"https://api.openai.example/v1".to_string(),
None,
None,
Some(2),
@@ -348,7 +348,7 @@ async fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_exe
let (upstream_url, upstream_handle) = start_server(upstream).await;
let (provider_url, provider_handle) = start_server(provider).await;
let mut primary_endpoint = sample_provider_catalog_endpoint();
primary_endpoint.base_url = provider_url.clone();
primary_endpoint.base_url = format!("{provider_url}/v1");
backup_endpoint.base_url = "http://127.0.0.1:9".to_string();
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
vec![sample_provider_catalog_provider(), backup_provider],
@@ -2300,7 +2300,7 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
);
assert_eq!(
seen_execution_runtime_requests[0].url,
"https://api.openai.primary.example/v1/chat/completions"
"https://api.openai.primary.example/chat/completions"
);
assert_eq!(
seen_execution_runtime_requests[0].authorization,
@@ -2308,7 +2308,7 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
);
assert_eq!(
seen_execution_runtime_requests[1].url,
"https://api.openai.backup.example/v1/chat/completions"
"https://api.openai.backup.example/chat/completions"
);
assert_eq!(
seen_execution_runtime_requests[1].model,
@@ -1068,7 +1068,7 @@ async fn gateway_routes_openai_responses_stream_image_intent_to_openai_image_pla
"responses-stream-image-bridge",
"image-provider",
"custom",
"https://images.example.com",
"https://images.example.com/v1",
execution_runtime_url,
)
.await;
@@ -234,7 +234,7 @@ async fn ai_execute_stream_pii_redaction_round_trip() {
let seen_provider_request = Arc::new(Mutex::new(None::<SeenProviderStreamRequest>));
let seen_provider_request_clone = Arc::clone(&seen_provider_request);
let provider_app = Router::new().route(
"/v1/chat/completions",
"/chat/completions",
any(move |request: Request| {
let seen_provider_request_inner = Arc::clone(&seen_provider_request_clone);
async move {
@@ -378,7 +378,7 @@ async fn gateway_skips_unsupported_local_openai_chat_sync_candidate_before_tryin
);
assert_eq!(
seen_execution_runtime_request.url,
"https://api.openai.backup.example/v1/chat/completions"
"https://api.openai.backup.example/chat/completions"
);
assert_eq!(
seen_execution_runtime_request.model,
@@ -1115,7 +1115,7 @@ async fn gateway_retries_next_local_openai_chat_sync_candidate_after_auth_failur
);
assert_eq!(
seen_execution_runtime_requests[0].url,
"https://api.openai.primary.example/v1/chat/completions"
"https://api.openai.primary.example/chat/completions"
);
assert_eq!(
seen_execution_runtime_requests[0].authorization,
@@ -1123,7 +1123,7 @@ async fn gateway_retries_next_local_openai_chat_sync_candidate_after_auth_failur
);
assert_eq!(
seen_execution_runtime_requests[1].url,
"https://api.openai.backup.example/v1/chat/completions"
"https://api.openai.backup.example/chat/completions"
);
assert_eq!(
seen_execution_runtime_requests[1].model,
@@ -233,7 +233,7 @@ async fn proxy_pii_redaction_local_openai_chat_runtime_masks_headers_and_restore
let seen_provider_request = Arc::new(Mutex::new(None::<SeenProviderRequest>));
let seen_provider_request_clone = Arc::clone(&seen_provider_request);
let provider_app = Router::new().route(
"/v1/chat/completions",
"/chat/completions",
any(move |request: Request| {
let seen_provider_request_inner = Arc::clone(&seen_provider_request_clone);
async move {
@@ -491,7 +491,7 @@ async fn gateway_executes_openai_chat_sync_via_local_decision_gate_without_execu
)
.expect("endpoint should build")
.with_transport_fields(
"https://api.openai.example".to_string(),
"https://api.openai.example/v1".to_string(),
None,
None,
Some(2),
@@ -669,7 +669,7 @@ async fn gateway_executes_openai_chat_sync_via_local_decision_gate_without_execu
let (upstream_url, upstream_handle) = start_server(upstream).await;
let (provider_url, provider_handle) = start_server(provider).await;
let mut primary_endpoint = sample_provider_catalog_endpoint();
primary_endpoint.base_url = provider_url.clone();
primary_endpoint.base_url = format!("{provider_url}/v1");
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
vec![sample_provider_catalog_provider(), backup_provider],
{
@@ -871,7 +871,7 @@ async fn gateway_executes_openai_chat_sync_with_regex_model_mapping_in_execution
)
.expect("endpoint should build")
.with_transport_fields(
"https://api.openai.example".to_string(),
"https://api.openai.example/v1".to_string(),
None,
None,
Some(2),
@@ -308,7 +308,7 @@ async fn run_sync_redaction_case_with_system_config(
let seen_provider_request = Arc::new(Mutex::new(None::<SeenProviderRequest>));
let seen_provider_request_clone = Arc::clone(&seen_provider_request);
let provider_app = Router::new().route(
"/v1/chat/completions",
"/chat/completions",
any(move |request: Request| {
let seen_provider_request_inner = Arc::clone(&seen_provider_request_clone);
async move {
@@ -631,7 +631,7 @@ async fn ai_execute_pii_redaction_restores_executed_candidate_session_after_late
let seen_provider_request = Arc::new(Mutex::new(None::<SeenProviderRequest>));
let seen_provider_request_clone = Arc::clone(&seen_provider_request);
let provider_app = Router::new().route(
"/v1/chat/completions",
"/chat/completions",
any(move |request: Request| {
let seen_provider_request_inner = Arc::clone(&seen_provider_request_clone);
async move {
@@ -486,7 +486,7 @@ async fn gateway_converts_gemini_image_sync_to_openai_image_provider_impl() {
StoredProviderCatalogProvider::new(
"provider-openai-image-bridge-1".to_string(),
"openai".to_string(),
Some("https://api.openai.com".to_string()),
Some("https://api.openai.com/v1".to_string()),
"openai".to_string(),
)
.expect("provider should build")
@@ -514,7 +514,7 @@ async fn gateway_converts_gemini_image_sync_to_openai_image_provider_impl() {
)
.expect("endpoint should build")
.with_transport_fields(
"https://api.openai.com".to_string(),
"https://api.openai.com/v1".to_string(),
None,
None,
Some(2),