This commit is contained in:
easong-openai
2025-09-05 14:48:19 -07:00
parent e17d794a4e
commit d1cf46b09f
18 changed files with 178 additions and 234 deletions
+20 -12
View File
@@ -735,10 +735,7 @@ async fn includes_user_instructions_message_in_request() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn azure_overrides_assign_properties_used_for_responses_url() {
let (existing_env_var_with_random_value, existing_env_var_value) = std::env::vars()
.find(|(_, value)| !value.trim().is_empty())
.expect("system environment variable should exist");
let auth_header_value = format!("Bearer {existing_env_var_value}");
let existing_env_var_with_random_value = if cfg!(windows) { "USERNAME" } else { "USER" };
// Mock server
let server = MockServer::start().await;
@@ -753,7 +750,14 @@ async fn azure_overrides_assign_properties_used_for_responses_url() {
.and(path("/openai/responses"))
.and(query_param("api-version", "2025-04-01-preview"))
.and(header_regex("Custom-Header", "Value"))
.and(header_regex("Authorization", auth_header_value.as_str()))
.and(header_regex(
"Authorization",
format!(
"Bearer {}",
std::env::var(existing_env_var_with_random_value).unwrap()
)
.as_str(),
))
.respond_with(first)
.expect(1)
.mount(&server)
@@ -763,7 +767,7 @@ async fn azure_overrides_assign_properties_used_for_responses_url() {
name: "custom".to_string(),
base_url: Some(format!("{}/openai", server.uri())),
// Reuse the existing environment variable to avoid using unsafe code
env_key: Some(existing_env_var_with_random_value.clone()),
env_key: Some(existing_env_var_with_random_value.to_string()),
query_params: Some(std::collections::HashMap::from([(
"api-version".to_string(),
"2025-04-01-preview".to_string(),
@@ -807,10 +811,7 @@ async fn azure_overrides_assign_properties_used_for_responses_url() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn env_var_overrides_loaded_auth() {
let (existing_env_var_with_random_value, existing_env_var_value) = std::env::vars()
.find(|(_, value)| !value.trim().is_empty())
.expect("system environment variable should exist");
let auth_header_value = format!("Bearer {existing_env_var_value}");
let existing_env_var_with_random_value = if cfg!(windows) { "USERNAME" } else { "USER" };
// Mock server
let server = MockServer::start().await;
@@ -825,7 +826,14 @@ async fn env_var_overrides_loaded_auth() {
.and(path("/openai/responses"))
.and(query_param("api-version", "2025-04-01-preview"))
.and(header_regex("Custom-Header", "Value"))
.and(header_regex("Authorization", auth_header_value.as_str()))
.and(header_regex(
"Authorization",
format!(
"Bearer {}",
std::env::var(existing_env_var_with_random_value).unwrap()
)
.as_str(),
))
.respond_with(first)
.expect(1)
.mount(&server)
@@ -835,7 +843,7 @@ async fn env_var_overrides_loaded_auth() {
name: "custom".to_string(),
base_url: Some(format!("{}/openai", server.uri())),
// Reuse the existing environment variable to avoid using unsafe code
env_key: Some(existing_env_var_with_random_value.clone()),
env_key: Some(existing_env_var_with_random_value.to_string()),
query_params: Some(std::collections::HashMap::from([(
"api-version".to_string(),
"2025-04-01-preview".to_string(),