diff --git a/jwt_test.go b/jwt_test.go index 583b19b..9108ded 100644 --- a/jwt_test.go +++ b/jwt_test.go @@ -178,7 +178,9 @@ func benchmarkSigning(b *testing.B, method jwt.SigningMethod, key interface{}) { t := jwt.New(method) b.RunParallel(func(pb *testing.PB) { for pb.Next() { - t.SignedString(key) + if _, err := t.SignedString(key); err != nil { + b.Fatal(err) + } } }) diff --git a/rsa_test.go b/rsa_test.go index 7479910..13ba1fc 100644 --- a/rsa_test.go +++ b/rsa_test.go @@ -144,13 +144,31 @@ func TestRSAKeyParsing(t *testing.T) { } func BenchmarkRS256Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodRS256, hmacTestKey) + key, _ := ioutil.ReadFile("test/sample_key") + parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) + if err != nil { + b.Fatal(err) + } + + benchmarkSigning(b, jwt.SigningMethodRS256, parsedKey) } func BenchmarkRS384Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodRS384, hmacTestKey) + key, _ := ioutil.ReadFile("test/sample_key") + parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) + if err != nil { + b.Fatal(err) + } + + benchmarkSigning(b, jwt.SigningMethodRS384, parsedKey) } func BenchmarkRS512Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodRS512, hmacTestKey) + key, _ := ioutil.ReadFile("test/sample_key") + parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) + if err != nil { + b.Fatal(err) + } + + benchmarkSigning(b, jwt.SigningMethodRS512, parsedKey) }