Skip to content

Commit ff433d6

Browse files
committed
Add test with Env vars for Jasypt handler
1 parent 0bd8fa2 commit ff433d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

utils/jasypt/src/test/java/io/smallrye/config/jasypt/JasyptSecretKeysHandlerTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.smallrye.config.jasypt;
22

3+
import static io.smallrye.config.EnvConfigSource.ORDINAL;
34
import static org.junit.jupiter.api.Assertions.*;
45

56
import java.util.Map;
67

78
import org.junit.jupiter.api.Test;
89

10+
import io.smallrye.config.EnvConfigSource;
911
import io.smallrye.config.PropertiesConfigSource;
1012
import io.smallrye.config.SmallRyeConfig;
1113
import io.smallrye.config.SmallRyeConfigBuilder;
@@ -27,6 +29,22 @@ void jasypt() {
2729
assertEquals("12345678", config.getRawValue("my.secret"));
2830
}
2931

32+
@Test
33+
void jasyptWithEnv() {
34+
SmallRyeConfig config = new SmallRyeConfigBuilder()
35+
.addDefaultInterceptors()
36+
.addDiscoveredSecretKeysHandlers()
37+
.withSources(new EnvConfigSource(Map.of(
38+
"SMALLRYE_CONFIG_SECRET_HANDLER_JASYPT_PASSWORD", "jasypt",
39+
"SMALLRYE_CONFIG_SECRET_HANDLER_JASYPT_ALGORITHM", "PBEWithHMACSHA512AndAES_256"), ORDINAL))
40+
.withSources(new PropertiesConfigSource(
41+
Map.of("my.secret", "${jasypt::ENC(wqp8zDeiCQ5JaFvwDtoAcr2WMLdlD0rjwvo8Rh0thG5qyTQVGxwJjBIiW26y0dtU)}"),
42+
"", 0))
43+
.build();
44+
45+
assertEquals("12345678", config.getRawValue("my.secret"));
46+
}
47+
3048
@Test
3149
void expression() {
3250
Map<String, String> properties = Map.of(

0 commit comments

Comments
 (0)