RezinaLMS-BackEnd/internal/domain/team_roles_test.go
Yared Yemane dbdea622d4 feat: allow custom RBAC roles for team member invites
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-03 04:52:45 -07:00

31 lines
871 B
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 != RoleAdmin {
t.Fatalf("CONTENT_MANAGER JWT role = %q, want ADMIN", 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")
}
}