Fix property source for decrypted variables
Use SystemEnvironmentPropertySource so that env vars can be
encrypted as well as property values (i.e. FOO_BAR will bind to
@Value("foo.bar")).
Fixes gh-89, fixes gh-87
This commit is contained in:
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class EnvironmentDecryptApplicationListenerTests {
|
||||
public class EnvironmentDecryptApplicationInitializerTests {
|
||||
|
||||
private EnvironmentDecryptApplicationInitializer listener = new EnvironmentDecryptApplicationInitializer(
|
||||
Encryptors.noOpText());
|
||||
@@ -43,6 +43,14 @@ public class EnvironmentDecryptApplicationListenerTests {
|
||||
assertEquals("bar", context.getEnvironment().getProperty("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relaxedBinding() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(context, "FOO_TEXT: {cipher}bar");
|
||||
this.listener.initialize(context);
|
||||
assertEquals("bar", context.getEnvironment().getProperty("foo.text"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertySourcesOrderedCorrectly() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
Reference in New Issue
Block a user