Skip to content

Commit

Permalink
Merge pull request #969 from evankanderson/cleanup-function-name
Browse files Browse the repository at this point in the history
Remove GetCryptoConfigWithDefaults, use DefaultConfigForTest
  • Loading branch information
evankanderson authored Sep 15, 2023
2 parents 172f54d + 588d853 commit 0d82d74
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
6 changes: 0 additions & 6 deletions internal/config/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ type CryptoConfig struct {
SaltLength uint32 `mapstructure:"salt_length" default:"16"`
KeyLength uint32 `mapstructure:"key_length" default:"32"`
}

// GetCryptoConfigWithDefaults returns a CryptoConfig with default values
// TODO: extract from struct default tags
func GetCryptoConfigWithDefaults() CryptoConfig {
return DefaultConfigForTest().Salt
}
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestLogin_gRPC(t *testing.T) {

seed := time.Now().UnixNano()
password := util.RandomPassword(8, seed)
cryptcfg := config.GetCryptoConfigWithDefaults()
cryptcfg := config.DefaultConfigForTest().Salt
hash, err := mcrypto.GeneratePasswordHash(password, &cryptcfg)
if err != nil {
t.Fatalf("Error generating password hash: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/controlplane/handlers_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestKeysHandler(t *testing.T) {
s := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
}

Expand Down Expand Up @@ -168,7 +168,7 @@ func TestKeysHandler_gRPC(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
}

Expand Down
26 changes: 13 additions & 13 deletions internal/controlplane/handlers_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestCreateUserDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestCreateUser_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestUpdatePasswordDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestUpdatePassword_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestUpdateProfileDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -466,7 +466,7 @@ func TestUpdateProfile_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -522,7 +522,7 @@ func TestDeleteUserDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -608,7 +608,7 @@ func TestDeleteUser_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -665,7 +665,7 @@ func TestGetUsersDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -780,7 +780,7 @@ func TestGetUsers_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -829,7 +829,7 @@ func TestGetUserDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -875,7 +875,7 @@ func TestGetNonExistingUserDBMock(t *testing.T) {
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -974,7 +974,7 @@ func TestGetUser_gRPC(t *testing.T) {
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: config.DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down

0 comments on commit 0d82d74

Please sign in to comment.