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
refactor(tests): move http-server auth tests from core to rpc crate
Steven Enamakel979d82800173
diff --git a/crates/openhuman-core/src/core/auth_tests.rs b/crates/openhuman-core/src/core/auth_tests.rsindex a11f93053b..1ae672ed80 100644--- a/crates/openhuman-core/src/core/auth_tests.rs+++ b/crates/openhuman-core/src/core/auth_tests.rs@@ -92,73 +92,6 @@ fn init_rpc_token_with_value_seeds_and_is_idempotent() {);}-#[cfg(feature = "http-server")]-#[test]-fn extract_query_token_returns_none_on_missing_query() {- assert_eq!(extract_query_token(None), None);-}--#[cfg(feature = "http-server")]-#[test]-fn extract_query_token_returns_none_when_key_absent() {- assert_eq!(extract_query_token(Some("other=1&foo=bar")), None);-}--#[cfg(feature = "http-server")]-#[test]-fn extract_query_token_returns_none_on_empty_value() {- assert_eq!(extract_query_token(Some("token=")), None);- assert_eq!(extract_query_token(Some("token=%20%20")), None);-}--#[cfg(feature = "http-server")]-#[test]-fn extract_query_token_returns_first_value_on_duplicate_keys() {- // Last-wins vs first-wins is a question the FE never hits; pin- // first-wins so any future ambiguity is documented.- assert_eq!(- extract_query_token(Some("token=alpha&token=beta")),- Some("alpha".to_string())- );-}--#[cfg(feature = "http-server")]-#[test]-fn extract_query_token_url_decodes_value() {- // `encodeURIComponent` on the FE may percent-encode a hex token- // accidentally (it shouldn't, but defensive); confirm round-trip.- assert_eq!(- extract_query_token(Some("token=cafe%2Dbabe")),- Some("cafe-babe".to_string())- );-}--#[cfg(feature = "http-server")]-#[test]-fn login_callbacks_are_no_longer_public() {- // The desktop `/auth` fallback and `/auth/telegram` exchanged login tokens- // inside the core; the host (openhuman_tinyhumans::session) owns that now.- assert!(!PUBLIC_PATHS.contains(&"/auth"));- assert!(!PUBLIC_PATHS.contains(&"/auth/telegram"));-}--#[cfg(feature = "http-server")]-#[test]-fn agentbox_run_and_jobs_paths_are_no_longer_public() {- // These bypassed bearer auth only to serve the AgentBox marketplace- // surface, which moved to tinybox. Nothing mounts them now, so they- // must authenticate like any other path — a re-added entry here would- // silently open an unauthenticated route.- assert!(!is_public_path("/run"));- assert!(!is_public_path("/jobs/abc-123"));- assert!(!is_public_path(- "/jobs/00000000-0000-0000-0000-000000000000"- ));- // Sanity: still protect the executable surface.- assert!(!is_public_path("/rpc"));- assert!(!is_public_path("/v1/chat/completions"));-}-#[cfg(unix)]#[test]fn token_file_has_owner_only_permissions() {@@ -172,40 +105,3 @@ fn token_file_has_owner_only_permissions() {assert_eq!(mode & 0o777, 0o600, "token file must be 0o600");std::fs::remove_dir_all(&tmp).ok();}--#[cfg(feature = "http-server")]-#[test]-fn is_external_inference_path_matches_only_v1_routes() {- assert!(is_external_inference_path("/v1"));- assert!(is_external_inference_path("/v1/models"));- assert!(is_external_inference_path("/v1/chat/completions"));- assert!(!is_external_inference_path("/rpc"));- assert!(!is_external_inference_path("/v10/models"));-}--#[cfg(feature = "http-server")]-#[test]-fn verify_external_inference_bearer_for_config_accepts_stored_key() {- let tmp = tempfile::tempdir().unwrap();- let mut config = Config::default();- config.config_path = tmp.path().join("config.toml");-- let auth = AuthService::from_config(&config);- auth.store_provider_token(- EXTERNAL_OPENAI_COMPAT_PROVIDER,- "default",- "external-test-key",- std::collections::HashMap::new(),- true,- )- .unwrap();-- assert!(verify_external_inference_bearer_for_config(- &config,- "external-test-key"- ));- assert!(!verify_external_inference_bearer_for_config(- &config,- "wrong-key"- ));-}diff --git a/crates/openhuman-rpc/src/server/auth_tests.rs b/crates/openhuman-rpc/src/server/auth_tests.rsindex 65525480c9..48950a5e29 100644--- a/crates/openhuman-rpc/src/server/auth_tests.rs+++ b/crates/openhuman-rpc/src/server/auth_tests.rs@@ -1,3 +1,96 @@use super::*;+#[test]+fn extract_query_token_returns_none_on_missing_query() {+ assert_eq!(extract_query_token(None), None);+}+#[test]+fn extract_query_token_returns_none_when_key_absent() {+ assert_eq!(extract_query_token(Some("other=1&foo=bar")), None);+}++#[test]+fn extract_query_token_returns_none_on_empty_value() {+ assert_eq!(extract_query_token(Some("token=")), None);+ assert_eq!(extract_query_token(Some("token=%20%20")), None);+}++#[test]+fn extract_query_token_returns_first_value_on_duplicate_keys() {+ // Last-wins vs first-wins is a question the FE never hits; pin+ // first-wins so any future ambiguity is documented.+ assert_eq!(+ extract_query_token(Some("token=alpha&token=beta")),+ Some("alpha".to_string())+ );+}++#[test]+fn extract_query_token_url_decodes_value() {+ // `encodeURIComponent` on the FE may percent-encode a hex token+ // accidentally (it shouldn't, but defensive); confirm round-trip.+ assert_eq!(+ extract_query_token(Some("token=cafe%2Dbabe")),+ Some("cafe-babe".to_string())+ );+}++#[test]+fn login_callbacks_are_no_longer_public() {+ // The desktop `/auth` fallback and `/auth/telegram` exchanged login tokens+ // inside the core; the host (openhuman_tinyhumans::session) owns that now.+ assert!(!PUBLIC_PATHS.contains(&"/auth"));+ assert!(!PUBLIC_PATHS.contains(&"/auth/telegram"));+}++#[test]+fn agentbox_run_and_jobs_paths_are_no_longer_public() {+ // These bypassed bearer auth only to serve the AgentBox marketplace+ // surface, which moved to tinybox. Nothing mounts them now, so they+ // must authenticate like any other path — a re-added entry here would+ // silently open an unauthenticated route.+ assert!(!is_public_path("/run"));+ assert!(!is_public_path("/jobs/abc-123"));+ assert!(!is_public_path(+ "/jobs/00000000-0000-0000-0000-000000000000"+ ));+ // Sanity: still protect the executable surface.+ assert!(!is_public_path("/rpc"));+ assert!(!is_public_path("/v1/chat/completions"));+}++#[test]+fn is_external_inference_path_matches_only_v1_routes() {+ assert!(is_external_inference_path("/v1"));+ assert!(is_external_inference_path("/v1/models"));+ assert!(is_external_inference_path("/v1/chat/completions"));+ assert!(!is_external_inference_path("/rpc"));+ assert!(!is_external_inference_path("/v10/models"));+}++#[test]+fn verify_external_inference_bearer_for_config_accepts_stored_key() {+ let tmp = tempfile::tempdir().unwrap();+ let mut config = Config::default();+ config.config_path = tmp.path().join("config.toml");++ let auth = AuthService::from_config(&config);+ auth.store_provider_token(+ EXTERNAL_OPENAI_COMPAT_PROVIDER,+ "default",+ "external-test-key",+ std::collections::HashMap::new(),+ true,+ )+ .unwrap();++ assert!(verify_external_inference_bearer_for_config(+ &config,+ "external-test-key"+ ));+ assert!(!verify_external_inference_bearer_for_config(+ &config,+ "wrong-key"+ ));+}