Skip to content

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

test(tinyflows): install credential via auth_set_credential in prompt e2e

Steven Enamakelba9b1b8e3547
diff --git a/tests/tinyflows_published_prompt_e2e.rs b/tests/tinyflows_published_prompt_e2e.rs
index 0ccdedeea5..6736f26090 100644
--- a/tests/tinyflows_published_prompt_e2e.rs
+++ b/tests/tinyflows_published_prompt_e2e.rs
@@ -124,19 +124,34 @@ async fn published_module_prompts_render_through_the_normal_host_path() {
// `agent dump-prompt` reads the install it is pointed at and builds the real
// session agent, which needs a stored backend credential (`SESSION_EXPIRED`
- // otherwise). Store a local-only key where the child will read it, under a
- // per-run master key the child inherits. `api_url` is unroutable.
+ // otherwise). Install a local-only key the way a host does, through
+ // `auth_set_credential`, under a per-run master key the child processes
+ // inherit. `api_url` is unroutable, so nothing leaves the machine.
let _master_key_guard =
EnvVarGuard::set("OPENHUMAN_KEYRING_MASTER_KEY", "5a".repeat(32).as_str());
let _keyring_backend_guard = EnvVarGuard::set("OPENHUMAN_KEYRING_BACKEND", "file");
- let credential_config = openhuman_core::config::Config::load_or_init()
- .await
- .expect("load the config the prompt dump will read");
- openhuman_core::security::credentials::api_key::store_api_key(
- &credential_config,
- "th_test_local_only",
- )
- .expect("store a local test credential for the prompt dump");
+ let credential = Command::new(env!("CARGO_BIN_EXE_openhuman-core"))
+ .args([
+ "call",
+ "--method",
+ "openhuman.auth_set_credential",
+ "--params",
+ r#"{"token":"th_test_local_only","kind":"api-key"}"#,
+ ])
+ .env("HOME", temp.path())
+ .env("OPENHUMAN_WORKSPACE", &workspace)
+ .env("OPENHUMAN_MODULE_PATH", module_search_path)
+ .env_remove("BACKEND_URL")
+ .env_remove("VITE_BACKEND_URL")
+ .env_remove("OPENHUMAN_BACKEND_API_KEY")
+ .env_remove("OPENHUMAN_BACKEND_SESSION_TOKEN")
+ .output()
+ .expect("install the local test credential");
+ assert!(
+ credential.status.success(),
+ "installing the local test credential failed: {}",
+ String::from_utf8_lossy(&credential.stderr)
+ );
for (agent_id, required, invariant) in [
("workflow_builder", "propose_workflow", "propose-only"),