Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(modules): every generated grant reaches each collection its owner names

M3gA-Mind90047f08d4f6
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
index c93c73de3e..b611750517 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
@@ -23,8 +23,32 @@ fn every_row_has_a_valid_generated_grant() {
.validate()
.unwrap_or_else(|why| panic!("{}: {why}", row.module));
assert!(grant.writable);
- let items = module_collections(row.owner);
- assert_eq!(grant.collections.len(), items.len(), "{}", row.module);
+ // What the owner provisions plus what its migrations read, and each
+ // one reachable: a collection the module touches but the grant lacks
+ // is refused as target-not-granted on every host with storage.
+ let mut expected: Vec<String> = module_collections(row.owner)
+ .into_iter()
+ .map(|spec| spec.name)
+ .collect();
+ for name in read_collections(row.owner) {
+ if !expected.contains(&name) {
+ expected.push(name);
+ }
+ }
+ let granted: Vec<String> = grant.collections.iter().map(|s| s.name.clone()).collect();
+ assert_eq!(granted, expected, "{}", row.module);
+ for collection in &expected {
+ assert!(
+ allowed(
+ &grant,
+ Object::Documents,
+ "Get",
+ json!({"collection": collection, "id": "x"})
+ ),
+ "{}: {collection} is not granted",
+ row.module
+ );
+ }
}
assert!(declared("not-a-module").is_none());
}