Adding util test class

This commit is contained in:
🐙PiperYxzzy
2022-05-01 20:55:49 +02:00
parent 6e7b30be0a
commit 67efb0600f

24
util/util_test.go Normal file
View File

@@ -0,0 +1,24 @@
package util
import (
"testing"
)
func TestParseJwt(t *testing.T) {
premadeJwt := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGFpbTEiOiJjbGFpbTEtdmFsIiwiY2xhaW0yIjoyMjJ9.n1rVLigY5Q6CNKqcGD38i27dqytY2qaWhXexq6PKyIY"
premadeHmac := []byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}
parsed, err := ParseJwt(premadeJwt, premadeHmac)
if err != nil {
t.Errorf("should not fail parsing JWT")
}
if parsed["claim1"] != "claim1-val" {
t.Errorf("did not contain expected value for claim1, %v", parsed)
}
if parsed["claim2"] != 222.0 {
t.Errorf("did not contain expected value for claim2, %v", parsed)
}
}