Closes GH-27360

Comment From: philwebb

Thanks @quaff. I've simplified things a bit in 8b83afdb681a9e889857dd06c4df557a27e1c042 so that we're no longer needing so many changes to TestRestTemplateBuilder. For folks that want specific redirect behavior they can pass in a configured RestTemplateBuilder and use your new redirects(...) method.

There's still some more improvements I'd like to make to TestRestTemplateBuilder in #43422, but those can wait until 3.5

Comment From: quaff

Thanks @quaff. I've simplified things a bit in 8b83afd so that we're no longer needing so many changes to TestRestTemplateBuilder. For folks that want specific redirect behavior they can pass in a configured RestTemplateBuilder and use your new redirects(...) method.

There's still some more improvements I'd like to make to TestRestTemplateBuilder in #43422, but those can wait until 3.5

@philwebb You removed TestRestTemplate::withRedirects in 8b83afd, then how to create a new TestRestTemplate base on the injected one?

Comment From: philwebb

That's a good point, I overlooked the injection. I was keen to not add more public API to TestRestTemplate, but duplicating org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer.TestRestTemplateFactory in tests will be a bit cumbersome.

I'll reopen the issue to consider things a bit more.

Comment From: philwebb

Thanks again for the feedback @quaff. I've added a withRequestFactorySettings methods that should allow you to apply settings that include alternative redirects. Let me know if that works for you.

Comment From: quaff

Thanks again for the feedback @quaff. I've added a withRequestFactorySettings methods that should allow you to apply settings that include alternative redirects. Let me know if that works for you.

Still not able to update redirects base on underlying settings, I created https://github.com/spring-projects/spring-boot/pull/43444.

Comment From: philwebb

@quaff Do you need to be able to update just the redirects? I assumed that using a complete ClientHttpRequestFactorySettings would be enough for most people.

Comment From: quaff

@quaff Do you need to be able to update just the redirects?

Yes.

Comment From: quaff

I like the UnaryOperator as customizer, thanks. @philwebb