Skip to content

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

test(core,mcp): add more integration tests

Steven Enamakel2914a17b9507
diff --git a/crates/openhuman-core/src/core/sentry_transport_tests.rs b/crates/openhuman-core/src/core/sentry_transport_tests.rs
index 21a4fffd8c..6119eb65ea 100644
--- a/crates/openhuman-core/src/core/sentry_transport_tests.rs
+++ b/crates/openhuman-core/src/core/sentry_transport_tests.rs
@@ -67,3 +67,16 @@ fn send_failure_does_not_prevent_flush() {
assert!(transport.flush(Duration::from_secs(3)));
assert!(transport.shutdown(Duration::from_secs(3)));
}
+
+#[test]
+fn an_invalid_proxy_is_ignored_rather_than_failing_the_transport() {
+ let options = ClientOptions {
+ dsn: Some("http://[email protected]:9/1".parse().unwrap()),
+ http_proxy: Some("http://[not a proxy".into()),
+ https_proxy: Some("http://[not a proxy".into()),
+ debug: true,
+ ..Default::default()
+ };
+ let transport = SharedReqwestTransport::new(&options);
+ transport.shutdown(Duration::from_secs(1));
+}
diff --git a/crates/openhuman-core/src/mcp/host_sandbox_tests.rs b/crates/openhuman-core/src/mcp/host_sandbox_tests.rs
index f5533f8e9e..f933f5bef5 100644
--- a/crates/openhuman-core/src/mcp/host_sandbox_tests.rs
+++ b/crates/openhuman-core/src/mcp/host_sandbox_tests.rs
@@ -87,3 +87,97 @@ fn built_sandbox_enforcement_follows_the_isolation_requirement() {
enforcement(sandbox.require_process_isolation)
);
}
+
+/// Runs `body` with a thread-local subscriber that enables every level, so the
+/// warnings the refusal paths log are evaluated rather than skipped.
+fn with_logging<T>(body: impl FnOnce() -> T) -> T {
+ let subscriber = tracing_subscriber::fmt()
+ .with_max_level(tracing::Level::TRACE)
+ .with_test_writer()
+ .finish();
+ tracing::subscriber::with_default(subscriber, body)
+}
+
+#[cfg(feature = "modules")]
+#[test]
+fn an_unusable_workspace_refuses_stdio_servers_instead_of_running_them_unconfined() {
+ let tmp = tempfile::tempdir().unwrap();
+ let file = tmp.path().join("not-a-dir");
+ std::fs::write(&file, b"").unwrap();
+ assert!(with_logging(|| stdio_sandbox(&config_in(&file))).is_none());
+}
+
+#[test]
+fn home_relative_grants_expand_and_forbidden_ones_are_refused() {
+ let home = tempfile::tempdir().unwrap();
+ std::fs::create_dir_all(home.path().join("tools")).unwrap();
+ let raw = vec![
+ "~/tools".to_string(),
+ "~/tools".to_string(),
+ "/etc".to_string(),
+ home.path().to_string_lossy().into_owned(),
+ ];
+ std::fs::create_dir_all(home.path().join(".ssh")).unwrap();
+ let admitted = with_logging(|| admit_all(&raw, Some(home.path())));
+ let tools = home.path().join("tools").canonicalize().unwrap();
+ assert_eq!(admitted, vec![tools.to_string_lossy().into_owned()]);
+}
+
+#[test]
+fn merged_grants_are_deduplicated() {
+ let mut into = vec!["/a".to_string()];
+ merge(
+ &mut into,
+ &[PathBuf::from("/a"), PathBuf::from("/b"), PathBuf::from("/b")],
+ );
+ assert_eq!(into, vec!["/a".to_string(), "/b".to_string()]);
+}
+
+#[cfg(feature = "modules")]
+#[test]
+fn existing_credential_stores_are_denied_by_their_real_path() {
+ let tmp = tempfile::tempdir().unwrap();
+ let home = tmp.path().join("home");
+ let ssh = home.join(".ssh");
+ std::fs::create_dir_all(&ssh).unwrap();
+ let workspace = tmp.path().join("workspace");
+ std::fs::create_dir_all(&workspace).unwrap();
+ let config = config_in(&workspace);
+ let denied = credential_denials(&config, Some(&home), &workspace);
+ let ssh = ssh.canonicalize().unwrap().to_string_lossy().into_owned();
+ assert!(denied.contains(&ssh), "{denied:?}");
+ assert_eq!(denied.iter().filter(|d| **d == ssh).count(), 1);
+}
+
+#[cfg(feature = "modules")]
+#[test]
+fn a_workspace_inside_a_credential_store_is_not_denied_to_itself() {
+ let tmp = tempfile::tempdir().unwrap();
+ let home = tmp.path().join("home");
+ let workspace = home.join(".ssh").join("mcp_stdio");
+ std::fs::create_dir_all(&workspace).unwrap();
+ let workspace = workspace.canonicalize().unwrap();
+ let config = config_in(&workspace);
+ let denied = with_logging(|| credential_denials(&config, Some(&home), &workspace));
+ let ssh = home.join(".ssh").canonicalize().unwrap();
+ assert!(
+ !denied.contains(&ssh.to_string_lossy().into_owned()),
+ "{denied:?}"
+ );
+}
+
+#[cfg(feature = "modules")]
+#[tokio::test]
+async fn toolchain_grants_only_ever_add_to_the_configured_grants() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(tmp.path());
+ let mut sandbox = stdio_sandbox(&config).expect("a sandbox");
+ let before = sandbox.read_only.clone();
+ let subscriber = tracing_subscriber::fmt()
+ .with_max_level(tracing::Level::TRACE)
+ .with_test_writer()
+ .finish();
+ let _guard = tracing::subscriber::set_default(subscriber);
+ with_toolchain_grants(&config, &mut sandbox).await;
+ assert!(before.iter().all(|grant| sandbox.read_only.contains(grant)));
+}