Skip to content

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

test(connectors): add test for proxy policy propagation to module config

Steven Enamakel57b8b942ba80
diff --git a/crates/openhuman-core/src/integrations/composio/module_client_tests.rs b/crates/openhuman-core/src/integrations/composio/module_client_tests.rs
index 73af3647b6..1f7123c39e 100644
--- a/crates/openhuman-core/src/integrations/composio/module_client_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/module_client_tests.rs
@@ -1,6 +1,6 @@
//! Tests for the connector module shim.
-use super::{is_unsupported_by_route, methods};
+use super::{is_unsupported_by_route, member_failure_message, methods};
#[test]
fn classified_errors_start_with_the_frontend_marker() {
diff --git a/crates/openhuman-core/src/modules/connectors_tests.rs b/crates/openhuman-core/src/modules/connectors_tests.rs
index c4e2cb8ca0..5e6b46fd54 100644
--- a/crates/openhuman-core/src/modules/connectors_tests.rs
+++ b/crates/openhuman-core/src/modules/connectors_tests.rs
@@ -88,6 +88,47 @@ fn direct_mode_takes_the_api_key_from_the_config_file() {
assert!(blob.get("state_dir").is_some());
}
+#[test]
+fn direct_mode_hands_the_module_the_hosts_proxy_policy() {
+ // Part of the route description, so a proxy change reconfigures the module.
+ use crate::config::schema::{ProxyConfig, ProxyScope};
+ use crate::config::{runtime_proxy_config, set_runtime_proxy_config};
+
+ let _env = crate::config::TEST_ENV_LOCK
+ .lock()
+ .unwrap_or_else(|e| e.into_inner());
+ let mut config = bare_config();
+ config.composio.mode = COMPOSIO_MODE_DIRECT.to_string();
+ config.composio.api_key = Some("sk-from-file".to_string());
+
+ let previous = runtime_proxy_config();
+ set_runtime_proxy_config(ProxyConfig {
+ enabled: true,
+ https_proxy: Some("http://127.0.0.1:3128".into()),
+ no_proxy: vec!["localhost".into()],
+ scope: ProxyScope::OpenHuman,
+ ..ProxyConfig::default()
+ });
+ let proxied = module_config(&config).expect("resolves");
+ set_runtime_proxy_config(ProxyConfig::default());
+ let plain = module_config(&config).expect("resolves");
+ set_runtime_proxy_config(previous);
+
+ assert_eq!(proxied["transport"]["proxy_url"], "http://127.0.0.1:3128");
+ assert_eq!(proxied["transport"]["no_proxy"][0], "localhost");
+ if !cfg!(target_os = "windows") {
+ assert!(
+ plain.get("transport").is_none(),
+ "the default policy is not sent"
+ );
+ }
+ assert_ne!(
+ super::fingerprint(&proxied),
+ super::fingerprint(&plain),
+ "a proxy change must change the route fingerprint"
+ );
+}
+
#[test]
fn direct_mode_without_a_key_is_refused() {
// Rather than silently falling back to the backend route, which would send