The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(config): cover auth style parsing and wire up primary cloud tests
Steven Enamakelcaa42bfd73a3
diff --git a/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs b/crates/openhuman-core/src/config/ops/cloud_providers_tests.rsnew file mode 100644index 0000000000..b3ae6824f9--- /dev/null+++ b/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs@@ -0,0 +1,88 @@+use super::*;++fn update(slug: &str) -> CloudProviderUpdate {+ CloudProviderUpdate {+ id: None,+ slug: slug.to_string(),+ label: None,+ endpoint: String::new(),+ auth_style: None,+ ca_cert_pem: None,+ legacy_type: None,+ default_model: None,+ }+}++#[test]+fn builder_preserves_legacy_preset_and_blank_fallback_rules() {+ let mut entry = update(" openai-compatible ");+ entry.id = Some(" ".to_string());+ entry.label = Some(" ".to_string());+ entry.legacy_type = Some("openai".to_string());+ let providers = build_cloud_provider_creds(vec![entry]).expect("provider should build");++ assert_eq!(providers.len(), 1);+ let provider = &providers[0];+ assert!(provider.id.starts_with("p_openai-compatible_"));+ assert_eq!(provider.slug, "openai-compatible");+ assert_eq!(provider.label, "openai-compatible");+ assert_eq!(provider.endpoint, "https://api.openai.com/v1");+ assert_eq!(provider.auth_style, AuthStyle::Bearer);+}++#[test]+fn builder_keeps_explicit_whitespace_endpoint_and_drops_reserved_slugs() {+ let mut entry = update("custom");+ entry.endpoint = " ".to_string();+ let mut reserved = update("openhuman");+ reserved.endpoint = "https://echoed.invalid".to_string();++ let providers = build_cloud_provider_creds(vec![entry, reserved]).expect("valid update");+ assert_eq!(providers.len(), 1);+ assert_eq!(providers[0].endpoint, " ");+ assert_eq!(providers[0].auth_style, AuthStyle::Bearer);+}++#[test]+fn builder_preserves_auth_aliases_and_unknown_error() {+ for (input, expected) in [+ ("ANTHROPIC", AuthStyle::Anthropic),+ ("OpenHumanJwt", AuthStyle::OpenhumanJwt),+ ("openhuman_jwt", AuthStyle::OpenhumanJwt),+ ("none", AuthStyle::None),+ ] {+ let mut entry = update("custom");+ entry.auth_style = Some(input.to_string());+ assert_eq!(+ build_cloud_provider_creds(vec![entry]).unwrap()[0].auth_style,+ expected+ );+ }++ let mut entry = update("custom");+ entry.auth_style = Some("OddAuth".to_string());+ assert_eq!(+ build_cloud_provider_creds(vec![entry]).unwrap_err(),+ "unknown auth_style 'oddauth'; valid: bearer, anthropic, openhuman_jwt, none"+ );+}++#[test]+fn builder_accepts_the_legacy_type_rpc_field() {+ let value = serde_json::json!({+ "slug": "openai-compatible",+ "endpoint": "",+ "type": "openai"+ });+ let update: CloudProviderUpdate = serde_json::from_value(value).expect("legacy payload");+ let provider = build_cloud_provider_creds(vec![update]).unwrap().remove(0);+ assert_eq!(provider.endpoint, "https://api.openai.com/v1");+}++#[test]+fn builder_rejects_empty_slug() {+ assert_eq!(+ build_cloud_provider_creds(vec![update(" ")]).unwrap_err(),+ "cloud provider slug must not be empty"+ );+}diff --git a/crates/openhuman-core/src/config/ops/primary_cloud.rs b/crates/openhuman-core/src/config/ops/primary_cloud.rsindex 7ac6b53912..cf37c327a1 100644--- a/crates/openhuman-core/src/config/ops/primary_cloud.rs+++ b/crates/openhuman-core/src/config/ops/primary_cloud.rs@@ -155,3 +155,7 @@ pub(crate) fn normalize_endpoint_for_compare(url: &str) -> String {pub(crate) fn looks_like_openhuman_backend(config: &Config, url: &str) -> bool {config.resolved_endpoints.is_managed_host(url)}++#[cfg(test)]+#[path = "primary_cloud_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/config/ops/primary_cloud_tests.rs b/crates/openhuman-core/src/config/ops/primary_cloud_tests.rsnew file mode 100644index 0000000000..9703026142--- /dev/null+++ b/crates/openhuman-core/src/config/ops/primary_cloud_tests.rs@@ -0,0 +1,80 @@+use super::*;++use crate::config::schema::cloud_providers::CloudProviderCreds;++fn provider(id: &str, slug: &str, endpoint: &str, auth_style: AuthStyle) -> CloudProviderCreds {+ CloudProviderCreds {+ id: id.to_string(),+ slug: slug.to_string(),+ label: slug.to_string(),+ endpoint: endpoint.to_string(),+ auth_style,+ default_model: Some("provider-model".to_string()),+ }+}++#[test]+fn explicit_managed_primary_yields_matching_legacy_custom_provider() {+ let mut config = Config::default();+ config.cloud_providers = vec![+ provider(+ "managed",+ "openhuman",+ "https://api.openhuman.ai/v1",+ AuthStyle::OpenhumanJwt,+ ),+ provider(+ "custom",+ "my-provider",+ "https://example.test/v1/",+ AuthStyle::Bearer,+ ),+ ];+ config.primary_cloud = Some("managed".to_string());+ config.inference_url = Some("https://EXAMPLE.test/v1".to_string());++ assert_eq!(+ resolve_primary_cloud_provider_string(&config),+ "my-provider:provider-model"+ );+}++#[test]+fn explicit_managed_primary_fails_closed_for_unmatched_custom_intent() {+ let mut config = Config::default();+ config.cloud_providers = vec![provider(+ "managed",+ "openhuman",+ "https://api.openhuman.ai/v1",+ AuthStyle::OpenhumanJwt,+ )];+ config.primary_cloud = Some("managed".to_string());+ config.inference_url = Some("https://unmatched.example.test/v1".to_string());++ assert_eq!(+ resolve_primary_cloud_provider_string(&config),+ crate::inference::provider::factory::BYOK_INCOMPLETE_SENTINEL+ );+}++#[test]+fn absent_primary_without_custom_intent_retains_managed_route() {+ let config = Config::default();+ assert_eq!(+ resolve_primary_cloud_provider_string(&config),+ crate::inference::provider::factory::PROVIDER_OPENHUMAN+ );+}++#[test]+fn resolved_managed_host_is_not_treated_as_byok_intent() {+ let mut config = Config::default();+ config.resolved_endpoints.managed_hosts = vec![".managed.test".to_string()];+ config.inference_url = Some("https://api.managed.test/v1".to_string());++ assert!(!has_custom_inference_intent(&config));+ assert_eq!(+ resolve_primary_cloud_provider_string(&config),+ crate::inference::provider::factory::PROVIDER_OPENHUMAN+ );+}diff --git a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rsindex 431281679c..d32240c370 100644--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs@@ -13,6 +13,23 @@ fn reserved_slugs() {}}+#[test]+fn auth_style_parse_accepts_rpc_spellings_and_preserves_unknown_error() {+ for (value, expected) in [+ ("BEARER", AuthStyle::Bearer),+ ("anthropic", AuthStyle::Anthropic),+ ("openhuman_jwt", AuthStyle::OpenhumanJwt),+ ("OpenHumanJwt", AuthStyle::OpenhumanJwt),+ ("none", AuthStyle::None),+ ] {+ assert_eq!(AuthStyle::parse(value).unwrap(), expected);+ }+ assert_eq!(+ AuthStyle::parse("Strange").unwrap_err(),+ "unknown auth_style 'strange'; valid: bearer, anthropic, openhuman_jwt, none"+ );+}+// Regression: `ollama` was previously reserved, which made the AI settings// panel unable to persist an `ollama` cloud_providers entry — so the// model-list dropdown failed with "no cloud provider with id or slug