MCPcopy Index your code
hub / github.com/docker/docker-agent / TestExecutePreToolUseWithJSONOutput

Function TestExecutePreToolUseWithJSONOutput

pkg/hooks/hooks_test.go:432–458  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

430}
431
432func TestExecutePreToolUseWithJSONOutput(t *testing.T) {
433 t.Parallel()
434
435 jsonOutput := `{"decision":"block","reason":"Tool not allowed"}`
436 config := &Config{
437 PreToolUse: []MatcherConfig{
438 {
439 Matcher: "*",
440 Hooks: []Hook{
441 {Type: HookTypeCommand, Command: "echo '" + jsonOutput + "'", Timeout: 5},
442 },
443 },
444 },
445 }
446
447 exec := NewExecutor(config, t.TempDir(), nil)
448 input := &Input{
449 SessionID: "test-session",
450 ToolName: "shell",
451 ToolUseID: "test-id",
452 }
453
454 result, err := exec.Dispatch(t.Context(), EventPreToolUse, input)
455 require.NoError(t, err)
456 assert.False(t, result.Allowed)
457 assert.Contains(t, result.Message, "Tool not allowed")
458}
459
460func TestExecutePostToolUse(t *testing.T) {
461 t.Parallel()

Callers

nothing calls this directly

Calls 3

DispatchMethod · 0.95
NewExecutorFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected