Skip to content
Merged
21 changes: 17 additions & 4 deletions spring/fluentforms-jersey-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.7</version>
<version>4.0.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com._4point.aem.fluentforms</groupId>
Expand All @@ -20,7 +20,8 @@

<!-- Testing Dependencies -->
<fp.hamcrest.matchers.version>0.0.4-SNAPSHOT</fp.hamcrest.matchers.version>
<wiremock.version>4.0.0-beta.16</wiremock.version>
<wiremock.version>4.0.0-beta.22</wiremock.version>
<wiremock-spring-boot.version>4.0.8</wiremock-spring-boot.version>
<pitest.maven.plugin.version>1.20.2</pitest.maven.plugin.version>
<pitest.junit5.maven.plugin.version>1.2.3</pitest.junit5.maven.plugin.version>
</properties>
Expand Down Expand Up @@ -94,7 +95,7 @@
<!-- Testing Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<artifactId>spring-boot-starter-jersey-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -105,10 +106,22 @@
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-junit5</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock.integrations</groupId>
<artifactId>wiremock-spring-boot</artifactId>
<version>${wiremock-spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jersey.autoconfigure.ResourceConfigCustomizer;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.system.JavaVersion;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ public Response proxyPost(@PathParam("remainder") String remainder, @HeaderParam
.log("Returning POST response from target '{}'.");
}

return Response.fromResponse(result).build();
return Response.fromResponse(result)
.header("Transfer-Encoding", null) // Remove the Transfer-Encoding header
.build();
}

