Skip to content

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

test(inference): add jwt tests to factory module

Steven Enamakelb164a2553e2a
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_jwt_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_jwt_tests.rs
new file mode 100644
index 0000000000..2ecb1d65da
--- /dev/null
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_jwt_tests.rs
@@ -0,0 +1,32 @@
+use super::*;
+
+#[test]
+fn unmanaged_openhuman_jwt_route_never_builds_a_direct_unauthenticated_model() {
+ let _guard = crate::inference::inference_test_guard();
+ let mut config = Config::default();
+ config.cloud_providers.push(CloudProviderCreds {
+ id: "p_managed".to_string(),
+ slug: "managed".to_string(),
+ label: "Managed".to_string(),
+ endpoint: "https://api.example/v1".to_string(),
+ auth_style: AuthStyle::OpenhumanJwt,
+ ..Default::default()
+ });
+
+ let error = try_create_cloud_slug_chat_model_from_string_with_native_tools(
+ "chat",
+ "managed:model",
+ &config,
+ true,
+ &EgressLedger::none(),
+ )
+ .expect("configured slug")
+ .expect_err("unregistered managed credentials must not reach the direct registry");
+
+ assert!(
+ error
+ .to_string()
+ .contains("hosted cloud authentication is unavailable"),
+ "unexpected error: {error}"
+ );
+}
diff --git a/crates/openhuman-core/src/inference/provider/factory_tests.rs b/crates/openhuman-core/src/inference/provider/factory_tests.rs
index 4d90ae3028..0f2290e625 100644
--- a/crates/openhuman-core/src/inference/provider/factory_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_tests.rs
@@ -261,6 +261,8 @@ fn only_library_hosts_are_exempt_from_app_login() {
mod crate_native_diagnostics_tests;
#[path = "factory_crate_native_tests.rs"]
mod crate_native_tests;
+#[path = "factory_crate_native_jwt_tests.rs"]
+mod crate_native_jwt_tests;
#[path = "factory_egress_fallback_tests.rs"]
mod egress_fallback_tests;
#[path = "factory_explicit_ctx_tests.rs"]