Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GetCryptoConfigWithDefaults, use DefaultConfigForTest #969

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
3 changes: 1 addition & 2 deletions internal/controlplane/handlers_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/auth"
"github.com/stacklok/mediator/internal/config"
mcrypto "github.com/stacklok/mediator/internal/crypto"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
Expand All @@ -41,7 +40,7 @@

seed := time.Now().UnixNano()
password := util.RandomPassword(8, seed)
cryptcfg := config.GetCryptoConfigWithDefaults()
cryptcfg := DefaultConfigForTest().Salt

Check failure on line 43 in internal/controlplane/handlers_auth_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 43 in internal/controlplane/handlers_auth_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
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 @@
s := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 78 in internal/controlplane/handlers_keys_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 78 in internal/controlplane/handlers_keys_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
}

Expand Down Expand Up @@ -168,7 +168,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 171 in internal/controlplane/handlers_keys_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 171 in internal/controlplane/handlers_keys_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
}

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 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 99 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 99 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -214,7 +214,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 217 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 217 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -257,7 +257,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 260 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 260 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -340,7 +340,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 343 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 343 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -381,7 +381,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 384 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 384 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -466,7 +466,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 469 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

undefined: DefaultConfigForTest

Check failure on line 469 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -522,7 +522,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,

Check failure on line 525 in internal/controlplane/handlers_user_test.go

View workflow job for this annotation

GitHub Actions / test / Unit testing

undefined: DefaultConfigForTest
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -608,7 +608,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -665,7 +665,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -780,7 +780,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down Expand Up @@ -829,7 +829,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -875,7 +875,7 @@
server := &Server{
store: mockStore,
cfg: &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
},
cryptoEngine: crypeng,
}
Expand Down Expand Up @@ -974,7 +974,7 @@
evt, err := events.Setup()
require.NoError(t, err, "failed to setup eventer")
server, err := NewServer(mockStore, evt, &config.Config{
Salt: config.GetCryptoConfigWithDefaults(),
Salt: DefaultConfigForTest().Salt,
Auth: config.AuthConfig{
TokenKey: generateTokenKey(t),
},
Expand Down
Loading