Skip to content

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

test: store local credentials in e2e tests that build session agents

Steven Enamakelc5715ef8aad0
diff --git a/tests/json_rpc_agent_team_e2e.rs b/tests/json_rpc_agent_team_e2e.rs
index ea1db81d56..47d7b9f398 100644
--- a/tests/json_rpc_agent_team_e2e.rs
+++ b/tests/json_rpc_agent_team_e2e.rs
@@ -568,6 +568,17 @@ async fn json_rpc_agent_registry_manages_defaults_and_custom_agents() {
// The agent editor's tool picker is fed by available_tools — every entry is
// a {name, description} pair whose name is a valid tool_allowlist value.
+ // The tools catalog builds a real session agent, which needs a backend
+ // session.
+ let store = post_json_rpc(
+ &rpc_base,
+ 286_199,
+ "openhuman.auth_store_session",
+ json!({ "token": "e2e-test-jwt", "user_id": "e2e-user" }),
+ )
+ .await;
+ assert_no_jsonrpc_error(&store, "auth_store_session");
+
let available_tools = post_json_rpc(
&rpc_base,
286_224,
diff --git a/tests/json_rpc_threads_e2e.rs b/tests/json_rpc_threads_e2e.rs
index 61b2e53d31..4a30afa72b 100644
--- a/tests/json_rpc_threads_e2e.rs
+++ b/tests/json_rpc_threads_e2e.rs
@@ -1080,8 +1080,9 @@ async fn json_rpc_threads_transcript_get_projects_and_paginates() {
let mut config = config;
config.agent.chat_agent_id = Some("orchestrator".into());
config.save().await.expect("save test chat agent");
- openhuman_core::agent_registry::host_definition::AgentDefinitionRegistry::init_global_builtins()
- .expect("initialize built-in agent definitions");
+ openhuman_core::agent_registry::host_definition::AgentDefinitionRegistry::init_global_builtins(
+ )
+ .expect("initialize built-in agent definitions");
let backend = openhuman_core::storage::local::backend_for(&config.workspace_dir)
.expect("open test workspace storage");
let reports = openhuman_core::storage::import::sessions::run_with(&backend, &config);
diff --git a/tests/legacy_voice_config_boot_e2e.rs b/tests/legacy_voice_config_boot_e2e.rs
index 2f7680b1d7..59706d73cf 100644
--- a/tests/legacy_voice_config_boot_e2e.rs
+++ b/tests/legacy_voice_config_boot_e2e.rs
@@ -125,6 +125,8 @@ fn legacy_voice_settings_boot_without_starting_retired_listeners() {
.env("OPENHUMAN_DOTENV_PATH", &dotenv_path)
.env("OPENHUMAN_CORE_TOKEN", TOKEN)
.env("OPENHUMAN_KEYRING_BACKEND", "file")
+ // Installing the credential encrypts it; a hermetic child cannot rely on an OS keychain.
+ .env("OPENHUMAN_KEYRING_MASTER_KEY", "5a".repeat(32))
.env("RUST_LOG", "info")
.env("BACKEND_URL", backend_url)
.env_remove("OPENHUMAN_BACKEND_API_KEY")
diff --git a/tests/tinyflows_published_prompt_e2e.rs b/tests/tinyflows_published_prompt_e2e.rs
index c3725f610d..b536e7822e 100644
--- a/tests/tinyflows_published_prompt_e2e.rs
+++ b/tests/tinyflows_published_prompt_e2e.rs
@@ -35,10 +35,7 @@ fn dump_published_prompt(
.env("OPENHUMAN_MODULE_PATH", module_search_path)
.env_remove("BACKEND_URL")
.env_remove("VITE_BACKEND_URL")
- // Building the session agent resolves a backend credential before it
- // renders a prompt (`SESSION_EXPIRED` otherwise). A fixed local key
- // satisfies that without reaching any backend: `api_url` is unroutable.
- .env("OPENHUMAN_BACKEND_API_KEY", "th_test_local_only")
+ .env_remove("OPENHUMAN_BACKEND_API_KEY")
.env_remove("OPENHUMAN_BACKEND_SESSION_TOKEN")
.env_remove("OPENHUMAN_STORAGE_URL")
.env_remove("OPENHUMAN_MODULE_SOURCE")
@@ -125,6 +122,23 @@ 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). Store a local-only key where the child will read it, under a
+ // per-run master key the child inherits. `api_url` is unroutable.
+ 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_from_config_path(&config_path, &workspace)
+ .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");
+
for (agent_id, required, invariant) in [
("workflow_builder", "propose_workflow", "propose-only"),
("flow_discovery", "suggest_workflows", "read-only"),