From 51b7e1393024f0d1b182c01eaecd878e07c8e229 Mon Sep 17 00:00:00 2001
From: zachmann <gabriel.zachmann@kit.edu>
Date: Fri, 21 Jan 2022 10:38:03 +0100
Subject: [PATCH] fix code smells

---
 .../db/dbrepo/mytokenrepo/transfercoderepo/transfercode.go     | 3 ++-
 internal/utils/hashUtils/hashUtils_test.go                     | 3 ++-
 shared/mytoken/restrictions/restriction.go                     | 3 ++-
 shared/mytoken/restrictions/restriction_test.go                | 3 ++-
 shared/mytoken/rotation/rotation.go                            | 3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/internal/db/dbrepo/mytokenrepo/transfercoderepo/transfercode.go b/internal/db/dbrepo/mytokenrepo/transfercoderepo/transfercode.go
index fc145471..cc8e93a8 100644
--- a/internal/db/dbrepo/mytokenrepo/transfercoderepo/transfercode.go
+++ b/internal/db/dbrepo/mytokenrepo/transfercoderepo/transfercode.go
@@ -79,7 +79,8 @@ func (tc TransferCode) Store(rlog log.Ext1FieldLogger, tx *sqlx.Tx) error {
 	)
 }
 
-// GetRevokeJWT returns a bool indicating if the linked jwt should also be revoked when this TransferCode is revoked or not
+// GetRevokeJWT returns a bool indicating if the linked jwt should also be revoked when this TransferCode is revoked or
+// not
 func (tc TransferCode) GetRevokeJWT(rlog log.Ext1FieldLogger, tx *sqlx.Tx) (bool, error) {
 	var revokeMT db.BitBool
 	err := db.RunWithinTransaction(
diff --git a/internal/utils/hashUtils/hashUtils_test.go b/internal/utils/hashUtils/hashUtils_test.go
index f1f2194c..a7bf7376 100644
--- a/internal/utils/hashUtils/hashUtils_test.go
+++ b/internal/utils/hashUtils/hashUtils_test.go
@@ -36,7 +36,8 @@ func TestSHA3_512Str(t *testing.T) {
 func TestHMACBasedHash(t *testing.T) {
 	data := `{"nbf":1599939600,"exp":1599948600,"ip":["192.168.0.31"],"usages_AT":11}`
 	hash := HMACBasedHash([]byte(data))
-	expected := "eyJuYmYiOjE1OTk5Mzk2MDAsImV4cCI6MTU5OTk0ODYwMCwiaXAiOlsiMTkyLjE2OC4wLjMxIl0sInVzYWdlc19BVCI6MTF9L3Lomh4pL9+cwcig05q2/MSuKFRsr6CMVw2iUcQjRAhdOt8qGVwg1R08eICUg8sKiwNDpXr92k1iWIMDcvuA/Q=="
+	expected := "eyJuYmYiOjE1OTk5Mzk2MDAsImV4cCI6MTU5OTk0ODYwMCwiaXAiOlsiMTkyLjE2OC4wLjMxIl0sInVzYWdlc19BVCI6MTF9L3" +
+		"Lomh4pL9+cwcig05q2/MSuKFRsr6CMVw2iUcQjRAhdOt8qGVwg1R08eICUg8sKiwNDpXr92k1iWIMDcvuA/Q=="
 	if hash != expected {
 		t.Errorf(hashFailFmt, hash, expected)
 	}
diff --git a/shared/mytoken/restrictions/restriction.go b/shared/mytoken/restrictions/restriction.go
index d7188c03..b0a6a3d1 100644
--- a/shared/mytoken/restrictions/restriction.go
+++ b/shared/mytoken/restrictions/restriction.go
@@ -402,7 +402,8 @@ func (r *Restrictions) GetAudiences() (auds []string) {
 }
 
 // SetMaxScopes sets the maximum scopes, i.e. all scopes are stripped from the restrictions if not included in the
-// passed argument. This is used to eliminate requested scopes that are dropped by the provider. Don't use it to eliminate scopes that are not enabled for the oidc client, because it also could be a custom scope.
+// passed argument. This is used to eliminate requested scopes that are dropped by the provider. Don't use it to
+// eliminate scopes that are not enabled for the oidc client, because it also could be a custom scope.
 func (r *Restrictions) SetMaxScopes(mScopes []string) {
 	for _, rr := range *r {
 		rScopes := utils.SplitIgnoreEmpty(rr.Scope, " ")
diff --git a/shared/mytoken/restrictions/restriction_test.go b/shared/mytoken/restrictions/restriction_test.go
index ec86b471..cfcc3cb0 100644
--- a/shared/mytoken/restrictions/restriction_test.go
+++ b/shared/mytoken/restrictions/restriction_test.go
@@ -299,7 +299,8 @@ func tightenCase8() tightenTestCase {
 		wanted: Restrictions{
 			{
 				Restriction: api.Restriction{
-					Scope: "a b c d", // This is semantically different from base, because it allows a token with all the scopes combined. One might want to not allow this.
+					Scope: "a b c d", // This is semantically different from base,
+					// because it allows a token with all the scopes combined. One might want to not allow this.
 				},
 				ExpiresAt: 50,
 			},
diff --git a/shared/mytoken/rotation/rotation.go b/shared/mytoken/rotation/rotation.go
index 7fbb1193..8153e5de 100644
--- a/shared/mytoken/rotation/rotation.go
+++ b/shared/mytoken/rotation/rotation.go
@@ -57,7 +57,8 @@ func RotateMytokenAfterAT(
 	return rotateMytoken(rlog, tx, oldJWT, old, clientMetaData)
 }
 
-// RotateMytokenAfterOther rotates a mytoken after it was used for other usages than AT if rotation is enabled for that case
+// RotateMytokenAfterOther rotates a mytoken after it was used for other usages than AT if rotation is enabled for that
+// case
 func RotateMytokenAfterOther(
 	rlog log.Ext1FieldLogger, tx *sqlx.Tx, oldJWT string, old *mytoken.Mytoken, clientMetaData api.ClientMetaData,
 ) (*mytoken.Mytoken, bool, error) {
-- 
GitLab