ultisuite-backend/internal/apitokens/chat_session_test.go
R3D347HR4Y 0466a1c169
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
wow
2026-06-11 01:22:52 +02:00

55 lines
1.3 KiB
Go

package apitokens
import "testing"
func TestChatSessionGrantsMail(t *testing.T) {
perms, _, _ := chatSessionGrants(ChatSessionInput{Preset: ChatSessionMail})
if len(perms) == 0 {
t.Fatal("expected grants")
}
found := false
for _, p := range perms {
if p.Resource == "mail.messages" && p.Read {
found = true
}
}
if !found {
t.Fatal("expected mail.messages read grant")
}
}
func TestChatSessionGrantsDocs(t *testing.T) {
perms, _, drive := chatSessionGrants(ChatSessionInput{
Preset: ChatSessionDocs,
DrivePath: "/Docs/note.ultidoc",
AllowWrite: true,
})
foundRead := false
foundWrite := false
for _, p := range perms {
if p.Resource == "drive.files" && p.Read {
foundRead = true
foundWrite = p.Write
}
}
if !foundRead || !foundWrite {
t.Fatalf("expected drive.files read+write: %+v", perms)
}
if drive.AllFolders || len(drive.FolderPaths) != 1 {
t.Fatalf("unexpected drive scope: %+v", drive)
}
}
func TestChatSessionGrantsDriveScoped(t *testing.T) {
_, _, drive := chatSessionGrants(ChatSessionInput{
Preset: ChatSessionDrive,
DrivePath: "/docs",
})
if drive.AllFolders {
t.Fatal("expected folder scope")
}
if len(drive.FolderPaths) != 1 || drive.FolderPaths[0] != "/docs" {
t.Fatalf("unexpected drive scope: %+v", drive)
}
}