Skip to content

Commit 0efabfd

Browse files
committed
Remove unused test code and mock cleanup
Removing unused test and mock code simplifies maintenance and reduces clutter.
1 parent e654a65 commit 0efabfd

File tree

4 files changed

+4
-94
lines changed

4 files changed

+4
-94
lines changed

coderd/cryptokeys/dbkeycache_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func TestDBKeyCache(t *testing.T) {
6969
_, err = k.VerifyingKey(ctx, "123")
7070
require.ErrorIs(t, err, cryptokeys.ErrKeyNotFound)
7171
})
72-
7372
})
7473

7574
t.Run("Signing", func(t *testing.T) {
@@ -173,7 +172,6 @@ func TestDBKeyCache(t *testing.T) {
173172
_, err := cryptokeys.NewEncryptionCache(logger, db, database.CryptoKeyFeatureOidcConvert, cryptokeys.WithDBCacheClock(clock))
174173
require.ErrorIs(t, err, cryptokeys.ErrInvalidFeature)
175174
})
176-
177175
}
178176

179177
func keyID(key database.CryptoKey) string {

coderd/cryptokeys/doc.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
// Package cryptokeys provides an abstraction for fetching internally used cryptographic keys mainly for JWT signing and verification.
22
package cryptokeys
3-
4-
//go:generate mockgen -destination keycachemock.go -package cryptokeys . Keycache

coderd/cryptokeys/keycachemock.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

coderd/jwtutils/jwt_test.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package jwtutils_test
33
import (
44
"context"
55
"crypto/rand"
6-
"encoding/hex"
76
"testing"
87
"time"
98

@@ -19,7 +18,6 @@ import (
1918
"github.com/coder/coder/v2/coderd/database/dbgen"
2019
"github.com/coder/coder/v2/coderd/database/dbtestutil"
2120
"github.com/coder/coder/v2/coderd/jwtutils"
22-
"github.com/coder/coder/v2/codersdk"
2321
"github.com/coder/coder/v2/testutil"
2422
)
2523

@@ -355,19 +353,6 @@ func TestJWE(t *testing.T) {
355353
})
356354
}
357355

358-
func generateCryptoKey(t *testing.T, seq int32, now time.Time, keySize int) codersdk.CryptoKey {
359-
t.Helper()
360-
361-
secret := generateSecret(t, keySize)
362-
363-
return codersdk.CryptoKey{
364-
Feature: codersdk.CryptoKeyFeatureTailnetResume,
365-
Secret: hex.EncodeToString(secret),
366-
Sequence: seq,
367-
StartsAt: now,
368-
}
369-
}
370-
371356
func generateSecret(t *testing.T, keySize int) []byte {
372357
t.Helper()
373358

@@ -431,22 +416,22 @@ func newKey(t *testing.T, size int) *key {
431416
}
432417
}
433418

434-
func (k *key) SigningKey(ctx context.Context) (id string, key interface{}, err error) {
419+
func (k *key) SigningKey(_ context.Context) (id string, key interface{}, err error) {
435420
return k.id, k.secret, nil
436421
}
437422

438-
func (k *key) VerifyingKey(ctx context.Context, id string) (key interface{}, err error) {
423+
func (k *key) VerifyingKey(_ context.Context, id string) (key interface{}, err error) {
439424
k.t.Helper()
440425

441426
require.Equal(k.t, k.id, id)
442427
return k.secret, nil
443428
}
444429

445-
func (k *key) EncryptingKey(ctx context.Context) (id string, key interface{}, err error) {
430+
func (k *key) EncryptingKey(_ context.Context) (id string, key interface{}, err error) {
446431
return k.id, k.secret, nil
447432
}
448433

449-
func (k *key) DecryptingKey(ctx context.Context, id string) (key interface{}, err error) {
434+
func (k *key) DecryptingKey(_ context.Context, id string) (key interface{}, err error) {
450435
k.t.Helper()
451436

452437
require.Equal(k.t, k.id, id)

0 commit comments

Comments
 (0)