()
| 760 | |
| 761 | #[tokio::test] |
| 762 | async fn test_confirmation_flow_reject() { |
| 763 | let (event_tx, mut event_rx) = broadcast::channel(100); |
| 764 | let manager = ConfirmationManager::new(ConfirmationPolicy::enabled(), event_tx); |
| 765 | |
| 766 | // Request confirmation |
| 767 | let rx = manager |
| 768 | .request_confirmation( |
| 769 | "tool-1", |
| 770 | "bash", |
| 771 | &serde_json::json!({"command": "rm -rf /"}), |
| 772 | ) |
| 773 | .await; |
| 774 | |
| 775 | // Skip ConfirmationRequired event |
| 776 | let _ = event_rx.recv().await.unwrap(); |
| 777 | |
| 778 | // Reject the confirmation with reason |
| 779 | let result = manager |
| 780 | .confirm("tool-1", false, Some("Dangerous command".to_string())) |
| 781 | .await; |
| 782 | assert!(result.is_ok()); |
| 783 | assert!(result.unwrap()); |
| 784 | |
| 785 | // Check ConfirmationReceived event |
| 786 | let event = event_rx.recv().await.unwrap(); |
| 787 | match event { |
| 788 | AgentEvent::ConfirmationReceived { |
| 789 | tool_id, |
| 790 | approved, |
| 791 | reason, |
| 792 | } => { |
| 793 | assert_eq!(tool_id, "tool-1"); |
| 794 | assert!(!approved); |
| 795 | assert_eq!(reason, Some("Dangerous command".to_string())); |
| 796 | } |
| 797 | _ => panic!("Expected ConfirmationReceived event"), |
| 798 | } |
| 799 | |
| 800 | // Check response |
| 801 | let response = rx.await.unwrap(); |
| 802 | assert!(!response.approved); |
| 803 | assert_eq!(response.reason, Some("Dangerous command".to_string())); |
| 804 | } |
| 805 | |
| 806 | #[tokio::test] |
| 807 | async fn test_confirmation_not_found() { |
nothing calls this directly
no test coverage detected