...
1 package services
2
3 import (
4 "context"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8
9 "edge-infra.dev/pkg/edge/api/graph/model"
10 )
11
12
13 func TestIsSystemAdminTrue(t *testing.T) {
14 roles := []string{string(model.RoleEdgeOrgAdmin), "role1", "role2"}
15 if !bslRoleService.IsOrgAdmin(roles) {
16 t.Fatalf(`system role = %v is system admin %v, False want match for True`, string(model.RoleEdgeOrgAdmin), roles)
17 }
18 }
19
20 func TestIsSystemAdminFalse(t *testing.T) {
21 roles := []string{"role1", "role2", "role3"}
22 if bslRoleService.IsOrgAdmin(roles) {
23 t.Fatalf(`system role = %v is not system admin %v, True want match for False`, string(model.RoleEdgeOrgAdmin), roles)
24 }
25 }
26
27
28 func TestIsOrganizationAdminTrue(t *testing.T) {
29 roles := []string{string(model.RoleEdgeBannerAdmin), "role1", "role2"}
30 if !bslRoleService.IsBannerAdmin(roles) {
31 t.Fatalf(`org role = %v is org admin %v, False want match for True`, string(model.RoleEdgeBannerAdmin), roles)
32 }
33 }
34
35 func TestIsOrganizationAdminFalse(t *testing.T) {
36 roles := []string{"role1", "role2", "role3"}
37 if bslRoleService.IsBannerAdmin(roles) {
38 t.Fatalf(`org role = %v is not org admin %v, True want match for False`, string(model.RoleEdgeBannerAdmin), roles)
39 }
40 }
41
42 func TestRecoverPassword(t *testing.T) {
43 err := bslRoleService.RecoverPassword(context.Background(), bslUsername, testOrg)
44 assert.Nil(t, err)
45 }
46
View as plain text