Skip to content

Commit

Permalink
fix: resolve all comments made in PR
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-Philippe Fuller <marc-philippe.fuller@intel.com>
  • Loading branch information
marcpfuller committed Jan 4, 2023
1 parent 05dff3e commit b07c832
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
4 changes: 1 addition & 3 deletions internal/app/configurable.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const (
Algorithm = "algorithm"
CompressGZIP = "gzip"
CompressZLIB = "zlib"
EncryptAES = "aes"
EncryptAES256 = "aes256"
Mode = "mode"
BatchByCount = "bycount"
Expand Down Expand Up @@ -390,9 +389,8 @@ func (app *Configurable) Encrypt(parameters map[string]string) interfaces.AppFun
return nil
default:
app.lc.Errorf(
"Invalid encryption algorithm '%s'. Must be one of '%s', '%s",
"Invalid encryption algorithm '%s'. Must be '%s",
algorithm,
EncryptAES,
EncryptAES256)
return nil
}
Expand Down
34 changes: 7 additions & 27 deletions internal/app/configurable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,29 +374,15 @@ func TestAddTags(t *testing.T) {
func TestEncrypt(t *testing.T) {
configurable := Configurable{lc: lc}

key := "xyz12345"
vector := "1243565"
secretsPath := "/aes"
secretName := "myKey"

tests := []struct {
Name string
Algorithm string
EncryptionKey string
InitVector string
SecretPath string
SecretName string
ExpectNil bool
Name string
Algorithm string
SecretPath string
SecretName string
ExpectNil bool
}{
{"Good - Key & vector ", EncryptAES, key, vector, "", "", false},
{"Good - Secrets & vector", "aEs", "", vector, secretsPath, secretName, false},
{"Bad - No algorithm ", "", key, "", "", "", true},
{"Bad - No vector ", EncryptAES, key, "", "", "", true},
{"Bad - No Key or secrets ", EncryptAES, "", vector, "", "", true},
{"Bad - Missing secretPath", EncryptAES, "", vector, "", secretName, true},
{"Bad - Missing secretName", EncryptAES, "", vector, secretsPath, "", true},
{"AES256 - Bad - No secrets ", EncryptAES256, "", "", "", "", true},
{"AES256 - good - secrets", EncryptAES256, "", "", uuid.NewString(), uuid.NewString(), false},
{"AES256 - Bad - No secrets ", EncryptAES256, "", "", true},
{"AES256 - good - secrets", EncryptAES256, uuid.NewString(), uuid.NewString(), false},
}

for _, testCase := range tests {
Expand All @@ -405,12 +391,6 @@ func TestEncrypt(t *testing.T) {
if len(testCase.Algorithm) > 0 {
params[Algorithm] = testCase.Algorithm
}
if len(testCase.EncryptionKey) > 0 {
params[EncryptionKey] = testCase.EncryptionKey
}
if len(testCase.InitVector) > 0 {
params[InitVector] = testCase.InitVector
}
if len(testCase.SecretPath) > 0 {
params[SecretPath] = testCase.SecretPath
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/transforms/aesprotection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"testing"
)

const(
const (
plainString = "This is the test string used for testing"
)

Expand Down

0 comments on commit b07c832

Please sign in to comment.