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(storage): add grant tests for tinybox, tinyconnectors, tinyjuice, tinywallet
Steven Enamakelb5ff88ff07bb
diff --git a/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rsnew file mode 100644index 0000000000..2dddd0bdb7--- /dev/null+++ b/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rs@@ -0,0 +1,69 @@+use super::*;+use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};+use serde_json::json;++fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {+ matches!(+ authorize(&grant(), object, selector, &request),+ Ok(Plan::Forward { .. })+ )+}++#[test]+fn the_grant_is_declared_for_tinybox_and_validates() {+ let declared = declared(MODULE_ID).expect("tinybox declares storage");+ assert_eq!(declared, grant());+ declared.validate().expect("a valid grant");+ assert!(declared.writable);+ assert!(declared.secret_prefixes.is_empty());+}++#[test]+fn the_declared_module_id_is_a_registry_module() {+ assert!(crate::modules::registry::ALL+ .iter()+ .any(|record| record.id == MODULE_ID));+}++#[test]+fn box_records_and_the_jail_index_are_reachable() {+ for name in ["tinybox_boxes", "tinybox_jail_index"] {+ assert!(+ allowed(+ Object::Documents,+ "Put",+ json!({"collection": name, "id": "x"})+ ),+ "{name}"+ );+ }+ assert_eq!(grant().collections.len(), 2);+ for other in ["tinybox_host_import", "tinybox_boxes_x", "approvals", "_secrets"] {+ assert_eq!(+ authorize(+ &grant(),+ Object::Documents,+ "Get",+ &json!({"collection": other, "id": "x"})+ ),+ Err(Denied::Target),+ "{other}"+ );+ }+}++#[test]+fn streams_blobs_and_secrets_are_not_granted() {+ assert_eq!(+ authorize(&grant(), Object::Streams, "Append", &json!({"stream": "s"})),+ Err(Denied::Object)+ );+ assert_eq!(+ authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),+ Err(Denied::Object)+ );+ assert_eq!(+ authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),+ Err(Denied::Object)+ );+}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rsnew file mode 100644index 0000000000..e0a1200e04--- /dev/null+++ b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rs@@ -0,0 +1,71 @@+use super::*;+use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};+use serde_json::json;++fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {+ matches!(+ authorize(&grant(), object, selector, &request),+ Ok(Plan::Forward { .. })+ )+}++#[test]+fn the_grant_is_declared_for_tinyconnectors_and_validates() {+ let declared = declared(MODULE_ID).expect("tinyconnectors declares storage");+ assert_eq!(declared, grant());+ declared.validate().expect("a valid grant");+ assert!(declared.writable);+ assert!(declared.secret_prefixes.is_empty());+}++#[test]+fn the_declared_module_id_is_a_registry_module() {+ assert!(crate::modules::registry::ALL+ .iter()+ .any(|record| record.id == MODULE_ID));+}++#[test]+fn only_its_own_collection_and_trigger_streams_are_reachable() {+ assert_eq!(grant().collections.len(), 1);+ assert!(allowed(+ Object::Documents,+ "Put",+ json!({"collection": "composio-user-scopes", "id": "gmail"})+ ));+ for day in ["triggers/2026-10-13", "triggers/x"] {+ assert!(allowed(Object::Streams, "Append", json!({"stream": day})), "{day}");+ assert!(allowed(Object::Streams, "Len", json!({"stream": day})), "{day}");+ }+ for other in ["trigger", "mcp_audit", "x402.payments", "_secrets"] {+ assert_eq!(+ authorize(&grant(), Object::Streams, "Append", &json!({"stream": other})),+ Err(Denied::Target),+ "{other}"+ );+ }+ for other in ["composio-user-scopes-x", "tinyconnectors_host_import", "approvals"] {+ assert_eq!(+ authorize(+ &grant(),+ Object::Documents,+ "Get",+ &json!({"collection": other, "id": "x"})+ ),+ Err(Denied::Target),+ "{other}"+ );+ }+}++#[test]+fn blobs_and_secrets_are_not_granted() {+ assert_eq!(+ authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),+ Err(Denied::Object)+ );+ assert_eq!(+ authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),+ Err(Denied::Object)+ );+}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rsnew file mode 100644index 0000000000..328ebe3961--- /dev/null+++ b/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rs@@ -0,0 +1,69 @@+use super::*;+use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};+use serde_json::json;++fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {+ matches!(+ authorize(&grant(), object, selector, &request),+ Ok(Plan::Forward { .. })+ )+}++#[test]+fn the_grant_is_declared_for_tinyjuice_and_validates() {+ let declared = declared(MODULE_ID).expect("tinyjuice declares storage");+ assert_eq!(declared, grant());+ declared.validate().expect("a valid grant");+ assert!(declared.writable);+ assert!(declared.secret_prefixes.is_empty());+}++#[test]+fn the_declared_module_id_is_a_registry_module() {+ assert!(crate::modules::registry::ALL+ .iter()+ .any(|record| record.id == MODULE_ID));+}++#[test]+fn only_ccr_blobs_are_reachable() {+ for selector in ["Get", "Head", "Delete"] {+ assert!(+ allowed(+ Object::Blobs,+ selector,+ json!({"key": "tinyjuice_ccr/0123456789abcdef0123456789abcdef"})+ ),+ "{selector}"+ );+ }+ for other in ["tinyjuice_ccr", "tinyjuice_ccr_x/a", "ccr/a", "../tinyjuice_ccr/a"] {+ assert_eq!(+ authorize(&grant(), Object::Blobs, "Get", &json!({"key": other})),+ Err(Denied::Target),+ "{other}"+ );+ }+}++#[test]+fn documents_streams_and_secrets_are_not_granted() {+ assert!(grant().collections.is_empty());+ assert_eq!(+ authorize(+ &grant(),+ Object::Documents,+ "Get",+ &json!({"collection": "tinyjuice_host_import", "id": "x"})+ ),+ Err(Denied::Target)+ );+ assert_eq!(+ authorize(&grant(), Object::Streams, "Append", &json!({"stream": "s"})),+ Err(Denied::Object)+ );+ assert_eq!(+ authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),+ Err(Denied::Object)+ );+}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rsnew file mode 100644index 0000000000..59d9eed2c4--- /dev/null+++ b/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rs@@ -0,0 +1,81 @@+use super::*;+use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};+use serde_json::json;++fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {+ matches!(+ authorize(&grant(), object, selector, &request),+ Ok(Plan::Forward { .. })+ )+}++#[test]+fn the_grant_is_declared_for_tinywallet_and_validates() {+ let declared = declared(MODULE_ID).expect("tinywallet declares storage");+ assert_eq!(declared, grant());+ declared.validate().expect("a valid grant");+ assert!(declared.writable);+ assert!(declared.secret_prefixes.is_empty());+}++#[cfg(feature = "web3")]+#[test]+fn the_declared_module_id_is_a_registry_module() {+ assert!(crate::modules::registry::ALL+ .iter()+ .any(|record| record.id == MODULE_ID));+}++#[test]+fn the_payments_stream_and_the_budget_hold_document_are_reachable() {+ assert!(allowed(+ Object::Streams,+ "Append",+ json!({"stream": "x402.payments"})+ ));+ assert!(allowed(+ Object::Streams,+ "ReadWindow",+ json!({"stream": "x402.payments"})+ ));+ // The hold is compare-and-swap on one document: puts with a precondition+ // are forwarded like any other write.+ assert!(allowed(+ Object::Documents,+ "Put",+ json!({"collection": "x402_budget", "id": "holds"})+ ));+ assert!(allowed(+ Object::Documents,+ "Get",+ json!({"collection": "x402_budget", "id": "holds"})+ ));+}++#[test]+fn nothing_else_is_reachable() {+ for other in ["x402_budget_extra", "tinywallet_host_import", "approvals", "_secrets"] {+ assert_eq!(+ authorize(+ &grant(),+ Object::Documents,+ "Get",+ &json!({"collection": other, "id": "x"})+ ),+ Err(Denied::Target),+ "{other}"+ );+ }+ assert_eq!(+ authorize(&grant(), Object::Streams, "Append", &json!({"stream": "mcp_audit"})),+ Err(Denied::Target)+ );+ assert_eq!(+ authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),+ Err(Denied::Object)+ );+ assert_eq!(+ authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),+ Err(Denied::Object)+ );+}