mirror of
https://github.com/warmbly/warmbly.git
synced 2026-10-05 16:02:10 +00:00
27 lines
944 B
Go
27 lines
944 B
Go
package handler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/warmbly/warmbly/internal/app/aitools"
|
|
"github.com/warmbly/warmbly/internal/models"
|
|
)
|
|
|
|
func TestMCPNeedsAIAgent(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
inv aitools.Invocation
|
|
want bool
|
|
}{
|
|
{"key without AI_AGENT", aitools.Invocation{IsAPIKey: true, APIPerms: models.APIPermReadContacts}, false},
|
|
{"key with AI_AGENT", aitools.Invocation{IsAPIKey: true, APIPerms: models.APIPermAIAgent}, true},
|
|
{"oauth member without use_ai", aitools.Invocation{IsAPIKey: true, ActsForMember: true, APIPerms: models.APIPermAIAgent, OrgPerms: models.PermViewContacts}, false},
|
|
{"oauth member with use_ai", aitools.Invocation{IsAPIKey: true, ActsForMember: true, APIPerms: models.APIPermAIAgent, OrgPerms: models.PermUseAI}, true},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := mcpAllowed(tc.inv); got != tc.want {
|
|
t.Errorf("%s: mcpAllowed = %v, want %v", tc.name, got, tc.want)
|
|
}
|
|
}
|
|
}
|