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

Function TestHMACSign

hmac_test.go:67–82  ·  hmac_test.go::TestHMACSign
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestHMACSign(t *testing.T) {
68 for _, data := range hmacTestData {
69 if !data.valid {
70 continue
71 }
72 parts := strings.Split(data.tokenString, ".")
73 method := jwt.GetSigningMethod(data.alg)
74 sig, err := method.Sign(strings.Join(parts[0:2], "."), hmacTestKey)
75 if err != nil {
76 t.Errorf("[%v] Error signing token: %v", data.name, err)
77 }
78 if !reflect.DeepEqual(sig, decodeSegment(t, parts[2])) {
79 t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", data.name, sig, parts[2])
80 }
81 }
82}
83
84func BenchmarkHS256Signing(b *testing.B) {
85 benchmarkSigning(b, jwt.SigningMethodHS256, hmacTestKey)

Callers

nothing calls this directly

Calls 2

decodeSegmentFunction · 0.85
SignMethod · 0.65

Tested by

no test coverage detected