Reformat code: add whitespaces, remove empty lines (#319)

This commit is contained in:
Oleksandr Redko 2023-06-21 13:39:55 +03:00 committed by GitHub
parent 33d62b4dae
commit b2b650971a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 16 deletions

View File

@ -1,11 +1,10 @@
package jwt package jwt
import ( import (
"errors"
"crypto" "crypto"
"crypto/ed25519" "crypto/ed25519"
"crypto/rand" "crypto/rand"
"errors"
) )
var ( var (

View File

@ -114,7 +114,6 @@ func Example_getTokenViaHTTP() {
} }
func Example_useTokenViaHTTP() { func Example_useTokenViaHTTP() {
// Make a sample token // Make a sample token
// In a real world situation, this token will have been acquired from // In a real world situation, this token will have been acquired from
// some other API call (see Example_getTokenViaHTTP) // some other API call (see Example_getTokenViaHTTP)

View File

@ -42,7 +42,6 @@ func init() {
// Load private keys // Load private keys
jwtTestRSAPrivateKey = test.LoadRSAPrivateKeyFromDisk("test/sample_key") jwtTestRSAPrivateKey = test.LoadRSAPrivateKeyFromDisk("test/sample_key")
jwtTestEC256PrivateKey = test.LoadECPrivateKeyFromDisk("test/ec256-private.pem") jwtTestEC256PrivateKey = test.LoadECPrivateKeyFromDisk("test/ec256-private.pem")
} }
var jwtTestData = []struct { var jwtTestData = []struct {
@ -352,11 +351,9 @@ func signToken(claims jwt.Claims, signingMethod jwt.SigningMethod) string {
} }
func TestParser_Parse(t *testing.T) { func TestParser_Parse(t *testing.T) {
// Iterate over test data set and run tests // Iterate over test data set and run tests
for _, data := range jwtTestData { for _, data := range jwtTestData {
t.Run(data.name, func(t *testing.T) { t.Run(data.name, func(t *testing.T) {
// If the token string is blank, use helper function to generate string // If the token string is blank, use helper function to generate string
if data.tokenString == "" { if data.tokenString == "" {
data.tokenString = signToken(data.claims, data.signingMethod) data.tokenString = signToken(data.claims, data.signingMethod)
@ -428,7 +425,6 @@ func TestParser_Parse(t *testing.T) {
} }
func TestParser_ParseUnverified(t *testing.T) { func TestParser_ParseUnverified(t *testing.T) {
// Iterate over test data set and run tests // Iterate over test data set and run tests
for _, data := range jwtTestData { for _, data := range jwtTestData {
// Skip test data, that intentionally contains malformed tokens, as they would lead to an error // Skip test data, that intentionally contains malformed tokens, as they would lead to an error
@ -670,13 +666,11 @@ func TestSetPadding(t *testing.T) {
err, err,
) )
} }
}) })
} }
} }
func BenchmarkParseUnverified(b *testing.B) { func BenchmarkParseUnverified(b *testing.B) {
// Iterate over test data set and run tests // Iterate over test data set and run tests
for _, data := range jwtTestData { for _, data := range jwtTestData {
// If the token string is blank, use helper function to generate string // If the token string is blank, use helper function to generate string

View File

@ -41,7 +41,6 @@ func TestSingleArrayMarshal(t *testing.T) {
expected := `"test"` expected := `"test"`
b, err := json.Marshal(s) b, err := json.Marshal(s)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %s", err) t.Errorf("Unexpected error: %s", err)
} }