Fix logging conditions. Refactor tests.

This commit is contained in:
Olga Maciaszek-Sharma
2022-05-18 13:20:54 +02:00
parent ead2d9c453
commit 595e00b849
2 changed files with 16 additions and 4 deletions

View File

@@ -109,7 +109,9 @@ public class EncryptionController {
Map<String, String> keys = helper.getEncryptorKeys(name, profiles, input);
String textToEncrypt = helper.stripPrefix(input);
String encrypted = helper.addPrefix(keys, encryptorLocator.locate(keys).encrypt(textToEncrypt));
logger.info("Encrypted data");
if (logger.isInfoEnabled()) {
logger.info("Encrypted data");
}
return encrypted;
}
@@ -128,21 +130,31 @@ public class EncryptionController {
encryptor = getEncryptor(name, profiles, data);
String input = stripFormData(helper.stripPrefix(data), type, true);
String decrypted = encryptor.decrypt(input);
logger.info("Decrypted cipher data");
if (logger.isInfoEnabled()) {
logger.info("Decrypted cipher data");
}
return decrypted;
}
catch (IllegalArgumentException | IllegalStateException e) {
logger.error("Cannot decrypt key:" + name + ", value:" + data, e);
if (logger.isErrorEnabled()) {
logger.error("Cannot decrypt key:" + name + ", value:" + data, e);
}
throw new InvalidCipherException();
}
}
private TextEncryptor getEncryptor(String name, String profiles, String data) {
if (encryptorLocator == null) {
if (logger.isDebugEnabled()) {
logger.debug("Text encryptorLocator is null.");
}
throw new KeyNotInstalledException();
}
TextEncryptor encryptor = encryptorLocator.locate(helper.getEncryptorKeys(name, profiles, data));
if (encryptor == null) {
if (logger.isDebugEnabled()) {
logger.debug("TextEncryptor is null.");
}
throw new KeyNotInstalledException();
}
return encryptor;

View File

@@ -77,7 +77,7 @@ public class BootstrapConfigServerIntegrationTests {
@Test
@Ignore // FIXME: configdata
public void environmentBootstraps() throws Exception {
public void environmentBootstraps() {
assertThat(this.env.getProperty("info.foo", "")).isEqualTo("bar");
assertThat(this.env.getProperty("config.foo", "")).isEqualTo("foo");
}