Skip to content

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

chore: files changed crates/openhuman-core/src/core/all_bound_controller_tests.rs,crates/openhuman-c

Steven Enamakel3422a53bc759
diff --git a/crates/openhuman-core/src/core/all_bound_controller_tests.rs b/crates/openhuman-core/src/core/all_bound_controller_tests.rs
index 3008a63036..3bf5f2cc4e 100644
--- a/crates/openhuman-core/src/core/all_bound_controller_tests.rs
+++ b/crates/openhuman-core/src/core/all_bound_controller_tests.rs
@@ -706,3 +706,6 @@ mod registry_test_support;
#[path = "all_bound_registry_contract_tests.rs"]
mod registry_contract_tests;
+
+#[path = "all_keyring_consent_controller_tests.rs"]
+mod keyring_consent_controller_tests;
diff --git a/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs b/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs
new file mode 100644
index 0000000000..6c5a4da0ff
--- /dev/null
+++ b/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs
@@ -0,0 +1,159 @@
+use super::*;
+use serde_json::{json, Map};
+
+fn keyring_consent_fixture_contracts() -> Vec<ControllerParamContract> {
+ vec![
+ ControllerParamContract {
+ method: "keyring_consent.status",
+ required: &[],
+ optional: &[],
+ examples: vec![json!({})],
+ },
+ ControllerParamContract {
+ method: "keyring_consent.decide",
+ required: &["mode"],
+ optional: &[],
+ examples: [
+ "local_encrypted",
+ "declined",
+ "",
+ "unknown",
+ " local_encrypted ",
+ ]
+ .into_iter()
+ .map(|mode| json!({ "mode": mode }))
+ .collect(),
+ },
+ ControllerParamContract {
+ method: "keyring_consent.retry_probe",
+ required: &[],
+ optional: &[],
+ examples: vec![json!({})],
+ },
+ ]
+}
+
+fn keyring_consent_entries() -> Vec<ControllerEntry> {
+ registry()
+ .iter()
+ .filter(|row| row.controller.schema.namespace == "keyring_consent")
+ .map(|row| row.controller.clone())
+ .collect()
+}
+
+#[test]
+fn raw_keyring_consent_registry_matches_its_independent_contract() {
+ let contract = registry_test_support::BoundFamilyWireContract {
+ namespaces: &["keyring_consent"],
+ group: DomainGroup::Security,
+ methods: &[
+ ("keyring_consent.status", "openhuman.keyring_consent_status"),
+ ("keyring_consent.decide", "openhuman.keyring_consent_decide"),
+ (
+ "keyring_consent.retry_probe",
+ "openhuman.keyring_consent_retry_probe",
+ ),
+ ],
+ };
+ registry_test_support::verify_family_contract(
+ registry(),
+ internal_registry(),
+ &contract,
+ &keyring_consent_fixture_contracts(),
+ )
+ .expect("raw Keyring Consent entries retain their ordered wire contracts");
+}
+
+#[test]
+fn raw_keyring_consent_decoders_pin_their_safe_wire_boundary() {
+ let entries = keyring_consent_entries();
+ let status = entries
+ .iter()
+ .find(|entry| entry.schema.function == "status")
+ .expect("raw status entry");
+ let retry_probe = entries
+ .iter()
+ .find(|entry| entry.schema.function == "retry_probe")
+ .expect("raw retry_probe entry");
+ for entry in [status, retry_probe] {
+ entry
+ .decode_params(Map::from_iter([(
+ "ignored".into(),
+ json!({"nested": true}),
+ )]))
+ .unwrap_or_else(|error| {
+ panic!(
+ "{} ignores its entire parameter map: {error}",
+ entry.schema.method_name()
+ )
+ });
+ }
+
+ let decide = entries
+ .iter()
+ .find(|entry| entry.schema.function == "decide")
+ .expect("raw decide entry");
+ for mode in [
+ "local_encrypted",
+ "declined",
+ "",
+ "unknown",
+ " local_encrypted ",
+ ] {
+ decide
+ .decode_params(Map::from_iter([
+ ("mode".into(), json!(mode)),
+ ("ignored".into(), json!({"extra": true})),
+ ]))
+ .unwrap_or_else(|error| panic!("string mode {mode:?} is passed unchanged: {error}"));
+ }
+ assert_eq!(
+ decide.decode_params(Map::new()).unwrap_err(),
+ "missing required param 'mode'"
+ );
+ for value in [json!(null), json!(false), json!(7), json!([]), json!({})] {
+ assert_eq!(
+ decide
+ .decode_params(Map::from_iter([("mode".into(), value)]))
+ .unwrap_err(),
+ "missing required param 'mode'"
+ );
+ }
+}
+
+#[test]
+fn raw_keyring_consent_wire_fields_are_exact() {
+ let entries = keyring_consent_entries();
+ assert_eq!(entries.len(), 3);
+ for entry in [&entries[0], &entries[2]] {
+ assert_eq!(
+ crate::core::all::verify_wire_fields(&entry.schema.inputs, &[]),
+ Ok(()),
+ "{} inputs",
+ entry.schema.method_name()
+ );
+ assert_eq!(
+ crate::core::all::verify_wire_fields(
+ &entry.schema.outputs,
+ &[("result", TypeSchema::Json, true)]
+ ),
+ Ok(()),
+ "{} outputs",
+ entry.schema.method_name()
+ );
+ }
+ assert_eq!(
+ crate::core::all::verify_wire_fields(
+ &entries[1].schema.inputs,
+ &[("mode", TypeSchema::String, true)]
+ ),
+ Ok(())
+ );
+ assert_eq!(
+ crate::core::all::verify_wire_fields(
+ &entries[1].schema.outputs,
+ &[("result", TypeSchema::Json, true)]
+ ),
+ Ok(())
+ );
+}