Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump spring-cloud-dependencies from 2021.0.4 to 2022.0.0 #548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<properties>
<java.version>19</java.version>
<maven.compiler.target>19</maven.compiler.target>
<spring.cloud-version>2021.0.4</spring.cloud-version>
<spring.cloud-version>2022.0.0</spring.cloud-version>
<lombok.version>1.18.24</lombok.version>
<aws.sdk.version>2.19.6</aws.sdk.version>
<asciidoctorj.version>2.5.7</asciidoctorj.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.owasp.wrongsecrets;

import org.apache.hc.client5.http.HttpHostConnectException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

// Tests worked with Spring Boot 2.7.5 with random port configuration
// Not working after migration to Spring Boot 3.0
Expand All @@ -31,9 +32,14 @@ void shouldRedirectWhenProtoProvided() {
.defaultHeader("x-forwarded-proto", "value")
.build();
var rootAddress = "http://localhost:" + port + "/heroku";//note we loosely ask for "heroku" to be part of the url
var result = restTemplate.getForEntity(rootAddress, String.class);
assertEquals(HttpStatus.FOUND, result.getStatusCode());
assertEquals("https", result.getHeaders().getLocation().getScheme());

//in Spring security 2022 we no longer can bind to the new port of the redirect as that is not preset. hence this exception proves the redirect
Exception exception = assertThrows(ResourceAccessException.class, () -> {
restTemplate.getForEntity(rootAddress, String.class);
});

assertEquals(exception.getCause().getClass(), HttpHostConnectException.class);
assertEquals(exception.getCause().getMessage(), "Connect to https://localhost:8443 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused");
}

@Test
Expand Down