The current situation is quite confusing. We use the defaults for the underlying library (usually follow redirects), unless you use HttpComponents. At that point we stop following redirects unless you create the TestRestTemplate with HttpClientOption.ENABLE_REDIRECTS.

Comment From: thecooldrop

Hello @philwebb if you would be available to explain what you mean by second sentence in a bit more detail I would like to start working on this issue.

Comment From: philwebb

Thanks for the offer @thecooldrop, but I think this one might be better handled by the team. We need to do some design work before and have some additional discussion before come up with the direction we want to take.

Comment From: bananer

Seems like the documentation also needs to be updated: https://docs.spring.io/spring-boot/reference/testing/test-utilities.html#testing.utilities.test-rest-template

If you do use Apache’s HTTP client, some additional test-friendly features are enabled: - Redirects are not followed (so you can assert the response location). - Cookies are ignored (so the template is stateless).

Comment From: wilkinsona

Thanks, @bananer. I've opened https://github.com/spring-projects/spring-boot/issues/45842.

Comment From: israelrios

The javadoc in TestRestTemplate needs to be updated too:

A TestRestTemplate can optionally carry Basic authentication headers. If Apache Http Client 4.3.2 or better is available (recommended) it will be used as the client, and by default configured to ignore cookies and redirects.