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

refactor(sdk): remove deprecated EncryptWithAES code #1235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 1 addition & 18 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 @@ -378,21 +377,6 @@ func (app *Configurable) Encrypt(parameters map[string]string) interfaces.AppFun
}

switch strings.ToLower(algorithm) {
case EncryptAES:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to remove the EncryptAES constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the constant, and all its references.

initVector, ok := parameters[InitVector]
if !ok {
app.lc.Error("Could not find " + InitVector)
return nil
}

//nolint: staticcheck
transform := transforms.Encryption{
EncryptionKey: encryptionKey,
InitializationVector: initVector,
SecretPath: secretPath,
SecretName: secretName,
}
return transform.EncryptWithAES
case EncryptAES256:
if len(secretPath) > 0 && len(secretName) > 0 {
protector := transforms.AESProtection{
Expand All @@ -405,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
4 changes: 4 additions & 0 deletions pkg/transforms/aesprotection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
"testing"
)

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

func TestNewAESProtection(t *testing.T) {
secretPath := uuid.NewString()
secretName := uuid.NewString()
Expand Down
147 changes: 0 additions & 147 deletions pkg/transforms/encryption.go

This file was deleted.

131 changes: 0 additions & 131 deletions pkg/transforms/encryption_test.go

This file was deleted.