()
| 996 | |
| 997 | #[tokio::test] |
| 998 | async fn test_timeout_auto_approve() { |
| 999 | let (event_tx, mut event_rx) = broadcast::channel(100); |
| 1000 | let policy = ConfirmationPolicy { |
| 1001 | enabled: true, |
| 1002 | default_timeout_ms: 50, // Very short timeout for testing |
| 1003 | timeout_action: TimeoutAction::AutoApprove, |
| 1004 | ..Default::default() |
| 1005 | }; |
| 1006 | let manager = ConfirmationManager::new(policy, event_tx); |
| 1007 | |
| 1008 | // Request confirmation |
| 1009 | let rx = manager |
| 1010 | .request_confirmation("tool-1", "bash", &serde_json::json!({})) |
| 1011 | .await; |
| 1012 | |
| 1013 | // Skip ConfirmationRequired event |
| 1014 | let _ = event_rx.recv().await.unwrap(); |
| 1015 | |
| 1016 | // Wait for timeout |
| 1017 | tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; |
| 1018 | |
| 1019 | // Check timeouts |
| 1020 | let timed_out = manager.check_timeouts().await; |
| 1021 | assert_eq!(timed_out, 1); |
| 1022 | |
| 1023 | // Check timeout event |
| 1024 | let event = event_rx.recv().await.unwrap(); |
| 1025 | match event { |
| 1026 | AgentEvent::ConfirmationTimeout { |
| 1027 | tool_id, |
| 1028 | action_taken, |
| 1029 | } => { |
| 1030 | assert_eq!(tool_id, "tool-1"); |
| 1031 | assert_eq!(action_taken, "auto_approved"); |
| 1032 | } |
| 1033 | _ => panic!("Expected ConfirmationTimeout event"), |
| 1034 | } |
| 1035 | |
| 1036 | // Check response indicates timeout auto-approval |
| 1037 | let response = rx.await.unwrap(); |
| 1038 | assert!(response.approved); |
| 1039 | assert!(response.reason.as_ref().unwrap().contains("auto_approved")); |
| 1040 | } |
| 1041 | |
| 1042 | #[tokio::test] |
| 1043 | async fn test_no_timeout_when_confirmed() { |
nothing calls this directly
no test coverage detected