added utils test
This commit is contained in:
parent
7463fd83b8
commit
41c5a8a7c8
20
keycloakclaims/utils_test.go
Normal file
20
keycloakclaims/utils_test.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user