mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Fix OpenAI family local auth to use bearer (#302)
* Fix OpenAI family local auth to use bearer * test(gateway): fix bearer auth assertions for openai local flows * test(usage): make local usage status wait resilient * style(gateway): apply rustfmt to usage test helper --------- Co-authored-by: fawney19 <elky0401@gmail.com>
This commit is contained in:
@@ -6,7 +6,7 @@ use aether_provider_transport::antigravity::{
|
||||
AntigravityRequestAuthSupport, ANTIGRAVITY_REQUEST_USER_AGENT,
|
||||
};
|
||||
use aether_provider_transport::auth::{
|
||||
ensure_upstream_auth_header, resolve_local_gemini_auth, resolve_local_openai_chat_auth,
|
||||
ensure_upstream_auth_header, resolve_local_gemini_auth, resolve_local_openai_bearer_auth,
|
||||
resolve_local_standard_auth,
|
||||
};
|
||||
use aether_provider_transport::vertex::resolve_local_vertex_api_key_query_auth;
|
||||
@@ -309,7 +309,7 @@ async fn resolve_standard_header_auth(
|
||||
|
||||
let api_format = transport.endpoint.api_format.trim().to_ascii_lowercase();
|
||||
if api_format.starts_with("openai:") {
|
||||
return Ok(resolve_local_openai_chat_auth(transport));
|
||||
return Ok(resolve_local_openai_bearer_auth(transport));
|
||||
}
|
||||
if api_format.starts_with("claude:") {
|
||||
return Ok(resolve_local_standard_auth(transport));
|
||||
@@ -337,7 +337,7 @@ async fn resolve_bearer_or_oauth_header_auth(
|
||||
return Ok(Some(auth));
|
||||
}
|
||||
|
||||
if let Some((name, value)) = resolve_local_openai_chat_auth(transport) {
|
||||
if let Some((name, value)) = resolve_local_openai_bearer_auth(transport) {
|
||||
return Ok(Some((name, value)));
|
||||
}
|
||||
|
||||
@@ -599,6 +599,25 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builds_openai_compact_models_fetch_plan_with_bearer_authorization() {
|
||||
let runtime = TestRuntime {
|
||||
oauth_auth: None,
|
||||
proxy: None,
|
||||
};
|
||||
let mut transport = sample_transport("openai", "openai:compact", "api_key");
|
||||
transport.key.decrypted_auth_config = None;
|
||||
let plan = build_models_fetch_execution_plan(&runtime, &transport)
|
||||
.await
|
||||
.expect("plan");
|
||||
|
||||
assert_eq!(plan.url, "https://example.com/v1/models");
|
||||
assert_eq!(
|
||||
plan.headers.get("authorization").map(String::as_str),
|
||||
Some("Bearer secret")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builds_claude_models_fetch_plan_with_pagination() {
|
||||
let runtime = TestRuntime {
|
||||
|
||||
Reference in New Issue
Block a user