Skip to content

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

refactor(tests): remove cloud adapter tests

Steven Enamakeld5962a1bc4b9
diff --git a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter_tests.rs b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter_tests.rs
index e5a8baa917..b7f56dfc8c 100644
--- a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter_tests.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter_tests.rs
@@ -17,77 +17,3 @@ async fn unregistered_managed_embedder_answers_backend_unavailable() {
"unexpected error: {err}"
);
}
-
-/// The keyless credential scope must land in the **user-scoped** directory,
-/// never the root. Sign-in writes `auth-profiles.json` to
-/// `{root}/users/<user_id>/`; the root itself holds no such file, so the
-/// previous root-returning implementation made every keyless managed
-/// embedder fail with "No backend session for cloud embeddings" for a user
-/// who was signed in.
-#[test]
-fn default_scope_is_the_active_user_dir_not_the_root() {
- let root = std::path::Path::new("/tmp/openhuman-root");
-
- let resolved = user_scoped_state_dir(root, Some("user-abc123"));
-
- assert_eq!(
- resolved,
- root.join("users").join("user-abc123"),
- "managed embedder must read credentials from the active user's dir"
- );
- assert_ne!(
- resolved, root,
- "the root dir holds no auth-profiles.json — resolving to it is the bug"
- );
-}
-
-/// With no user signed in yet, the scope is the pre-login user dir — the
-/// same directory the pre-login config and its credential store live in.
-/// Falling back to the root here would reintroduce the same empty-store
-/// failure one login earlier.
-#[test]
-fn default_scope_falls_back_to_the_pre_login_user_dir() {
- let root = std::path::Path::new("/tmp/openhuman-root");
-
- let resolved = user_scoped_state_dir(root, None);
-
- assert_eq!(
- resolved,
- root.join("users").join(crate::config::PRE_LOGIN_USER_ID),
- "a pre-login process must read its own store, not the empty root"
- );
-}
-
-/// `OPENHUMAN_WORKSPACE` must resolve through the same workspace→config-dir
-/// mapping `config::load` uses, not return the raw workspace path. A legacy
-/// `<X>/workspace` override keeps its credentials in the sibling
-/// `<X>/.openhuman` dir; returning the workspace dir itself would send the
-/// keyless embedder to a directory with no `auth-profiles.json` and
-/// reintroduce "No backend session" for that deployment.
-#[test]
-fn env_workspace_scope_is_the_config_dir_not_the_raw_workspace() {
- // Legacy sibling layout: `<X>/workspace` with credentials in `<X>/.openhuman`.
- // A `workspace`-basename override whose parent is not the `.openhuman` config
- // dir maps to the sibling `<X>/.openhuman` (where `auth-profiles.json` lives).
- // The modern-layout arm intercepts the `~/.openhuman/workspace` shape before
- // this one, so this arm can no longer produce a doubled path (#6079). A real
- // temp dir is used because `default_state_dir` operates on real filesystem
- // layouts; the sibling need not pre-exist for resolution to pick it.
- let root = tempfile::tempdir().unwrap();
- let base = root.path();
- let workspace = base.join("workspace");
- let sibling_config = base.join(".openhuman");
- std::fs::create_dir_all(&workspace).unwrap();
- std::fs::create_dir_all(&sibling_config).unwrap();
-
- let resolved = env_workspace_state_dir(&workspace);
-
- assert_eq!(
- resolved, sibling_config,
- "a `.../workspace` override must resolve to its sibling .openhuman config dir"
- );
- assert_ne!(
- resolved, workspace,
- "returning the raw workspace dir is the regression this guards against"
- );
-}
diff --git a/crates/openhuman-core/src/security/credentials/embedding_scope_tests.rs b/crates/openhuman-core/src/security/credentials/embedding_scope_tests.rs
new file mode 100644
index 0000000000..4910d196a7
--- /dev/null
+++ b/crates/openhuman-core/src/security/credentials/embedding_scope_tests.rs
@@ -0,0 +1,69 @@
+use super::*;
+
+/// Configured embedding credentials follow the caller's config directory and
+/// encryption setting, even when the process has a different default scope.
+#[test]
+fn configured_scope_uses_config_directory_and_encryption() {
+ let temp = tempfile::tempdir().unwrap();
+ let mut config = Config::default();
+ config.config_path = temp
+ .path()
+ .join("users")
+ .join("account")
+ .join("config.toml");
+ config.secrets.encrypt = false;
+
+ let (state_dir, encrypt) = credential_scope(Some(&config));
+
+ assert_eq!(state_dir, config.config_path.parent().unwrap());
+ assert!(!encrypt);
+}
+
+/// Call sites without a config retain the encrypted process-default policy.
+#[test]
+fn unconfigured_scope_defaults_to_encrypted_credentials() {
+ let (_, encrypt) = credential_scope(None);
+
+ assert!(encrypt);
+}
+
+/// The keyless credential scope must land in the active user's directory,
+/// never the root where there is no user auth profile.
+#[test]
+fn default_scope_is_the_active_user_dir_not_the_root() {
+ let root = Path::new("/tmp/openhuman-root");
+
+ let resolved = user_scoped_state_dir(root, Some("user-abc123"));
+
+ assert_eq!(resolved, root.join("users").join("user-abc123"));
+ assert_ne!(resolved, root);
+}
+
+/// Before sign-in, credential resolution uses the pre-login profile directory.
+#[test]
+fn default_scope_falls_back_to_the_pre_login_user_dir() {
+ let root = Path::new("/tmp/openhuman-root");
+
+ let resolved = user_scoped_state_dir(root, None);
+
+ assert_eq!(
+ resolved,
+ root.join("users").join(crate::config::PRE_LOGIN_USER_ID)
+ );
+}
+
+/// Legacy workspace overrides resolve to their sibling config directory,
+/// matching the location that stores auth profiles.
+#[test]
+fn env_workspace_scope_is_the_config_dir_not_the_raw_workspace() {
+ let root = tempfile::tempdir().unwrap();
+ let workspace = root.path().join("workspace");
+ let sibling_config = root.path().join(".openhuman");
+ std::fs::create_dir_all(&workspace).unwrap();
+ std::fs::create_dir_all(&sibling_config).unwrap();
+
+ let resolved = env_workspace_state_dir(&workspace);
+
+ assert_eq!(resolved, sibling_config);
+ assert_ne!(resolved, workspace);
+}