Files
geo/server/internal/shared/auth/permissions_test.go
T

36 lines
968 B
Go
Raw Normal View History

package auth
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPermissionsForRole_Admin(t *testing.T) {
perms := PermissionsForRole("tenant_admin")
assert.Contains(t, perms, "brand:write")
assert.Contains(t, perms, "brand:delete")
assert.Contains(t, perms, "member:write")
}
func TestPermissionsForRole_Editor(t *testing.T) {
perms := PermissionsForRole("editor")
assert.Contains(t, perms, "article:write")
assert.Contains(t, perms, "template:generate")
assert.NotContains(t, perms, "brand:delete")
assert.NotContains(t, perms, "member:write")
}
func TestPermissionsForRole_Viewer(t *testing.T) {
perms := PermissionsForRole("viewer")
assert.Contains(t, perms, "brand:read")
assert.Contains(t, perms, "article:read")
assert.NotContains(t, perms, "brand:write")
assert.NotContains(t, perms, "article:write")
}
func TestPermissionsForRole_Unknown(t *testing.T) {
perms := PermissionsForRole("nonexistent")
assert.Nil(t, perms)
}