package apitokens

import "testing"

func TestDrivePathWithinScope(t *testing.T) {
	auth := &AuthContext{
		DriveScope: DriveScope{
			AllFolders:  false,
			FolderPaths: []string{"/Projects"},
		},
	}
	if !AllowsDrivePath(auth, "/Projects/docs/report.pdf") {
		t.Fatal("expected nested path within /Projects")
	}
	if AllowsDrivePath(auth, "/Personal/notes.txt") {
		t.Fatal("did not expect /Personal to be allowed")
	}
}

func TestAllowsMailAccountScoped(t *testing.T) {
	auth := &AuthContext{
		MailScope: MailScope{
			AllAccounts: false,
			AccountIDs:  []string{"acc-1"},
		},
	}
	if !AllowsMailAccount(auth, "acc-1") {
		t.Fatal("expected acc-1")
	}
	if AllowsMailAccount(auth, "acc-2") {
		t.Fatal("did not expect acc-2")
	}
}
