2bbf42b741
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package services
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/dto/request"
|
|
)
|
|
|
|
func TestValidateMCPToolRiskPolicyRejectsTrustedToolOverride(t *testing.T) {
|
|
_, err := validateMCPToolRiskPolicy(request.AIAgentMCPToolRequest{
|
|
ToolCode: "system/server_time",
|
|
RiskLevel: "write",
|
|
RequireConfirmation: true,
|
|
})
|
|
if err == nil {
|
|
t.Fatal("expected trusted system tool policy override to be rejected")
|
|
}
|
|
|
|
item, err := validateMCPToolRiskPolicy(request.AIAgentMCPToolRequest{
|
|
ToolCode: "system/server_time",
|
|
RiskLevel: "read",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("validate trusted system tool policy: %v", err)
|
|
}
|
|
if item.Title != "获取当前时间" || item.RiskLevel != "read" || item.RequireConfirmation {
|
|
t.Fatalf("unexpected normalized trusted policy: %#v", item)
|
|
}
|
|
}
|
|
|
|
func TestValidateMCPToolRiskPolicyRequiresWriteConfirmation(t *testing.T) {
|
|
_, err := validateMCPToolRiskPolicy(request.AIAgentMCPToolRequest{
|
|
ToolCode: "crm/update_customer",
|
|
RiskLevel: "write",
|
|
})
|
|
if err == nil {
|
|
t.Fatal("expected write tool without confirmation to be rejected")
|
|
}
|
|
}
|