Skip to content

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

test(saas): cover per-user agent provisioning lifecycle

Steven Enamakel92a4a4b4d03c
diff --git a/tests/saas_mode_e2e.rs b/tests/saas_mode_e2e.rs
index 79471107a6..d595862390 100644
--- a/tests/saas_mode_e2e.rs
+++ b/tests/saas_mode_e2e.rs
@@ -125,12 +125,22 @@ fn rpc(
base: &str,
bearer: Option<&str>,
method: &str,
+) -> (u16, Value) {
+ rpc_with(client, base, bearer, method, json!({}))
+}
+
+fn rpc_with(
+ client: &reqwest::blocking::Client,
+ base: &str,
+ bearer: Option<&str>,
+ method: &str,
+ params: Value,
) -> (u16, Value) {
let mut request = client.post(format!("{base}/rpc")).json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": method,
- "params": {}
+ "params": params
}));
if let Some(bearer) = bearer {
request = request.bearer_auth(bearer);
@@ -192,6 +202,47 @@ fn a_safe_deployment_serves_only_core_built_ins_behind_the_gateway_bearer() {
);
}
+ // The operator plane provisions one agent per user, keyed by a hash of
+ // the gateway's user id, which is never echoed back.
+ let (_, body) = rpc_with(
+ &client,
+ &base,
+ Some(BEARER),
+ "openhuman.user_agents_provision",
+ json!({ "user_id": "[email protected]" }),
+ );
+ let result = body.get("result").unwrap_or_else(|| panic!("provision: {body}"));
+ let agent_id = result
+ .pointer("/result/agent_id")
+ .or_else(|| result.get("agent_id"))
+ .and_then(Value::as_str)
+ .unwrap_or_else(|| panic!("agent_id in {result}"))
+ .to_string();
+ assert!(agent_id.starts_with("u-"), "{agent_id}");
+ assert!(!body.to_string().contains("alice"), "{body}");
+ assert!(d.root.join("agents").join(&agent_id).join("workspace").is_dir());
+
+ let (_, body) = rpc(&client, &base, Some(BEARER), "openhuman.user_agents_list");
+ assert!(body.to_string().contains(&agent_id), "{body}");
+ let (_, body) = rpc_with(
+ &client,
+ &base,
+ Some(BEARER),
+ "openhuman.user_agents_status",
+ json!({ "agent_id": agent_id }),
+ );
+ assert!(body.get("result").is_some(), "{body}");
+ let (_, body) = rpc_with(
+ &client,
+ &base,
+ Some(BEARER),
+ "openhuman.user_agents_deprovision",
+ json!({ "agent_id": agent_id }),
+ );
+ assert!(body.get("result").is_some(), "{body}");
+ assert!(!d.root.join("agents").join(&agent_id).exists());
+ assert!(d.root.join("deprovisioned").is_dir(), "archived, not deleted");
+
assert!(
d.root.join("operator").join("workspace").is_dir(),
"the operator plane lives under the SaaS root"