Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver-core): gate YAML capability-manifest tests on the yaml feature (#6627)

injaneity3d7d6573a351
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
index e21de7d470..834eebcf4f 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
@@ -1817,6 +1817,7 @@ mod tests {
}
}
+ #[cfg(feature = "yaml")]
#[test]
fn standard_manifest_scope_is_checked_before_existing_profile_approval() {
use std::io::Write as _;
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/batch_tools/tests.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/batch_tools/tests.rs
index 5bf3a22e13..b993a66bbd 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/batch_tools/tests.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/batch_tools/tests.rs
@@ -422,6 +422,7 @@ async fn every_step_runs_in_the_batch_session() {
}
}
+#[cfg(feature = "yaml")]
#[tokio::test]
async fn each_step_is_held_to_the_capability_manifest() {
let harness = Harness::new();
@@ -450,6 +451,7 @@ async fn each_step_is_held_to_the_capability_manifest() {
assert_eq!(harness.hits("set_value"), 0, "later steps never run");
}
+#[cfg(feature = "yaml")]
#[tokio::test]
async fn the_batch_itself_needs_the_manifest_to_allow_it() {
let harness = Harness::new();
@@ -519,6 +521,7 @@ async fn the_old_name_run_actions_still_runs_but_is_not_listed() {
assert!(!text(&current).contains("deprecated"), "{}", text(&current));
}
+#[cfg(feature = "yaml")]
#[tokio::test]
async fn a_manifest_that_allows_run_actions_allows_run_steps() {
let harness = Harness::new();
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs
index b79bc93da3..add8e9b28d 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs
@@ -617,6 +617,7 @@ fn digest_request(request: &ConsentRequest) -> String {
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(feature = "yaml")]
use std::io::Write;
struct FakeProvider {
@@ -682,6 +683,7 @@ mod tests {
.unwrap()
}
+ #[cfg(feature = "yaml")]
fn authorization_context_with_manifest(
mode: PermissionMode,
) -> Arc<crate::session_authorization::EffectiveAuthorizationContext> {
@@ -822,6 +824,7 @@ mod tests {
assert_eq!(provider.requests.load(Ordering::SeqCst), 0);
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn capability_manifest_resources_narrow_standard_and_unrestricted_without_prompting() {
for mode in [PermissionMode::Standard, PermissionMode::Unrestricted] {
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
index 1fc76675e6..33b7324c2e 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
@@ -822,6 +822,7 @@ fn now_unix_ms() -> u128 {
#[cfg(test)]
mod tests {
+ #[cfg(feature = "yaml")]
use std::io::Write;
use super::*;
@@ -837,6 +838,7 @@ mod tests {
}
}
+ #[cfg(feature = "yaml")]
fn manifest_with_allowed_tool(tool: &str) -> Arc<SessionManifest> {
let mut file = tempfile::NamedTempFile::new().unwrap();
writeln!(
@@ -1129,6 +1131,7 @@ mod tests {
);
}
+ #[cfg(feature = "yaml")]
#[test]
fn capability_manifests_are_stored_per_connection_context() {
let registry = SessionAuthorizationRegistry::delegated_for_test(
@@ -1172,6 +1175,7 @@ mod tests {
);
}
+ #[cfg(feature = "yaml")]
#[test]
fn capability_manifest_is_optional_except_in_bounded_mode() {
let registry =
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
index af9c4c5a74..aad1f13481 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
@@ -3827,6 +3827,7 @@ mod runtime_isolation_tests {
protocol::{Content, ToolResult},
session_authorization::{SessionAuthorizationRegistry, SessionModeCeiling},
};
+ #[cfg(feature = "yaml")]
use std::io::Write;
use std::sync::{
atomic::{AtomicUsize, Ordering},
@@ -3860,12 +3861,14 @@ mod runtime_isolation_tests {
.unwrap()
}
+ #[cfg(feature = "yaml")]
fn bounded_context(
manifest_source: &str,
) -> Arc<crate::session_authorization::EffectiveAuthorizationContext> {
manifest_context(PermissionMode::Bounded, manifest_source)
}
+ #[cfg(feature = "yaml")]
fn manifest_context(
mode: PermissionMode,
manifest_source: &str,
@@ -4422,6 +4425,7 @@ mod runtime_isolation_tests {
assert_eq!(provider.requests.load(Ordering::SeqCst), 1);
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn bounded_history_requires_the_matching_operation_resource() {
for (operations, expected_allowed) in
@@ -4449,6 +4453,7 @@ mod runtime_isolation_tests {
}
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn manifest_launch_reaches_the_platform_only_for_launchable_apps() {
const MANIFEST: &str = "version: 3\nexpires_after: 1h\nidle_timeout: 30m\nresources:\n apps:\n - bundle_id: com.apple.TextEdit\n launch: true\n - bundle_id: com.apple.Preview\n launch: false\nallow:\n tools: [launch_app]\n";
@@ -4494,6 +4499,7 @@ mod runtime_isolation_tests {
}
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn bounded_observation_uses_only_the_manifest_without_a_protected_host() {
let hits = Arc::new(AtomicUsize::new(0));
@@ -4527,6 +4533,7 @@ resources:
assert_ne!(result.is_error, Some(true));
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn capability_manifest_typed_resources_narrow_standard_and_unrestricted() {
for mode in [PermissionMode::Standard, PermissionMode::Unrestricted] {
@@ -4590,6 +4597,7 @@ resources:
}
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn capability_manifest_tools_narrow_standard_and_unrestricted() {
for mode in [PermissionMode::Standard, PermissionMode::Unrestricted] {
@@ -4615,6 +4623,7 @@ allow:
}
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn rejected_typed_resource_does_not_refresh_manifest_idle_lease() {
let denied_hits = Arc::new(AtomicUsize::new(0));
@@ -4981,6 +4990,7 @@ resources:
assert_eq!(provider.requests.load(Ordering::SeqCst), 0);
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn background_input_rechecks_manifest_before_every_adapter_dispatch() {
// The adapter may retain a native connection after a successful call.
@@ -5704,6 +5714,7 @@ resources:
);
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn manifest_cannot_widen_standard_foreign_process_termination() {
let hits = Arc::new(AtomicUsize::new(0));
@@ -5741,6 +5752,7 @@ resources:
);
}
+ #[cfg(feature = "yaml")]
#[tokio::test]
async fn manifest_preserves_standard_owned_process_termination_inside_scope() {
let hits = Arc::new(AtomicUsize::new(0));