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

Function test_agent_permission_allow

core/src/agent/tests.rs:487–521  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

485
486#[tokio::test]
487async fn test_agent_permission_allow() {
488 let mock_client = Arc::new(MockLlmClient::new(vec![
489 // First response: tool call that will be allowed
490 MockLlmClient::tool_call_response(
491 "tool-1",
492 "bash",
493 serde_json::json!({"command": "echo hello"}),
494 ),
495 // Second response: final text
496 MockLlmClient::text_response("Done!"),
497 ]));
498
499 let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string()));
500
501 // Create permission policy that allows echo commands
502 let permission_policy = PermissionPolicy::new()
503 .allow("bash(echo:*)")
504 .deny("bash(rm:*)");
505
506 let config = AgentConfig {
507 permission_checker: Some(Arc::new(permission_policy)),
508 ..Default::default()
509 };
510
511 let agent = AgentLoop::new(
512 mock_client.clone(),
513 tool_executor,
514 test_tool_context(),
515 config,
516 );
517 let result = agent.execute(&[], "Echo hello", None).await.unwrap();
518
519 assert_eq!(result.text, "Done!");
520 assert_eq!(result.tool_calls_count, 1);
521}
522
523#[tokio::test]
524async fn test_agent_streaming_events() {

Callers

nothing calls this directly

Calls 5

denyMethod · 0.80
allowMethod · 0.80
test_tool_contextFunction · 0.70
cloneMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected