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(credentials): add tests for backend_bearer_secret fallback logic
Steven Enamakel0064b6772f0d
diff --git a/crates/openhuman-core/src/security/credentials/api_key.rs b/crates/openhuman-core/src/security/credentials/api_key.rsindex d568101004..4dcae31aee 100644--- a/crates/openhuman-core/src/security/credentials/api_key.rs+++ b/crates/openhuman-core/src/security/credentials/api_key.rs@@ -12,7 +12,7 @@//! * SDK REST clients send it as `x-api-key` — `BackendOAuthClient` and//! `IntegrationClient` pick the header from [`BackendCredential`];//! * bearer-only callers (cloud STT and embeddings, the connector proxy-//! route, the memory host, the Socket.IO handshake) send it as+//! route, the memory host) send it as//! `Authorization: Bearer <key>`, which the backend accepts by prefix.//!//! The key lives in the same auth-profile store as the app session (thediff --git a/crates/openhuman-core/src/security/credentials/session_support_tests.rs b/crates/openhuman-core/src/security/credentials/session_support_tests.rsindex 124d988940..69a82a0cf3 100644--- a/crates/openhuman-core/src/security/credentials/session_support_tests.rs+++ b/crates/openhuman-core/src/security/credentials/session_support_tests.rs@@ -256,6 +256,38 @@ fn get_session_token_returns_stored_token_when_present() {assert!(state.profile_id.is_some());}+#[test]+fn backend_bearer_secret_prefers_api_key_and_returns_none_when_empty() {+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp);+ assert_eq!(backend_bearer_secret(&config).unwrap(), None);+ crate::security::credentials::api_key::store_api_key(&config, "th_test_key")+ .expect("store API key");+ assert_eq!(+ backend_bearer_secret(&config).unwrap().as_deref(),+ Some("th_test_key")+ );+}++#[test]+fn backend_bearer_secret_falls_back_to_session_token() {+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp);+ AuthService::from_config(&config)+ .store_provider_token(+ APP_SESSION_PROVIDER,+ DEFAULT_AUTH_PROFILE_NAME,+ "raw-session-token",+ std::collections::HashMap::new(),+ true,+ )+ .expect("store session token");+ assert_eq!(+ backend_bearer_secret(&config).unwrap().as_deref(),+ Some("raw-session-token")+ );+}+#[test]fn offline_local_token_is_never_a_backend_bearer() {let tmp = TempDir::new().unwrap();