generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added app level encryption feature. (#599)
* Added app level encryption feature. * Add validation of config parameters. * test * better name * naming * nil encrypter for kek * docs. * integration fix
- Loading branch information
1 parent
31ea6fd
commit f836a81
Showing
25 changed files
with
764 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
package config | ||
|
||
import ( | ||
"embed" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
config, err := LoadConfig(Filename) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, config) | ||
//go:embed testdata | ||
var testdata embed.FS | ||
|
||
assert.False(t, config.Server.ReadTimeout.String() == "") | ||
assert.False(t, config.Server.WriteTimeout.String() == "") | ||
assert.False(t, config.Server.ShutdownTimeout.String() == "") | ||
assert.False(t, config.Server.APIHost == "") | ||
func TestLoadConfig(t *testing.T) { | ||
t.Run("returns no errors when passed in file", func(t *testing.T) { | ||
config, err := LoadConfig(Filename, nil) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, config) | ||
|
||
assert.NotEmpty(t, config.Services.StorageProvider) | ||
assert.False(t, config.Server.ReadTimeout.String() == "") | ||
assert.False(t, config.Server.WriteTimeout.String() == "") | ||
assert.False(t, config.Server.ShutdownTimeout.String() == "") | ||
assert.False(t, config.Server.APIHost == "") | ||
|
||
assert.NotEmpty(t, config.Services.StorageProvider) | ||
}) | ||
|
||
t.Run("returns errors when prod disables encryption", func(t *testing.T) { | ||
_, err := LoadConfig("testdata/test1.toml", testdata) | ||
assert.Error(t, err) | ||
assert.ErrorContains(t, err, "prod environment cannot disable key encryption") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[server] | ||
env = "prod" # either 'dev', 'test', or 'prod' | ||
|
||
[services.keystore] | ||
name = "keystore" | ||
disable_encryption = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.