-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Description
My test is broken after rest-assured
dependency removed, I found it caused by TestRestTemplate
inconsistent follow redirects. TestRestTemplate
will use apache httpclient since org.apache.httpcomponents: httpclient
is introduced by rest-assured
, following redirects is disabled by default, thanks to #1497, you can enable it by passing HttpClientOption.ENABLE_REDIRECTS
.
If apache httpclient is not present, TestRestTemplate
will fallback to okhttp3:
Lines 41 to 45 in 47516b5
Map<String, String> candidates = new LinkedHashMap<>(); | |
candidates.put("org.apache.http.client.HttpClient", | |
"org.springframework.http.client.HttpComponentsClientHttpRequestFactory"); | |
candidates.put("okhttp3.OkHttpClient", "org.springframework.http.client.OkHttp3ClientHttpRequestFactory"); | |
REQUEST_FACTORY_CANDIDATES = Collections.unmodifiableMap(candidates); |
okhttp3 enable following redirects by default, I think TestRestTemplate
should keep same behavior not matter which underlying implementation, disabling following redirects is sensible since test want to know which url is redirected to, and it would be better if this option can be mutated.