Skip to content

Commit

Permalink
chore(deps): update tomcat to 9.0.82 (run 10.0.15); spring boot 3.1.5 (
Browse files Browse the repository at this point in the history
…#3888)

* adjust CORS tests in run to test cross-origin requests

#3724
  • Loading branch information
yanavasileva authored Oct 24, 2023
1 parent bd8dabf commit ee9aa5a
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class CorsConfigAllowCredentialsTest extends AbstractRestTest {
@Test
public void shouldRespondWithSupportedCredentials() {
// given
// same origin
String origin = "http://localhost:" + localPort;
String origin = "http://other.origin:8081";

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
Expand All @@ -46,8 +45,7 @@ public class CorsConfigAllowedHeadersTest extends AbstractRestTest {
@Test
public void shouldContainPreflightWithAllowedHeaders() {
// given
// same origin
String origin = "http://localhost:" + localPort;
String origin = "http://other.origin";

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.camunda.bpm.run.property.CamundaBpmRunCorsProperty;
import org.camunda.bpm.run.test.AbstractRestTest;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -35,30 +36,13 @@
* Note: To run this test via an IDE you must set the system property
* {@code sun.net.http.allowRestrictedHeaders} to {@code true}.
* (e.g. System.setProperty("sun.net.http.allowRestrictedHeaders", "true");)
*
*
* @see https://jira.camunda.com/browse/CAM-11290
*/
@ActiveProfiles(profiles = { "test-cors-enabled" }, inheritProfiles = true)
@TestPropertySource(properties = {CamundaBpmRunCorsProperty.PREFIX + ".allowed-origins=http://other.origin:8081"})
public class CorsConfigurationEnabledAllowedOriginConfiguredTest extends AbstractRestTest {

@Test
public void shouldPassSameOriginRequest() {
// given
// same origin
String origin = "http://localhost:" + localPort;

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);

// when
ResponseEntity<List> response = testRestTemplate.exchange(CONTEXT_PATH + "/task", HttpMethod.GET, new HttpEntity<>(headers), List.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().getAccessControlAllowOrigin()).contains(origin);
}

@Test
public void shouldFailCrossOriginRequestFromNotAllowedOrigin() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,12 @@
* Note: To run this test via an IDE you must set the system property
* {@code sun.net.http.allowRestrictedHeaders} to {@code true}.
* (e.g. System.setProperty("sun.net.http.allowRestrictedHeaders", "true");)
*
*
* @see https://jira.camunda.com/browse/CAM-11290
*/
@ActiveProfiles(profiles = { "test-cors-enabled" }, inheritProfiles = true)
public class CorsConfigurationEnabledWildcardTest extends AbstractRestTest {

@Test
public void shouldPassSameOriginRequest() {
// given
// same origin
String origin = "http://localhost:" + localPort;

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);

// when
ResponseEntity<List> response = testRestTemplate.exchange(CONTEXT_PATH + "/task", HttpMethod.GET, new HttpEntity<>(headers), List.class);

// then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().getAccessControlAllowOrigin()).contains("*");
}

@Test
public void shouldPassCrossOriginRequest() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class CorsConfigurationExposedHeadersTest extends AbstractRestTest {
@Test
public void shouldProvideResponseWithExposedHeaders() {
// given
// same origin
String origin = "http://localhost:" + localPort;
String origin = "http://other.origin";

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class CorsConfigurationPreflightMaxAgeTest extends AbstractRestTest {
@Test
public void shouldUseACustomPreflightAge() {
// given
// same origin
String origin = "http://localhost:" + localPort;
String origin = "http://other.origin";

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class CorsWithChangedContextPathTest extends AbstractRestTest {
@Test
public void shouldCheckCorsAvailabilityOnPathChange() {
// given
// same origin
String origin = "http://localhost:" + localPort;
String origin = "http://other.origin:8081";

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ORIGIN, origin);
Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<version.quarkus>3.2.6.Final</version.quarkus>
<version.spring.framework>5.3.27</version.spring.framework>
<version.spring.framework6>6.0.9</version.spring.framework6>
<version.spring-boot>3.1.4</version.spring-boot>
<version.spring-boot>3.1.5</version.spring-boot>
<version.resteasy>3.15.6.Final</version.resteasy>
<version.jersey2>2.34</version.jersey2>
<!-- use minimum version of resteasy and jersey -->
Expand Down Expand Up @@ -58,7 +58,7 @@
<version.wildfly26>26.0.1.Final</version.wildfly26>
<version.wildfly26.core>18.0.4.Final</version.wildfly26.core>

<version.tomcat>9.0.80</version.tomcat>
<version.tomcat>9.0.82</version.tomcat>

<version.arquillian>1.1.10.Final</version.arquillian>
<version.shrinkwrap.resolvers>2.2.2</version.shrinkwrap.resolvers>
Expand Down

0 comments on commit ee9aa5a

Please sign in to comment.