Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Remove unused variable from CreateRSAToken
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Apr 17, 2023
1 parent 1112f6c commit b3d17f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func CreateRSAkeys(keyPath string, keyName string) error {
}

// CreateRSAToken creates an RSA token
func CreateRSAToken(privateKey *rsa.PrivateKey, headerAlg, headerType string, tokenClaims map[string]interface{}) (string, error) {
func CreateRSAToken(privateKey *rsa.PrivateKey, headerAlg string, tokenClaims map[string]interface{}) (string, error) {
var tok jwt.Token
tok, err := jwt.NewBuilder().Issuer(fmt.Sprintf("%v", tokenClaims["iss"])).Build()
if err != nil {
Expand All @@ -197,7 +197,7 @@ func CreateRSAToken(privateKey *rsa.PrivateKey, headerAlg, headerType string, to
}
}

serialized, err := jwt.Sign(tok, jwt.WithKey(jwa.RS256, privateKey))
serialized, err := jwt.Sign(tok, jwt.WithKey(jwa.SignatureAlgorithm(headerAlg), privateKey))
if err != nil {
return "no-token", err
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func (suite *TestSuite) TestGetUserFromToken() {
}

// Functional token
token, err := CreateRSAToken(suite.PrivateKey, "RS256", "JWT", CorrectToken)
token, err := CreateRSAToken(suite.PrivateKey, "RS256", CorrectToken)
if err != nil {
log.Fatalf("error in createToken: %v", err)
}
Expand All @@ -275,7 +275,7 @@ func (suite *TestSuite) TestGetUserFromToken() {
assert.Equal(suite.T(), "", user)

// Token without issuer
token, err = CreateRSAToken(suite.PrivateKey, "RS256", "JWT", NoIssuer)
token, err = CreateRSAToken(suite.PrivateKey, "RS256", NoIssuer)
if err != nil {
log.Fatalf("error: %v", err)
}
Expand Down

0 comments on commit b3d17f4

Please sign in to comment.