31 lines
871 B
Go
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")
|
|
}
|
|
}
|