Skip to content

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

test(config): cover storage url secret round-trip and fail-closed decrypt

Steven Enamakelb659c5a29c9f
diff --git a/crates/openhuman-core/src/config/schema/load/secrets_tests.rs b/crates/openhuman-core/src/config/schema/load/secrets_tests.rs
index 8fd4b9f600..41e959dc94 100644
--- a/crates/openhuman-core/src/config/schema/load/secrets_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load/secrets_tests.rs
@@ -18,3 +18,27 @@ fn gemini_key_round_trips_with_encryption_enabled() {
Some("gemini-sentinel")
);
}
+
+#[test]
+fn storage_url_round_trips_and_fails_closed_without_the_key() {
+ let dir = tempfile::tempdir().unwrap();
+ let mut config = Config::default();
+ config.config_path = dir.path().join("config.toml");
+ config.secrets.encrypt = true;
+ config.storage.url = Some("mongodb://app:[email protected]/openhuman".into());
+
+ encrypt_config_secrets(&mut config).unwrap();
+ let sealed = config.storage.url.clone().unwrap();
+ assert!(sealed.starts_with("enc2:") && !sealed.contains("hunter2"));
+ decrypt_config_secrets(&mut config, dir.path()).unwrap();
+ assert_eq!(
+ config.storage.url.as_deref(),
+ Some("mongodb://app:[email protected]/openhuman")
+ );
+
+ // A key that cannot open the URL must not clear it into "no URL".
+ let other = tempfile::tempdir().unwrap();
+ config.storage.url = Some(sealed.clone());
+ decrypt_config_secrets(&mut config, other.path()).unwrap();
+ assert_eq!(config.storage.url.as_deref(), Some(sealed.as_str()));
+}