mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
Normalize endpoint API root handling
This commit is contained in:
@@ -847,7 +847,7 @@ async fn gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![],
|
||||
));
|
||||
@@ -1662,7 +1662,7 @@ async fn gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch(
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![key],
|
||||
));
|
||||
@@ -1770,7 +1770,7 @@ async fn gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_fro
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![key],
|
||||
));
|
||||
@@ -1878,7 +1878,7 @@ async fn gateway_refreshes_allowed_models_when_updating_include_patterns_with_au
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![key],
|
||||
));
|
||||
@@ -1982,7 +1982,7 @@ async fn gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_au
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![key],
|
||||
));
|
||||
|
||||
@@ -175,7 +175,7 @@ async fn gateway_handles_admin_provider_query_models_fetches_upstream_for_select
|
||||
)
|
||||
.expect("endpoint should build")
|
||||
.with_transport_fields(
|
||||
"https://api.openai.example".to_string(),
|
||||
"https://api.openai.example/v1".to_string(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -432,7 +432,7 @@ async fn gateway_handles_admin_provider_query_models_with_openai_responses_endpo
|
||||
)
|
||||
.expect("endpoint should build")
|
||||
.with_transport_fields(
|
||||
"https://api.openai.example".to_string(),
|
||||
"https://api.openai.example/v1".to_string(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -649,7 +649,7 @@ async fn gateway_handles_admin_provider_query_models_respecting_key_api_formats(
|
||||
)
|
||||
.expect("endpoint should build")
|
||||
.with_transport_fields(
|
||||
"https://api.openai.example".to_string(),
|
||||
"https://api.openai.example/v1".to_string(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -669,7 +669,7 @@ async fn gateway_handles_admin_provider_query_models_respecting_key_api_formats(
|
||||
)
|
||||
.expect("endpoint should build")
|
||||
.with_transport_fields(
|
||||
"https://api.openai.example".to_string(),
|
||||
"https://api.openai.example/v1".to_string(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -798,7 +798,7 @@ async fn gateway_handles_admin_provider_query_models_aggregating_active_keys() {
|
||||
)
|
||||
.expect("endpoint should build")
|
||||
.with_transport_fields(
|
||||
"https://api.openai.example".to_string(),
|
||||
"https://api.openai.example/v1".to_string(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -1007,7 +1007,7 @@ async fn gateway_handles_admin_provider_query_test_model_locally_with_trusted_ad
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-openai-primary",
|
||||
@@ -1066,7 +1066,7 @@ async fn gateway_handles_admin_provider_query_embedding_model_test() {
|
||||
assert_eq!(plan.key_id, "key-siliconflow-embedding");
|
||||
assert_eq!(plan.client_api_format, "openai:embedding");
|
||||
assert_eq!(plan.provider_api_format, "openai:embedding");
|
||||
assert_eq!(plan.url, "https://api.siliconflow.example/v1/embeddings");
|
||||
assert_eq!(plan.url, "https://api.siliconflow.example/embeddings");
|
||||
assert_eq!(plan.model_name.as_deref(), Some("Qwen/Qwen3-Embedding-4B"));
|
||||
assert!(!plan.stream);
|
||||
assert_eq!(
|
||||
@@ -1546,7 +1546,7 @@ async fn gateway_handles_admin_provider_query_jina_embedding_model_test() {
|
||||
assert_eq!(plan.key_id, "key-jina-embedding");
|
||||
assert_eq!(plan.client_api_format, "openai:embedding");
|
||||
assert_eq!(plan.provider_api_format, "jina:embedding");
|
||||
assert_eq!(plan.url, "https://api.jina.example/v1/embeddings");
|
||||
assert_eq!(plan.url, "https://api.jina.example/embeddings");
|
||||
assert_eq!(plan.model_name.as_deref(), Some("jina-embeddings-v3"));
|
||||
assert!(!plan.stream);
|
||||
assert_eq!(
|
||||
@@ -1775,7 +1775,7 @@ async fn gateway_handles_admin_provider_query_rerank_model_test() {
|
||||
assert_eq!(plan.key_id, "key-jina-rerank");
|
||||
assert_eq!(plan.client_api_format, "openai:rerank");
|
||||
assert_eq!(plan.provider_api_format, "jina:rerank");
|
||||
assert_eq!(plan.url, "https://api.jina.example/v1/rerank");
|
||||
assert_eq!(plan.url, "https://api.jina.example/rerank");
|
||||
assert_eq!(
|
||||
plan.model_name.as_deref(),
|
||||
Some("jina-reranker-v2-base-multilingual")
|
||||
@@ -2736,7 +2736,7 @@ async fn gateway_handles_admin_provider_query_test_model_failover_locally_with_t
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![
|
||||
sample_key(
|
||||
@@ -3504,7 +3504,7 @@ async fn gateway_handles_non_kiro_multi_model_failover_locally() {
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-openai-primary",
|
||||
@@ -3799,7 +3799,7 @@ async fn gateway_handles_openai_image_test_model_locally() {
|
||||
"endpoint-openai-image",
|
||||
"provider-openai",
|
||||
"openai:image",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-openai-image",
|
||||
@@ -4112,13 +4112,13 @@ async fn gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted(
|
||||
"endpoint-openai-cli",
|
||||
"provider-openai",
|
||||
"openai:responses",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
sample_endpoint(
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
],
|
||||
vec![
|
||||
@@ -4215,7 +4215,7 @@ async fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_i
|
||||
"endpoint-openai-chat-unsupported",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
);
|
||||
unsupported_endpoint.header_rules = Some(json!({"invalid": true}));
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
@@ -4226,7 +4226,7 @@ async fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_i
|
||||
"endpoint-openai-chat-supported",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
],
|
||||
vec![sample_key(
|
||||
@@ -4322,7 +4322,7 @@ async fn gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_ap
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
],
|
||||
vec![sample_key(
|
||||
@@ -4411,13 +4411,13 @@ async fn gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted() {
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
sample_endpoint(
|
||||
"endpoint-openai-cli",
|
||||
"provider-openai",
|
||||
"openai:responses",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
),
|
||||
],
|
||||
vec![sample_key(
|
||||
@@ -4503,14 +4503,14 @@ async fn gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_forma
|
||||
"endpoint-openai-chat-unsupported",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
);
|
||||
unsupported_chat_endpoint.header_rules = Some(json!({"invalid": true}));
|
||||
let cli_endpoint = sample_endpoint(
|
||||
"endpoint-openai-cli-runnable",
|
||||
"provider-openai",
|
||||
"openai:responses",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
);
|
||||
let mut shared_key = sample_key(
|
||||
"key-openai-shared",
|
||||
@@ -4604,7 +4604,7 @@ async fn gateway_handles_openai_responses_test_model_failover_locally() {
|
||||
"endpoint-openai-cli",
|
||||
"provider-openai",
|
||||
"openai:responses",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-openai-cli",
|
||||
@@ -4698,7 +4698,7 @@ async fn gateway_handles_claude_cli_test_model_locally() {
|
||||
"endpoint-claude-cli",
|
||||
"provider-claude",
|
||||
"claude:messages",
|
||||
"https://api.anthropic.example",
|
||||
"https://api.anthropic.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-claude-cli",
|
||||
@@ -4786,7 +4786,7 @@ async fn gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted(
|
||||
"endpoint-claude-cli",
|
||||
"provider-claude",
|
||||
"claude:messages",
|
||||
"https://api.anthropic.example",
|
||||
"https://api.anthropic.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-claude-cli",
|
||||
@@ -4875,7 +4875,7 @@ async fn gateway_handles_claude_cli_test_model_failover_locally() {
|
||||
"endpoint-claude-cli",
|
||||
"provider-claude",
|
||||
"claude:messages",
|
||||
"https://api.anthropic.example",
|
||||
"https://api.anthropic.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-claude-cli",
|
||||
@@ -5653,7 +5653,7 @@ async fn gateway_handles_admin_provider_query_test_model_failover_with_single_mo
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![sample_key(
|
||||
"key-openai-alias",
|
||||
@@ -5766,7 +5766,7 @@ async fn gateway_retries_non_kiro_failover_after_http_error_without_message() {
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![
|
||||
sample_key(
|
||||
@@ -5886,7 +5886,7 @@ async fn gateway_retries_non_kiro_failover_after_success_status_without_body() {
|
||||
"endpoint-openai-chat",
|
||||
"provider-openai",
|
||||
"openai:chat",
|
||||
"https://api.openai.example",
|
||||
"https://api.openai.example/v1",
|
||||
)],
|
||||
vec![
|
||||
sample_key(
|
||||
|
||||
@@ -2516,7 +2516,7 @@ async fn gateway_handles_admin_usage_curl_locally_with_trusted_admin_principal()
|
||||
assert_eq!(payload["method"], "POST");
|
||||
assert_eq!(
|
||||
payload["url"],
|
||||
"https://api.openai.example/v1/chat/completions"
|
||||
"https://api.openai.example/chat/completions"
|
||||
);
|
||||
assert_eq!(payload["headers"]["Content-Type"], "application/json");
|
||||
assert_eq!(payload["headers"]["Authorization"], "Bearer provider-real");
|
||||
@@ -2536,7 +2536,7 @@ async fn gateway_handles_admin_usage_curl_locally_with_trusted_admin_principal()
|
||||
);
|
||||
let curl = payload["curl"].as_str().expect("curl should be string");
|
||||
assert!(curl.contains("curl"));
|
||||
assert!(curl.contains("https://api.openai.example/v1/chat/completions"));
|
||||
assert!(curl.contains("https://api.openai.example/chat/completions"));
|
||||
assert!(curl.contains("Content-Type: application/json"));
|
||||
assert!(curl.contains("Authorization: Bearer provider-real"));
|
||||
assert!(curl.contains("\"model\":\"gpt-5-target\""));
|
||||
|
||||
@@ -569,7 +569,7 @@ async fn gateway_cancels_admin_video_task_locally_with_trusted_admin_principal()
|
||||
"format_converted": false
|
||||
},
|
||||
"transport": {
|
||||
"upstream_base_url": "https://api.openai.example",
|
||||
"upstream_base_url": "https://api.openai.example/v1",
|
||||
"provider_name": "openai-video",
|
||||
"provider_id": "provider-openai",
|
||||
"endpoint_id": "endpoint-1",
|
||||
|
||||
@@ -304,7 +304,7 @@ fn assert_embedding_execution_plan(plan: &ExecutionPlan) {
|
||||
assert_eq!(plan.client_api_format, "openai:embedding");
|
||||
assert_eq!(plan.provider_api_format, "openai:embedding");
|
||||
assert_eq!(plan.method, "POST");
|
||||
assert_eq!(plan.url, "https://api.openai.example/v1/embeddings");
|
||||
assert_eq!(plan.url, "https://api.openai.example/embeddings");
|
||||
assert_eq!(plan.model_name.as_deref(), Some("text-embedding-3-small"));
|
||||
let body = plan.body.json_body.as_ref().expect("json request body");
|
||||
assert_eq!(body["model"], "upstream-embedding");
|
||||
|
||||
@@ -112,7 +112,7 @@ fn assert_rerank_execution_plan(plan: &ExecutionPlan) {
|
||||
assert_eq!(plan.client_api_format, "openai:rerank");
|
||||
assert_eq!(plan.provider_api_format, "openai:rerank");
|
||||
assert_eq!(plan.method, "POST");
|
||||
assert_eq!(plan.url, "https://api.openai.example/v1/rerank");
|
||||
assert_eq!(plan.url, "https://api.openai.example/rerank");
|
||||
assert_eq!(plan.model_name.as_deref(), Some("bge-reranker-base"));
|
||||
let body = plan.body.json_body.as_ref().expect("json request body");
|
||||
assert_eq!(body["model"], "upstream-rerank");
|
||||
|
||||
Reference in New Issue
Block a user