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(core): cover security policy dispatch and tidy rpc test helpers
Steven Enamakele50798b05918
diff --git a/crates/openhuman-core/src/core/all_dispatch_ctx_tests.rs b/crates/openhuman-core/src/core/all_dispatch_ctx_tests.rsindex 99792fb1c9..d15424a4fc 100644--- a/crates/openhuman-core/src/core/all_dispatch_ctx_tests.rs+++ b/crates/openhuman-core/src/core/all_dispatch_ctx_tests.rs@@ -2,7 +2,7 @@use serde_json::{json, Map, Value};-use crate::core::all::*;+use super::*;use crate::core::runtime::{CoreContext, DispatchCtx, DomainSet};use std::sync::Arc;@@ -108,3 +108,26 @@ async fn explicit_context_overrides_the_calling_tasks_scope() {.expect("handler succeeds");assert_eq!(value["workspace"], json!("/tmp/ctx-probe-explicit"));}++#[tokio::test]+async fn try_invoke_registered_rpc_routes_security_policy_info() {+ let workspace = tempfile::TempDir::new().expect("security policy workspace");+ let mut config = crate::config::Config::default();+ config.workspace_dir = workspace.path().to_path_buf();+ config.action_dir = workspace.path().to_path_buf();+ config.config_path = workspace.path().join("config.toml");+ let ctx = CoreContext::for_test_with_config(DomainSet::full(), config);+ let out = try_invoke_registered_rpc(+ DispatchCtx::new(ctx),+ "openhuman.security_policy_info",+ Map::new(),+ )+ .await+ .expect("security policy info should be registered")+ .expect("security policy info should succeed");++ assert!(+ out.get("result").is_some() || out.get("autonomy").is_some(),+ "security policy info should return policy payload: {out}"+ );+}diff --git a/crates/openhuman-core/src/core/all_extensions_tests.rs b/crates/openhuman-core/src/core/all_extensions_tests.rsindex 52fd50eb9e..b77961284f 100644--- a/crates/openhuman-core/src/core/all_extensions_tests.rs+++ b/crates/openhuman-core/src/core/all_extensions_tests.rs@@ -45,8 +45,8 @@ async fn registry_extension_is_visible_to_every_lookup_and_dispatches() {Map::new(),).await- .expect("extension method is dispatchable")- .expect("handler succeeds");+ .expect("extension method is dispatchable")+ .expect("handler succeeds");assert_eq!(result, serde_json::json!({"ext": true}));}@@ -99,9 +99,10 @@ async fn registry_extension_is_gated_by_its_domain_group() {let mut domains = DomainSet::full();domains.hosted = false;let ctx = CoreContext::for_test(domains, None);+ let dispatch = DispatchCtx::new(ctx.clone());let hidden = CoreContext::scope(ctx, async {(- try_invoke_registered_rpc("openhuman.ext_gate_ping", Map::new())+ try_invoke_registered_rpc(dispatch, "openhuman.ext_gate_ping", Map::new()).await.is_none(),schema_for_rpc_method("openhuman.ext_gate_ping").is_none(),diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rsindex 590455d8ed..4d2de52e23 100644--- a/crates/openhuman-core/src/core/all_tests.rs+++ b/crates/openhuman-core/src/core/all_tests.rs@@ -800,7 +800,12 @@ fn validate_registry_rejects_duplicate_registered_controllers() {#[tokio::test]async fn try_invoke_registered_rpc_returns_none_for_unknown_method() {- let out = try_invoke_registered_rpc(DispatchCtx::unbound(), "openhuman.not_a_real_method_xyz_123", Map::new()).await;+ let out = try_invoke_registered_rpc(+ DispatchCtx::unbound(),+ "openhuman.not_a_real_method_xyz_123",+ Map::new(),+ )+ .await;assert!(out.is_none(), "unknown methods must return None");}@@ -808,31 +813,13 @@ async fn try_invoke_registered_rpc_returns_none_for_unknown_method() {async fn try_invoke_registered_rpc_returns_some_for_known_method() {// `openhuman.health_snapshot` is registered at startup and takes no// required params — it must route and produce Some(_).- let out = try_invoke_registered_rpc(DispatchCtx::unbound(), "openhuman.health_snapshot", Map::new()).await;- assert!(out.is_some(), "known method must route");-}--#[tokio::test]-async fn try_invoke_registered_rpc_routes_security_policy_info() {- let workspace = tempfile::TempDir::new().expect("security policy workspace");- let mut config = crate::config::Config::default();- config.workspace_dir = workspace.path().to_path_buf();- config.action_dir = workspace.path().to_path_buf();- config.config_path = workspace.path().join("config.toml");- let ctx = CoreContext::for_test_with_config(DomainSet::full(), config);let out = try_invoke_registered_rpc(- DispatchCtx::new(ctx),- "openhuman.security_policy_info",+ DispatchCtx::unbound(),+ "openhuman.health_snapshot",Map::new(),)- .await- .expect("security policy info should be registered")- .expect("security policy info should succeed");-- assert!(- out.get("result").is_some() || out.get("autonomy").is_some(),- "security policy info should return policy payload: {out}"- );+ .await;+ assert!(out.is_some(), "known method must route");}#[test]@@ -968,8 +955,7 @@ async fn dispatch_returns_none_for_gated_method() {.expect("a flows.* method exists in the full registry");let ctx = CoreContext::for_test(DomainSet::harness(), None);- let out =- try_invoke_registered_rpc(DispatchCtx::new(ctx), &gated_method, Map::new()).await;+ let out = try_invoke_registered_rpc(DispatchCtx::new(ctx), &gated_method, Map::new()).await;assert!(out.is_none(),"gated method `{gated_method}` must dispatch as None under harness()"