Skip to content

Commit 5ae3eb5

Browse files
committed
✅ Updated test to uise SSL (and Spring SSLBundles).
1 parent f2797cf commit 5ae3eb5

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

spring/fluentforms-spring-boot-autoconfigure/src/test/java/com/_4point/aem/fluentforms/spring/AemProxyAfSubmissionTest.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.DisplayName;
2222
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.extension.RegisterExtension;
2324
import org.junit.jupiter.params.ParameterizedTest;
2425
import org.junit.jupiter.params.provider.CsvSource;
2526
import org.junit.jupiter.params.provider.EnumSource;
@@ -44,7 +45,8 @@
4445
import com._4point.aem.fluentforms.spring.AemProxyAfSubmission.AfSubmitLocalProcessor.InternalAfSubmitAemProxyProcessor;
4546
import com._4point.aem.fluentforms.spring.AemProxyAfSubmissionTest.AemProxyAfSubmissionTestWithLocalAfSubmitProcessorTest.MockAemProxy;
4647
import com.github.tomakehurst.wiremock.client.WireMock;
47-
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
48+
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
49+
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
4850

4951
import jakarta.ws.rs.client.ClientBuilder;
5052
import jakarta.ws.rs.client.Entity;
@@ -99,10 +101,6 @@ public static JakartaRestClient setUpRestClient(int port) {
99101
return getPdfForm;
100102
}
101103

102-
private static String getBaseUriString(int port) {
103-
return getBaseUri(port).toString();
104-
}
105-
106104
private static URI getBaseUri(int port) {
107105
return URI.create("http://localhost:" + port);
108106
}
@@ -121,10 +119,9 @@ public static class JerseyConfig extends ResourceConfig {
121119
}
122120

123121
/**
124-
* Tests the AemAfSubmitProcessor
122+
* Tests the AemAfSubmitProcessor. It utilizes an SSL connection to test the SslBundle code.
125123
*
126124
*/
127-
@WireMockTest(httpPort = 8502)
128125
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
129126
classes = {TestApplication.class, JerseyConfig.class, AfSubmitAemProxyProcessor.class},
130127
properties = {
@@ -133,10 +130,26 @@ public static class JerseyConfig extends ResourceConfig {
133130
"fluentforms.aem.port=" + "8502",
134131
"fluentforms.aem.user=admin",
135132
"fluentforms.aem.password=admin",
133+
"fluentforms.aem.useSsl=true",
134+
"spring.ssl.bundle.jks.aem.truststore.location=file:src/test/resources/aemforms.p12",
135+
"spring.ssl.bundle.jks.aem.truststore.password=Pa$$123",
136+
"spring.ssl.bundle.jks.aem.truststore.type=PKCS12"
136137
}
137138
)
138139
public static class AemProxyAfSubmissionTestWithAemAfSubmitProcessorTest {
139140

141+
@RegisterExtension
142+
static WireMockExtension wm1 = WireMockExtension.newInstance()
143+
.options(WireMockConfiguration.wireMockConfig().httpsPort(8502)
144+
.httpDisabled(true)
145+
.keystorePath("src/test/resources/aemforms.p12")
146+
.keyManagerPassword("Pa$$123")
147+
.keystorePassword("Pa$$123")
148+
.keystoreType("PKCS12")
149+
)
150+
.configureStaticDsl(true) // Use with Static DSL
151+
.build();
152+
140153
@LocalServerPort
141154
private int port;
142155

0 commit comments

Comments
 (0)