ginoidc/keycloakclaims/utils_test.go
2022-11-03 15:59:48 +01:00

21 lines
479 B
Go

package keycloakclaims
import "testing"
func TestHasAnyRole(t *testing.T) {
query := []string{"user", "editor"}
rolesOK := &Claims{}
rolesOK.RealmAccess.Roles = []string{"user", "editor", "admin"}
rolesNOTOK := &Claims{}
rolesNOTOK.RealmAccess.Roles = []string{"admin"}
if !HasAnyRole(query, rolesOK) {
t.Log("error: role not found, expected: found")
t.Fail()
}
if HasAnyRole(query, rolesNOTOK) {
t.Log("error: role found, expected: not found")
t.Fail()
}
}