Skip to content

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

test(core,security): update schema validation tests

Steven Enamakel28267926029b
diff --git a/crates/openhuman-core/src/core/all_devices_controller_tests.rs b/crates/openhuman-core/src/core/all_devices_controller_tests.rs
index 1e944015bf..0448c8082d 100644
--- a/crates/openhuman-core/src/core/all_devices_controller_tests.rs
+++ b/crates/openhuman-core/src/core/all_devices_controller_tests.rs
@@ -61,10 +61,28 @@ fn raw_devices_security_registry_matches_its_independent_contract() {
"expires_at"
]
);
- assert_eq!(
- create.outputs.iter().filter(|field| field.required).count(),
- 4
- );
+ for name in ["channel_id", "pairing_token", "core_pubkey", "expires_at"] {
+ let field = create
+ .outputs
+ .iter()
+ .find(|field| field.name == name)
+ .expect("required pairing output is declared");
+ assert!(field.required, "{name} remains required");
+ assert!(
+ matches!(&field.ty, TypeSchema::String),
+ "{name} remains a string"
+ );
+ }
+ let rpc_url = create
+ .outputs
+ .iter()
+ .find(|field| field.name == "rpc_url")
+ .expect("optional RPC URL output is declared");
+ assert!(!rpc_url.required);
+ assert!(matches!(
+ &rpc_url.ty,
+ TypeSchema::Option(inner) if matches!(inner.as_ref(), TypeSchema::String)
+ ));
let list = &entries[1].controller.schema;
assert!(list.inputs.is_empty());
diff --git a/crates/openhuman-core/src/security/devices/schemas_tests.rs b/crates/openhuman-core/src/security/devices/schemas_tests.rs
index 7aee2cc23c..02f2b61123 100644
--- a/crates/openhuman-core/src/security/devices/schemas_tests.rs
+++ b/crates/openhuman-core/src/security/devices/schemas_tests.rs
@@ -101,6 +101,16 @@ fn create_pairing_parser_preserves_optional_labels_and_strict_type_errors() {
] {
assert_eq!(parse_create_pairing(params).unwrap(), expected);
}
+ assert_eq!(
+ parse_create_pairing(Map::from_iter([
+ ("label".into(), json!(" parser label ")),
+ ("unknown_scalar".into(), json!(true)),
+ ("unknown_nested".into(), json!({"ignored": [1, null]})),
+ ]))
+ .unwrap(),
+ Some(" parser label ".to_owned()),
+ "the actual parser keeps its value while ignoring unknown fields"
+ );
for (value, kind) in [
(json!(true), "bool"),
@@ -151,6 +161,16 @@ fn revoke_parser_requires_and_preserves_a_string_channel_id() {
value
);
}
+ assert_eq!(
+ parse_revoke(Map::from_iter([
+ ("channel_id".into(), json!(" parser channel id ")),
+ ("extra_scalar".into(), json!(true)),
+ ("extra_nested".into(), json!({"ignored": [false, null]})),
+ ]))
+ .unwrap(),
+ " parser channel id ",
+ "the actual parser preserves the channel id while ignoring extras"
+ );
}
async fn runtime_device_entries() -> Vec<crate::core::all::ControllerEntry> {