Skip to content

Commit

Permalink
spring cloud update Greenwich.SR3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulises Bocchio authored and Ulises Bocchio committed Nov 25, 2019
1 parent 4303c3c commit 4517a13
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
5 changes: 5 additions & 0 deletions jasypt-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@
<artifactId>system-rules</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.cloud.bootstrap.BootstrapApplicationListener;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
Expand Down Expand Up @@ -40,13 +40,11 @@ public void issue_notDecryptedDuringBoostrapPhase() {
startWith(new BaseBootstrappingTestListener() {

@Override
public void onApplicationEvent(final ApplicationEnvironmentPreparedEvent event) {
assertFalse("ENC() value is not decrypted during bootstrap phase",
event.getEnvironment().getProperty("spring.cloud.config.server.svn.password").equals("mypassword"));
public void onApplicationEvent(final ApplicationStartedEvent event) {
assertEquals("ENC() value is not decrypted during bootstrap phase", "mypassword", event.getApplicationContext().getEnvironment().getProperty("spring.cloud.config.server.svn.password"));
}
}, "--spring.cloud.bootstrap.enabled=true", "--jasypt.encryptor.bootstrap=false");

// to get codacy to pass.
assertNotNull(this.context.getBean(EnableEncryptablePropertiesBeanFactoryPostProcessor.class));
}

Expand All @@ -57,26 +55,36 @@ public void fix_decryptedDuringBoostrapPhase() {
startWith(new BaseBootstrappingTestListener() {

@Override
public void onApplicationEvent(final ApplicationEnvironmentPreparedEvent event) {
assertTrue("ENC() value is decrypted during bootstrap phase",
event.getEnvironment().getProperty("spring.cloud.config.server.svn.password").equals("mypassword"));
public void onApplicationEvent(final ApplicationStartedEvent event) {
assertEquals("ENC() value is decrypted during bootstrap phase", "mypassword", event.getApplicationContext().getEnvironment().getProperty("spring.cloud.config.server.svn.password"));
}
}, "--spring.cloud.bootstrap.enabled=true", "--jasypt.encryptor.bootstrap=true");

// to get codacy to pass.
assertNotNull(this.context.getBean(EnableEncryptablePropertiesBeanFactoryPostProcessor.class));
}

@Test
public void encryptableBFPPBeanCreatedWhenBoostrapTrue() {
startWith(null, "--spring.cloud.bootstrap.enabled=true");
startWith(new BaseBootstrappingTestListener() {

@Override
public void onApplicationEvent(final ApplicationStartedEvent event) {
assertEquals("ENC() value is decrypted during bootstrap phase", "mypassword", event.getApplicationContext().getEnvironment().getProperty("spring.cloud.config.server.svn.password"));
}
}, "--spring.cloud.bootstrap.enabled=true");
assertNotNull("EnableEncryptablePropertiesBeanFactoryPostProcessor not created when spring.cloud.bootstrap.enabled=true",
this.context.getBean(EnableEncryptablePropertiesBeanFactoryPostProcessor.class));
}

@Test
public void encryptableBFPPBeanCreatedWhenBoostrapFalse() {
startWith(null, "--spring.cloud.bootstrap.enabled=false");
startWith(new BaseBootstrappingTestListener() {

@Override
public void onApplicationEvent(final ApplicationStartedEvent event) {
assertNotEquals("ENC() value is decrypted during bootstrap phase", "mypassword", event.getApplicationContext().getEnvironment().getProperty("spring.cloud.config.server.svn.password"));
}
}, "--spring.cloud.bootstrap.enabled=false");
assertNotNull("EnableEncryptablePropertiesBeanFactoryPostProcessor not created when spring.cloud.bootstrap.enabled=false",
this.context.getBean(EnableEncryptablePropertiesBeanFactoryPostProcessor.class));
}
Expand Down Expand Up @@ -107,7 +115,7 @@ static class BootstrapConfig {
}

static abstract class BaseBootstrappingTestListener
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
implements ApplicationListener<ApplicationStartedEvent>, Ordered {

@Override
public int getOrder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String resolvePropertyValue(String value) {
String resolvedProperty = environment.resolveRequiredPlaceholders(unwrappedProperty);
return encryptor.decrypt(resolvedProperty);
} catch (EncryptionOperationNotPossibleException e) {
throw new DecryptionException("Decryption of Properties failed, make sure encryption/decryption " +
throw new DecryptionException("Unable to decrypt: " + value + ". Decryption of Properties failed, make sure encryption/decryption " +
"passwords match", e);
}
})
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring.boot.version>2.2.1.RELEASE</spring.boot.version>
<spring.cloud.version>Finchley.RELEASE</spring.cloud.version>
<spring.cloud.version>Greenwich.SR3</spring.cloud.version>
<jasypt.version>1.9.3</jasypt.version>
<maven.compiler.version>3.7.0</maven.compiler.version>
<system.rules.version>1.19.0</system.rules.version>
Expand Down

0 comments on commit 4517a13

Please sign in to comment.