private InputStream debugInput(InputStream in, String target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jersey.autoconfigure.ResourceConfigCustomizer;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = {com._4point.aem.fluentforms.spring.FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class, AemProxyAutoConfiguration.class},
@SpringBootTest(classes = {com._4point.aem.fluentforms.spring.FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
properties = {
"fluentforms.aem.servername=localhost",
"fluentforms.aem.port=4502",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.web.client.RestClient;
import org.wiremock.spring.ConfigureWireMock;
import org.wiremock.spring.EnableWireMock;

import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
import com.github.tomakehurst.wiremock.junit5.WireMockTest;

@WireMockTest(httpPort = AemProxyJerseyEndpointTest.WIREMOCK_PORT)
@WireMockTest()
@SpringBootTest(classes = {com._4point.aem.fluentforms.spring.AemProxyJerseyEndpointTest.TestApplication.class},
webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {
"fluentforms.aem.servername=localhost",
"fluentforms.aem.port=" + AemProxyJerseyEndpointTest.WIREMOCK_PORT,
"fluentforms.aem.user=ENC(7FgD3ZsSExfUGRYlXNc++6C1upPBURNKq6HouzagnNZW4FsBwFs5+crawv+djhw6)",
"fluentforms.aem.password=ENC(QmQ6iTm/+TOO8U3dDuBzJWH129vReWgYNdgqQwWhjWaQy6j8sMnk2/Auhehmlh3v)",
//"fluentforms.aem.useSsl=true",
Expand All @@ -41,13 +42,18 @@
"jasypt.encryptor.password=4Point",
"jasypt.encryptor.iv-generator-classname=org.jasypt.iv.RandomIvGenerator",
"jasypt.encryptor.salt-generator-classname=org.jasypt.salt.RandomSaltGenerator",
"logging.level.com._4point.aem.fluentforms.spring.AemProxyEndpoint=DEBUG"
"logging.level.com._4point.aem.fluentforms.spring.AemProxyEndpoint=DEBUG",
// Wiremock produces a lot of output, the following entries reduce that output. They can be removed for debugging.
"logging.level.org.wiremock.spring=WARN", "logging.level.WireMock.wiremock=WARN",
})
@Timeout(value = 5, unit = TimeUnit.MINUTES) // Fail tests that take longer than this to prevent hanging.
@EnableWireMock(@ConfigureWireMock(
portProperties = "fluentforms.aem.port"
)
)
@Timeout(value = 30, unit = TimeUnit.SECONDS) // Fail tests that take longer than this to prevent hanging.
class AemProxyJerseyEndpointTest {
private final static Logger logger = LoggerFactory.getLogger(AemProxyJerseyEndpointTest.class);

static final int WIREMOCK_PORT = 5504;
static final String AF_BASE_LOCATION = "/aem";

// The following is a string that contains all possible values that may be modified by the AemProxyEndpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com._4point.aem.fluentforms.api.generatePDF.GeneratePDFService;
import com._4point.aem.fluentforms.api.output.OutputService;
import com._4point.aem.fluentforms.api.pdfUtility.PdfUtilityService;
import com._4point.aem.fluentforms.spring.rest_services.client.SpringRestClientRestClient;

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class},
properties = {
Expand Down Expand Up @@ -158,40 +157,42 @@ private static String inputStreamToString(InputStream inputStream) throws IOExce
return result;
}

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
properties = {
"fluentforms.aem.servername=localhost",
"fluentforms.aem.port=4502",
"fluentforms.aem.user=admin",
"fluentforms.aem.password=admin",
"fluentforms.restclient=springrestclient" // Configure for Spring RestClient
})
public static class SpringRestClientTest {

@Test
void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
}
}
// TODO: For now we are going to ignore mixed scenarios (where we are using one starter with a different rest client
// @SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
// properties = {
// "fluentforms.aem.servername=localhost",
// "fluentforms.aem.port=4502",
// "fluentforms.aem.user=admin",
// "fluentforms.aem.password=admin",
// "fluentforms.restclient=springrestclient" // Configure for Spring RestClient
// })
// public static class SpringRestClientTest {
//
// @Test
// void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
// RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
// assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
// }
// }

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
properties = {
"fluentforms.aem.servername=localhost",
"fluentforms.aem.port=4502",
"fluentforms.aem.user=admin",
"fluentforms.aem.password=admin",
"fluentforms.aem.usessl=true",
"fluentforms.restclient=springrestclient" // Configure for Spring RestClient
})
public static class SpringRestClient_SslNoBundleNameTest {

@Test
void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
}
}
// TODO: For now we are going to ignore mixed scenarios (where we are using one starter with a different rest client
// @SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
// properties = {
// "fluentforms.aem.servername=localhost",
// "fluentforms.aem.port=4502",
// "fluentforms.aem.user=admin",
// "fluentforms.aem.password=admin",
// "fluentforms.aem.usessl=true",
// "fluentforms.restclient=springrestclient" // Configure for Spring RestClient
// })
// public static class SpringRestClient_SslNoBundleNameTest {
//
// @Test
// void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
// RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
// assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
// }
// }

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class},
properties = {
Expand All @@ -212,26 +213,27 @@ void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemC
}
}

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
properties = {
"fluentforms.aem.servername=localhost",
"fluentforms.aem.port=4502",
"fluentforms.aem.user=admin",
"fluentforms.aem.password=admin",
"fluentforms.aem.usessl=true",
"spring.ssl.bundle.jks.aem.truststore.location=file:src/test/resources/aemforms.p12",
"spring.ssl.bundle.jks.aem.truststore.password=Pa$$123",
"spring.ssl.bundle.jks.aem.truststore.type=PKCS12",
"fluentforms.restclient=springrestclient" // Configure for Spring RestClient
})
public static class SpringRestClient_SslBundleTest {

@Test
void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
}
}
// TODO: For now we are going to ignore mixed scenarios (where we are using one starter with a different rest client
// @SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
// properties = {
// "fluentforms.aem.servername=localhost",
// "fluentforms.aem.port=4502",
// "fluentforms.aem.user=admin",
// "fluentforms.aem.password=admin",
// "fluentforms.aem.usessl=true",
// "spring.ssl.bundle.jks.aem.truststore.location=file:src/test/resources/aemforms.p12",
// "spring.ssl.bundle.jks.aem.truststore.password=Pa$$123",
// "spring.ssl.bundle.jks.aem.truststore.type=PKCS12",
// "fluentforms.restclient=springrestclient" // Configure for Spring RestClient
// })
// public static class SpringRestClient_SslBundleTest {
//
// @Test
// void testRestClientFactory(@Autowired RestClientFactory factory, @Autowired AemConfiguration config) {
// RestClient client = factory.apply(toAemConfig(config) , "testRestClientFactory", ()->"correlationId");
// assertTrue(client instanceof SpringRestClientRestClient, "RestClientFactory should return a SpringRestClientRestClient when configured to do so");
// }
// }

@SpringBootTest(classes = {FluentFormsJerseyAutoConfigurationTest.TestApplication.class, FluentFormsAutoConfiguration.class},
properties = {
Expand Down
Loading
Loading