Skip to content

Commit

Permalink
SET-544 minor refactor based on codacy findings
Browse files Browse the repository at this point in the history
  • Loading branch information
john-sobrepena-partior authored and krishnan-narayanan-partior committed Jul 30, 2024
1 parent 5cacb59 commit 8472c7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,12 @@ private boolean validateIfValueIsTobeDecryptedByTse(

private boolean validateIfValueNeedsToBeEncryptedByTse(
String transitSecretEngineName, String transitKeyName, String value) {
if (transitSecretEngineName != null
return transitSecretEngineName != null
&& !transitSecretEngineName.isEmpty()
&& transitKeyName != null
&& !transitKeyName.isEmpty()
&& value != null
&& !value.isEmpty()) {
return true;
}
return false;
&& !value.isEmpty();
}

String decryptValueIfTseRequired(Map<String, String> hashicorpGetSecretData, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void setSecretIfNullPointerExceptionThenHashicorpExceptionThrown() {

@Test
public void
givenTransitSecretEngineConfigurationAreAvailable_andKVDataWasEncryptedByTSE_thenKVDataAreDecryptedByTSEFirstBeforeReturningIt() {
givenTransitSecretEngineConfigurationAreAvailableAndKVDataWasEncryptedByTseThenKVDataAreDecryptedByTseFirstBeforeReturningIt() {
String encryptedKeyValue = "vault:v1:encrypted value";
String decryptedKeyValue = "decrypted data";

Expand Down Expand Up @@ -270,7 +270,7 @@ public void setSecretIfNullPointerExceptionThenHashicorpExceptionThrown() {

@Test
public void
givenKVDataWasEncryptedByTSE_butTransitSecretEngineConfigurationAreMissing_thenShouldThrowHashicorpVaultException() {
givenKVDataWasEncryptedByTseButTransitSecretEngineConfigurationAreMissingThenShouldThrowHashicorpVaultException() {
String encryptedKeyValue = "vault:v1:encrypted value";
String decryptedKeyValue = "decrypted data";

Expand Down Expand Up @@ -325,7 +325,7 @@ public void setSecretIfNullPointerExceptionThenHashicorpExceptionThrown() {

@Test
public void
givenTransitSecretEngineConfigurationAreAvailable_thenPrivateAndPublicKeyShouldBeTSEEncryptedBeforeStoredInKV() {
givenTransitSecretEngineConfigurationAreAvailableThenPrivateAndPublicKeyShouldBeTseEncryptedBeforeStoredInKV() {
String plainTextPublicKey = "plain text public key";
String plainTextPrivateKey = "plain text private key";
String encryptedPublicKey = "encrypted public key";
Expand Down Expand Up @@ -397,7 +397,7 @@ public void setSecretIfNullPointerExceptionThenHashicorpExceptionThrown() {

@Test
public void
givenTransitSecretEngineConfigurationAreMissing_thenPrivateAndPublicKeyShouldBeStoredInKVWithoutTSEEncyption() {
givenTransitSecretEngineConfigurationAreMissingThenPrivateAndPublicKeyShouldBeStoredInKvWithoutTseEncyption() {
String plainTextPublicKey = "plain text public key";
String plainTextPrivateKey = "plain text private key";
String encryptedPublicKey = "encrypted public key";
Expand Down

0 comments on commit 8472c7f

Please sign in to comment.