MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_confirmation_flow_reject

Function test_confirmation_flow_reject

core/src/hitl.rs:762–804  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 2

request_confirmationMethod · 0.45
confirmMethod · 0.45

Tested by

no test coverage detected