test(tools): verify normalization prevents self-delegation bypass
Add table-driven test with case and whitespace variants (ALPHA, " Alpha ", " alpha ") that should all be caught by the self-check after normalization. Ref: #2148
This commit is contained in:
parent
df486b9939
commit
6db17b8211
1 changed files with 20 additions and 0 deletions
|
|
@ -272,6 +272,26 @@ func TestDelegateTool_Execute_SelfDelegation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDelegateTool_Execute_SelfDelegation_Normalized(t *testing.T) {
|
||||||
|
tool := NewDelegateTool()
|
||||||
|
tool.SetSpawner(&delegateMockSpawner{})
|
||||||
|
tool.SetSelfAgentID("alpha") // stored normalized
|
||||||
|
|
||||||
|
// Case-insensitive and whitespace variants should still be caught
|
||||||
|
variants := []string{"ALPHA", " Alpha ", " alpha "}
|
||||||
|
for _, v := range variants {
|
||||||
|
t.Run(v, func(t *testing.T) {
|
||||||
|
result := tool.Execute(context.Background(), map[string]any{
|
||||||
|
"agent_id": v,
|
||||||
|
"task": "test",
|
||||||
|
})
|
||||||
|
if !result.IsError {
|
||||||
|
t.Errorf("agent_id=%q should be caught as self-delegation", v)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// nilResultSpawner always returns (nil, nil).
|
// nilResultSpawner always returns (nil, nil).
|
||||||
type nilResultSpawner struct{}
|
type nilResultSpawner struct{}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue