Skip to content

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

test(keyring): add fixture generation test for encrypted file backend

Steven Enamakelcdf9cb78a06c
diff --git a/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs b/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs
index a0a30730da..9e8f5eb69a 100644
--- a/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs
+++ b/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs
@@ -483,3 +483,23 @@ fn init_once_caches_a_loaded_key_and_a_keychain_outage_as_ok() {
Ok(())
);
}
+
+#[test]
+fn zz_generate_fixtures_tmp() {
+ let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/security/keyring/fixtures");
+ std::fs::create_dir_all(&dir).unwrap();
+ let key = [0x42u8; KEY_LEN];
+ let tmp = tempfile::TempDir::new().unwrap();
+ let b = EncryptedFileBackend::new(tmp.path());
+ b.set_with_key(&key, "user-1:session_token", "tok-abc-123").unwrap();
+ b.set_with_key(&key, "user-1:api_key", "sk-fixture-\u{00e9}\u{4e2d}").unwrap();
+ b.set_with_key(&key, "user-2:session_token", "tok-other").unwrap();
+ std::fs::copy(tmp.path().join("secrets.enc"), dir.join("secrets.enc")).unwrap();
+ let store_dir = tempfile::TempDir::new().unwrap();
+ std::fs::write(store_dir.path().join(".secret_key"), crypto::hex_encode(&key)).unwrap();
+ let enc = |p: &str| {
+ tinystoragedrivers::secrets::crypto::encrypt_enc2(&key, p.as_bytes()).unwrap()
+ };
+ let values = format!("{}\n{}\n", enc("sk-test-fixture-value"), enc("pa\u{00df}word \u{1f511}"));
+ std::fs::write(dir.join("enc2_values.txt"), values).unwrap();
+}