Skip to content

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

test(tinyflows): install local credential for published prompt e2e

Steven Enamakel9bcf7d4e70a7
diff --git a/tests/tinyflows_published_prompt_e2e.rs b/tests/tinyflows_published_prompt_e2e.rs
index bddbbbf4ff..b907e1a61e 100644
--- a/tests/tinyflows_published_prompt_e2e.rs
+++ b/tests/tinyflows_published_prompt_e2e.rs
@@ -122,6 +122,37 @@ async fn published_module_prompts_render_through_the_normal_host_path() {
std::fs::write(path, &enabled_config).expect("write enabled module override config");
}
+ // `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). 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 = 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"),
("flow_discovery", "suggest_workflows", "read-only"),
@@ -151,6 +182,13 @@ async fn published_module_prompts_render_through_the_normal_host_path() {
openhuman_core::config::Config::load_from_config_path(&config_path, &workspace)
.await
.expect("load the same scoped Config used by the prompt dump");
+ // The in-process host session resolves its credential from this config's
+ // own state directory, not the one the child processes used.
+ openhuman_core::security::credentials::api_key::store_api_key(
+ &config,
+ "th_test_local_only",
+ )
+ .expect("store a local test credential for the in-process host session");
let ctx = openhuman_core::core::runtime::DispatchCtx::host_default();
tinyhumans_boot::boot();
prewarm_flow_authoring_in_parent(&ctx, &config).await;