Skip to content

Commit 284c78f

Browse files
committed
Fixup tests that rely on TestRestTemplate redirects
See gh-43431
1 parent 5eee67b commit 284c78f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.beans.factory.annotation.Autowired;
24+
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects;
2425
import org.springframework.boot.test.context.SpringBootTest;
2526
import org.springframework.boot.test.web.client.TestRestTemplate;
2627
import org.springframework.boot.test.web.server.LocalServerPort;
@@ -42,7 +43,8 @@ class SampleOAuth2ClientApplicationTests {
4243

4344
@Test
4445
void everythingShouldRedirectToLogin() {
45-
ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
46+
ResponseEntity<String> entity = this.restTemplate.withRedirects(Redirects.DONT_FOLLOW)
47+
.getForEntity("/", String.class);
4648
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
4749
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create("http://localhost:" + this.port + "/login"));
4850
}

0 commit comments

Comments
 (0)