Add CONTENT_MANAGER RBAC defaults, migration, and Super Admin-only team email invitations; restrict assignable team_member roles without changing platform user roles. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestTeamRole_IsBuiltinTeamRole(t *testing.T) {
|
|
if !TeamRoleAdmin.IsBuiltinTeamRole() {
|
|
t.Fatal("ADMIN should be builtin")
|
|
}
|
|
if TeamRole("CONTENT_MANAGER_NEW").IsBuiltinTeamRole() {
|
|
t.Fatal("custom role should not be builtin")
|
|
}
|
|
}
|
|
|
|
func TestTeamRole_RBACRoleForJWT(t *testing.T) {
|
|
if got := TeamRoleContentManager.RBACRoleForJWT(); got != RoleContentManager {
|
|
t.Fatalf("CONTENT_MANAGER JWT role = %q, want CONTENT_MANAGER", got)
|
|
}
|
|
if got := TeamRole("CONTENT_MANAGER_NEW").RBACRoleForJWT(); got != Role("CONTENT_MANAGER_NEW") {
|
|
t.Fatalf("custom JWT role = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestIsForbiddenTeamMemberRole(t *testing.T) {
|
|
if !IsForbiddenTeamMemberRole("STUDENT") {
|
|
t.Fatal("STUDENT should be forbidden for team members")
|
|
}
|
|
if IsForbiddenTeamMemberRole("CONTENT_MANAGER_NEW") {
|
|
t.Fatal("custom staff role should be allowed")
|
|
}
|
|
}
|
|
|
|
func TestCanonicalTeamRoleKey(t *testing.T) {
|
|
cases := map[string]string{
|
|
"Super Admin": "SUPER_ADMIN",
|
|
"super-admin": "SUPER_ADMIN",
|
|
"SUPER_ADMIN": "SUPER_ADMIN",
|
|
" admin ": "ADMIN",
|
|
"Content Manager New": "CONTENT_MANAGER_NEW",
|
|
}
|
|
for in, want := range cases {
|
|
if got := CanonicalTeamRoleKey(in); got != want {
|
|
t.Fatalf("CanonicalTeamRoleKey(%q) = %q, want %q", in, got, want)
|
|
}
|
|
}
|
|
}
|