### Question:
EncryptedStringResolver { public String resolve(final String textToDecrypt) { if (PropertyValueEncryptionUtils.isEncryptedValue(textToDecrypt)) { if (!isPasswordSet) { encryptor.setPasswordCharArray( ConfigSecretReader.readSecretFromFile().orElseGet(ConfigSecretReader::readSecretFromConsole)); isPasswordSet = true; } return PropertyValueEncryptionUtils.decrypt(textToDecrypt, encryptor); } LOGGER.warn( "Some sensitive values are being given as unencrypted plain text in config. " + "Please note this is NOT recommended for production environment."); return textToDecrypt; } EncryptedStringResolver(); String resolve(final String textToDecrypt);  }### Answer:
@Test public void testMarshall() { final String expectedValue = "password"; assertThat(resolver.resolve("password")).isEqualTo(expectedValue); assertThat(resolver.resolve(null)).isNull(); }
@Test public void testUnMarshall() { String normalPassword = "password"; assertThat(resolver.resolve("password")).isEqualTo(normalPassword); assertThat(resolver.resolve("ENC(KLa6pRQpxI8Ez3Bo6D3cI6y13YYdntu7)")).isEqualTo("password"); assertThat(resolver.resolve(null)).isNull(); }
@Test public void testUnMarshallWithUserInputSecret() { envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH); resolver = new EncryptedStringResolver(); ByteArrayInputStream in = new ByteArrayInputStream(("quorum" + System.lineSeparator() + "quorum").getBytes()); System.setIn(in); assertThat(resolver.resolve("ENC(KLa6pRQpxI8Ez3Bo6D3cI6y13YYdntu7)")).isEqualTo("password"); System.setIn(System.in); }
@Test public void testUnMarshallWrongPassword() { envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH); resolver = new EncryptedStringResolver(); ByteArrayInputStream in = new ByteArrayInputStream(("bogus" + System.lineSeparator() + "bogus").getBytes()); System.setIn(in); assertThatExceptionOfType(EncryptionOperationNotPossibleException.class) .isThrownBy(() -> resolver.resolve("ENC(KLa6pRQpxI8Ez3Bo6D3cI6y13YYdntu7)")); System.setIn(System.in); }