MCPcopy
hub / github.com/golang-jwt/jwt / TestHMACVerify

Function TestHMACVerify

hmac_test.go:52–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50var hmacTestKey, _ = os.ReadFile("test/hmacTestKey")
51
52func TestHMACVerify(t *testing.T) {
53 for _, data := range hmacTestData {
54 parts := strings.Split(data.tokenString, ".")
55
56 method := jwt.GetSigningMethod(data.alg)
57 err := method.Verify(strings.Join(parts[0:2], "."), decodeSegment(t, parts[2]), hmacTestKey)
58 if data.valid && err != nil {
59 t.Errorf("[%v] Error while verifying key: %v", data.name, err)
60 }
61 if !data.valid && err == nil {
62 t.Errorf("[%v] Invalid key passed validation", data.name)
63 }
64 }
65}
66
67func TestHMACSign(t *testing.T) {
68 for _, data := range hmacTestData {

Callers

nothing calls this directly

Calls 2

decodeSegmentFunction · 0.85
VerifyMethod · 0.65

Tested by

no test coverage detected