From ce775d59aeb7f14bccbe9de45a7189d77cf628f6 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Thu, 30 Mar 2023 18:59:35 +0200 Subject: [PATCH] revert codacy --- management/server/jwtclaims/extractor.go | 4 ++-- management/server/jwtclaims/extractor_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/management/server/jwtclaims/extractor.go b/management/server/jwtclaims/extractor.go index 3bd518d00..9aa00a004 100644 --- a/management/server/jwtclaims/extractor.go +++ b/management/server/jwtclaims/extractor.go @@ -19,7 +19,7 @@ const ( UserIDClaim = "sub" ) -// Extract function type +// ExtractClaims Extract function type type ExtractClaims func(r *http.Request) AuthorizationClaims // ClaimsExtractor struct that holds the extract function @@ -65,7 +65,7 @@ func NewClaimsExtractor(options ...ClaimsExtractorOption) *ClaimsExtractor { ce.FromRequestContext = ce.fromRequestContext } if ce.userIDClaim == "" { - ce.userIDClaim = string(UserIDClaim) + ce.userIDClaim = UserIDClaim } return ce } diff --git a/management/server/jwtclaims/extractor_test.go b/management/server/jwtclaims/extractor_test.go index d8476e039..53f8818b1 100644 --- a/management/server/jwtclaims/extractor_test.go +++ b/management/server/jwtclaims/extractor_test.go @@ -12,16 +12,16 @@ import ( func newTestRequestWithJWT(t *testing.T, claims AuthorizationClaims, audiance string) *http.Request { claimMaps := jwt.MapClaims{} if claims.UserId != "" { - claimMaps[string(UserIDClaim)] = claims.UserId + claimMaps[UserIDClaim] = claims.UserId } if claims.AccountId != "" { - claimMaps[audiance+string(AccountIDSuffix)] = claims.AccountId + claimMaps[audiance+AccountIDSuffix] = claims.AccountId } if claims.Domain != "" { - claimMaps[audiance+string(DomainIDSuffix)] = claims.Domain + claimMaps[audiance+DomainIDSuffix] = claims.Domain } if claims.DomainCategory != "" { - claimMaps[audiance+string(DomainCategorySuffix)] = claims.DomainCategory + claimMaps[audiance+DomainCategorySuffix] = claims.DomainCategory } token := jwt.NewWithClaims(jwt.SigningMethodHS256, claimMaps) r, err := http.NewRequest(http.MethodGet, "http://localhost", nil) @@ -124,7 +124,7 @@ func TestExtractClaimsSetOptions(t *testing.T) { t.Error("audience should be empty") return } - if c.extractor.userIDClaim != string(UserIDClaim) { + if c.extractor.userIDClaim != UserIDClaim { t.Errorf("user id claim should be default, expected %s, got %s", UserIDClaim, c.extractor.userIDClaim) return }