Skip to content

Commit 6aa2d1a

Browse files
committed
chore: fix spelling and grammar mistakes, remove dead code
1 parent 80cf2e6 commit 6aa2d1a

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

authorization/storage_authorization.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (s *Store) transformToken(a *influxdb.Authorization) error {
106106
// code that triggered commit needs access to the raw Token, such as when a
107107
// token is initially created so it can be shown to the user.
108108
// Note that even if a.HashedToken is set, we will regenerate it here. This ensures
109-
// that a.HashedToken will be stored using the currently configured hashing algoirithm.
109+
// that a.HashedToken will be stored using the currently configured hashing algorithm.
110110
if hashedToken, err := s.hasher.Hash(a.Token); err != nil {
111111
return fmt.Errorf("error hashing token: %w", err)
112112
} else {

authorization/storage_authorization_test.go

+2-37
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ func TestAuthorizationStore_HashingConfigChanges(t *testing.T) {
427427
},
428428

429429
// The following tests are artificial tests intended to check proper operation when both
430-
// Token and HashedToken is set on an update. This should not occur in normal operation because,
431-
// we do not alter tokens like this. However, this is nothing to prevent this so we want to make sure
430+
// Token and HashedToken are set on an update. This should not occur in normal operation because,
431+
// we do not alter tokens like this. However, there is nothing to prevent this so we want to make sure
432432
// it works properly.
433433
{
434434
desc: "set Token and HashedToken with hashing enabled",
@@ -485,41 +485,6 @@ func TestAuthorizationStore_HashingConfigChanges(t *testing.T) {
485485
},
486486
hashedTokens: []string{},
487487
},
488-
/*
489-
{
490-
desc: "set Token and HashedToken with hashing re-enabled",
491-
config: testConfig{enabled: true, algo: influxdb2_algo.VariantIdentifierSHA256},
492-
action: func(t *testing.T, ctx context.Context, store *authorization.Store, tx kv.Tx) {
493-
for i := 1; i <= 3; i++ {
494-
token := fmt.Sprintf("Token#%d", i)
495-
auth, err := store.GetAuthorizationByToken(ctx, tx, token)
496-
require.NoError(t, err)
497-
require.Equal(t, auth.Token, token)
498-
require.Empty(t, auth.HashedToken, "only Token should be set from the last test case")
499-
500-
// Set Token and update.
501-
tokenDigest, err := sha256.Hash(token)
502-
require.NoError(t, err)
503-
hashedToken := tokenDigest.Encode()
504-
auth.HashedToken = hashedToken
505-
newAuth, err := store.UpdateAuthorization(ctx, tx, platform.ID(i), auth)
506-
require.NoError(t, err)
507-
508-
// Both newAuth.Token and newAuth.HashedToken should still be set, but only
509-
// HashedToken should be stored and indexed.
510-
require.Equal(t, token, newAuth.Token)
511-
require.Equal(t, hashedToken, newAuth.HashedToken)
512-
}
513-
},
514-
// NOTE: All hashes should be updated to the currently configured algorithm.
515-
exp: []authData{
516-
{ID: platform.ID(1), HashedToken: sha256.MustHash("Token#1").Encode()},
517-
{ID: platform.ID(2), HashedToken: sha256.MustHash("Token#2").Encode()},
518-
{ID: platform.ID(3), HashedToken: sha256.MustHash("Token#3").Encode()},
519-
},
520-
hashedTokens: []string{"Token#1", "Token#2", "Token#3"},
521-
},
522-
*/
523488
}
524489

525490
ctx := context.Background()

0 commit comments

Comments
 (0)