Skip to content

Commit cf57dcb

Browse files
committed
testhelp: delete unused code (used only in go-kit)
1 parent 4779252 commit cf57dcb

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ require (
66
dario.cat/mergo v1.0.0
77
github.com/Pix4D/go-kit v0.2.0
88
github.com/alexflint/go-arg v1.4.3
9-
github.com/golang-jwt/jwt/v5 v5.3.0
109
github.com/sasbury/mini v0.0.0-20181226232755-dc74af49394b
1110
gotest.tools/v3 v3.5.1
1211
)
1312

1413
require (
1514
github.com/alexflint/go-scalar v1.2.0 // indirect
15+
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
1616
github.com/google/go-cmp v0.7.0 // indirect
1717
)

testhelp/testhelper.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13-
"net/http"
1413
"os"
1514
"path"
1615
"path/filepath"
@@ -19,7 +18,6 @@ import (
1918
"text/template"
2019

2120
"dario.cat/mergo"
22-
"github.com/golang-jwt/jwt/v5"
2321
"gotest.tools/v3/assert"
2422
)
2523

@@ -339,18 +337,3 @@ func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte {
339337

340338
return pem.EncodeToMemory(&privBlock)
341339
}
342-
343-
// DecodeJWT decodes the HTTP request authorization header with the given RSA key
344-
// and returns the registered claims of the decoded token.
345-
func DecodeJWT(t *testing.T, r *http.Request, key *rsa.PrivateKey) *jwt.RegisteredClaims {
346-
token := strings.Fields(r.Header.Get("Authorization"))[1]
347-
tok, err := jwt.ParseWithClaims(token, &jwt.RegisteredClaims{}, func(t *jwt.Token) (any, error) {
348-
if t.Header["alg"] != "RS256" {
349-
return nil, fmt.Errorf("unexpected signing method: %v, expected: %v", t.Header["alg"], "RS256")
350-
}
351-
return &key.PublicKey, nil
352-
})
353-
assert.NilError(t, err)
354-
355-
return tok.Claims.(*jwt.RegisteredClaims)
356-
}

0 commit comments

Comments
 (0)