Skip to content

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

test(raw_coverage): remove obsolete approval redaction and parser tests

Steven Enamakel1d68b4d77003
diff --git a/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs b/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
index e47fdeff20..a48f2c0884 100644
--- a/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
@@ -836,285 +836,6 @@ async fn tool_registry_diagnostics_reports_config_and_audit_store_failures() {
.is_some_and(|error| !error.is_empty()));
}
-#[test]
-fn approval_redaction_and_store_cover_shape_expiry_migration_and_audit_branches() {
- let dir = tempdir().expect("tempdir");
- let config = Config {
- workspace_dir: dir.path().to_path_buf(),
- ..Config::default()
- };
-
- let raw_args = json!({
- "action": "execute",
- "tool_slug": "GMAIL_SEND_EMAIL",
- "integration": "gmail",
- "body": "Hello from /Users/alice/private.txt",
- "recipients": ["[email protected]", "[email protected]"],
- "metadata": {
- "Subject": "Confidential subject",
- "token": "sk-secret",
- "auth": true,
- "message": 42,
- "password": null,
- "user": { "id": "user-123", "name": "Alice" },
- "attempts": 3,
- "confirmed": true,
- "nullable": null,
- "safe_path": "C:\\Users\\bob\\Desktop\\report.txt",
- "safe_list": [
- "open /Users/frank/Desktop/report.txt",
- { "content": "nested secret" }
- ]
- }
- });
- let redacted = redact_args(&raw_args);
- assert_eq!(redacted["action"], json!("execute"));
- assert_eq!(redacted["body"], json!("<redacted: string (35 chars)>"));
- assert_eq!(redacted["recipients"], json!("<redacted: array (2 items)>"));
- assert_eq!(
- redacted.pointer("/metadata/Subject"),
- Some(&json!("<redacted: string (20 chars)>"))
- );
- assert_eq!(
- redacted.pointer("/metadata/attempts"),
- Some(&json!(3)),
- "non-sensitive numeric fields should pass through"
- );
- assert_eq!(
- redacted.pointer("/metadata/auth"),
- Some(&json!("<redacted: bool>"))
- );
- assert_eq!(
- redacted.pointer("/metadata/message"),
- Some(&json!("<redacted: number>"))
- );
- assert_eq!(redacted.pointer("/metadata/password"), Some(&Value::Null));
- assert_eq!(
- redacted.pointer("/metadata/user"),
- Some(&json!("<redacted: object (2 keys)>"))
- );
- assert_eq!(
- redacted.pointer("/metadata/safe_list/0"),
- Some(&json!("open <HOME>/Desktop/report.txt"))
- );
- assert_eq!(
- redacted.pointer("/metadata/safe_list/1/content"),
- Some(&json!("<redacted: string (13 chars)>"))
- );
- assert_eq!(
- redact_args(&json!(
- "open /home/carol/report.md and C:\\Users\\dave\\x.txt"
- )),
- json!("open <HOME>/report.md and <HOME>\\x.txt")
- );
- assert_eq!(redact_args(&json!("/Users/erin")), json!("<HOME>"));
- let summary = summarize_action("tools.composio_execute", &raw_args);
- assert!(summary.contains("action=execute"));
- assert!(summary.contains("tool_slug=GMAIL_SEND_EMAIL"));
- assert!(summary.contains("integration=gmail"));
- let summary_without_safe_fields = summarize_action("tools.empty", &json!(["opaque"]));
- assert!(summary_without_safe_fields.starts_with("tools.empty ("));
-
- approval_store::insert_pending(
- &config,
- &pending(
- "expired",
- "session-a",
- Some(chrono::Utc::now() - chrono::Duration::minutes(5)),
- ),
- "session-a",
- )
- .expect("insert expired");
- approval_store::insert_pending(
- &config,
- &pending(
- "active",
- "session-a",
- Some(chrono::Utc::now() + chrono::Duration::minutes(5)),
- ),
- "session-a",
- )
- .expect("insert active");
- approval_store::insert_pending(
- &config,
- &pending("other-session", "session-b", None),
- "session-b",
- )
- .expect("insert no-ttl");
-
- let rows = approval_store::list_pending(&config).expect("list pending");
- let ids = rows
- .iter()
- .map(|row| row.request_id.as_str())
- .collect::<Vec<_>>();
- assert_eq!(ids, vec!["active", "other-session"]);
- assert_eq!(
- approval_store::get_decision(&config, "expired").expect("expired decision"),
- Some(ApprovalDecision::Deny)
- );
-
- let removed = approval_store::purge_session(&config, "session-b").expect("purge session");
- assert_eq!(removed, 1);
- assert_eq!(
- approval_store::purge_session(&config, "missing-session").unwrap(),
- 0
- );
-
- let decided = approval_store::decide(&config, "active", ApprovalDecision::ApproveOnce)
- .expect("decide active")
- .expect("active row");
- assert_eq!(decided.request_id, "active");
- assert!(!approval_store::record_execution(
- &config,
- "missing",
- ExecutionOutcome::Aborted,
- Some("not found"),
- )
- .expect("unknown record execution"));
- assert!(approval_store::record_execution(
- &config,
- "active",
- ExecutionOutcome::Failure,
- Some("upstream Authorization: Bearer sk-live-abcdefghijklmnopqrstuvwxyz failed"),
- )
- .expect("record failed execution"));
- assert!(!approval_store::record_execution(
- &config,
- "active",
- ExecutionOutcome::Success,
- Some("late rewrite"),
- )
- .expect("idempotent execution"));
-
- let audit = approval_store::list_recent_decisions(&config, 0).expect("recent decisions");
- assert_eq!(audit.len(), 1, "zero limit should clamp to one");
- assert_eq!(audit[0].request_id, "active");
- assert_eq!(audit[0].decision, ApprovalDecision::ApproveOnce);
-
- let db_path = approval_db_path(&config);
- let conn = Connection::open(&db_path).expect("open approval db");
- conn.execute(
- "INSERT INTO pending_approvals
- (request_id, tool_name, action_summary, args_redacted, session_id, created_at,
- decided_at, decision)
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
- params![
- "corrupt-json",
- "tools.web_search",
- "corrupt args",
- "{not valid json",
- "session-a",
- chrono::Utc::now().to_rfc3339(),
- chrono::Utc::now().to_rfc3339(),
- "deny",
- ],
- )
- .expect("insert corrupt audit row");
- drop(conn);
- let audit = approval_store::list_recent_decisions(&config, 10).expect("audit with corrupt row");
- let corrupt = audit
- .iter()
- .find(|row| row.request_id == "corrupt-json")
- .expect("corrupt audit row");
- assert_eq!(
- corrupt.args_redacted,
- json!({ "_error": "args_redacted not valid JSON" })
- );
-
- let legacy_dir = tempdir().expect("legacy tempdir");
- let legacy_config = Config {
- workspace_dir: legacy_dir.path().to_path_buf(),
- ..Config::default()
- };
- let legacy_db = approval_db_path(&legacy_config);
- std::fs::create_dir_all(legacy_db.parent().expect("legacy db parent"))
- .expect("create legacy db dir");
- let legacy_conn = Connection::open(&legacy_db).expect("open legacy db");
- legacy_conn
- .execute_batch(
- "CREATE TABLE pending_approvals (
- request_id TEXT PRIMARY KEY,
- tool_name TEXT NOT NULL,
- action_summary TEXT NOT NULL,
- args_redacted TEXT NOT NULL,
- session_id TEXT NOT NULL,
- created_at TEXT NOT NULL,
- expires_at TEXT,
- decided_at TEXT,
- decision TEXT
- );",
- )
- .expect("create legacy schema");
- legacy_conn
- .execute(
- "INSERT INTO pending_approvals
- (request_id, tool_name, action_summary, args_redacted, session_id, created_at)
- VALUES ('legacy', 'tools.web_search', 'legacy', '{}', 'legacy-session', ?1)",
- params![chrono::Utc::now().to_rfc3339()],
- )
- .expect("insert legacy row");
- drop(legacy_conn);
-
- assert_eq!(
- approval_store::list_pending(&legacy_config)
- .expect("migrated pending")
- .len(),
- 1
- );
- approval_store::decide(&legacy_config, "legacy", ApprovalDecision::ApproveOnce)
- .expect("decide legacy");
- assert!(approval_store::record_execution(
- &legacy_config,
- "legacy",
- ExecutionOutcome::Success,
- None,
- )
- .expect("record execution after migration"));
-}
-
-#[test]
-fn approval_reply_parser_accepts_explicit_yes_no_only() {
- for decision in [
- ApprovalDecision::ApproveOnce,
- ApprovalDecision::ApproveAlwaysForTool,
- ApprovalDecision::Deny,
- ] {
- assert_eq!(
- ApprovalDecision::from_str(decision.as_str()),
- Some(decision)
- );
- }
- assert_eq!(ApprovalDecision::from_str("maybe"), None);
- assert!(ApprovalDecision::ApproveOnce.is_approve());
- assert!(ApprovalDecision::ApproveAlwaysForTool.is_approve());
- assert!(!ApprovalDecision::Deny.is_approve());
-
- for outcome in [
- ExecutionOutcome::Success,
- ExecutionOutcome::Failure,
- ExecutionOutcome::Aborted,
- ] {
- assert_eq!(ExecutionOutcome::from_str(outcome.as_str()), Some(outcome));
- }
- assert_eq!(ExecutionOutcome::from_str("partial"), None);
- assert_eq!(
- serde_json::to_string(&ExecutionOutcome::Aborted).expect("serialize outcome"),
- "\"aborted\""
- );
-
- assert_eq!(
- parse_approval_reply(" yes "),
- Some(ApprovalDecision::ApproveOnce)
- );
- assert_eq!(
- parse_approval_reply("APPROVED"),
- Some(ApprovalDecision::ApproveOnce)
- );
- assert_eq!(parse_approval_reply("n"), Some(ApprovalDecision::Deny));
- assert_eq!(parse_approval_reply("denied"), Some(ApprovalDecision::Deny));
- assert_eq!(parse_approval_reply("maybe later"), None);
-}
-
#[tokio::test]
async fn approval_schema_handlers_validate_params_and_surface_empty_gate_state() {
let schemas = all_approval_controller_schemas();