-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
RestTemplateBuilder headers no longer get applied when using MockRestServiceServer #17885
Comments
@gilinykh Creating Can you please share a complete sample that we can run so that we can confirm if this is a bug or expected behavior. |
@philwebb Here's the link to full sample gilinykh/mockrestserver-test Your summary is correct. But then what's the intended way to write tests with |
IMO, the problem is that since Spring Boot 2.2 there are a number of features that have been moved to wrapping the |
We changed this because spring-projects/spring-framework#22002 was declined and we wanted to set headers without reading the entire body. I have a feeling we might need that framework change after all. |
Maybe we add support for |
I was working on a PR. I think a |
I've reopened spring-projects/spring-framework#22002 with a suggested fix. If that gets accepted to can apply https://github.com/philwebb/spring-boot/tree/gh-17885 |
It's been accepted. Let me know if you need any help for this. |
build
method in default implementation ofMockRestServiceServerBuilder
overwrites request factory which makes impossible to write tests using remote resources access viaRestTemplate
built throughRestTemplateBuilder.defaultHeader()
with headers.How to reproduce:
bean definition:
using in test:
And then requests sent to that mock api will come without custom
x-api-key
headerThe text was updated successfully, but these errors were encountered: