remote tasks

This commit is contained in:
easong-openai
2025-09-03 16:57:37 -07:00
parent e83c5f429c
commit d2fcf4314e
51 changed files with 6048 additions and 68 deletions

View File

@@ -599,7 +599,10 @@ 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 = if cfg!(windows) { "USERNAME" } else { "USER" };
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}");
// Mock server
let server = MockServer::start().await;
@@ -614,14 +617,7 @@ 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",
format!(
"Bearer {}",
std::env::var(existing_env_var_with_random_value).unwrap()
)
.as_str(),
))
.and(header_regex("Authorization", auth_header_value.as_str()))
.respond_with(first)
.expect(1)
.mount(&server)
@@ -631,7 +627,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.to_string()),
env_key: Some(existing_env_var_with_random_value.clone()),
query_params: Some(std::collections::HashMap::from([(
"api-version".to_string(),
"2025-04-01-preview".to_string(),
@@ -675,7 +671,10 @@ 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 = if cfg!(windows) { "USERNAME" } else { "USER" };
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}");
// Mock server
let server = MockServer::start().await;
@@ -690,14 +689,7 @@ 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",
format!(
"Bearer {}",
std::env::var(existing_env_var_with_random_value).unwrap()
)
.as_str(),
))
.and(header_regex("Authorization", auth_header_value.as_str()))
.respond_with(first)
.expect(1)
.mount(&server)
@@ -707,7 +699,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.to_string()),
env_key: Some(existing_env_var_with_random_value.clone()),
query_params: Some(std::collections::HashMap::from([(
"api-version".to_string(),
"2025-04-01-preview".to_string(),