I'm starting a new thread for that. I discovered this issue as described in
https://groups.google.com/forum/#!topic/wiremock-user/zO8Gm7nRdCM
It means that WireMock saves the 401 response at this point.
Now, the client re-sends the request with the credentials included and receives the 200 OK response.
However, WireMock does not save it, because "Not recording mapping for /basic-auth/test_user/test_pass as this has already been received".
Is there a solution for this problem without enabling the preemptive authentication in Apache HTTP client?
Here is the scenario that I described:
31-07-2017_16:05:08 DEBUG [WireMock]: Proxying: GET http://httpbin.org/basic-auth/test_user/test_pass
31-07-2017_16:05:09 DEBUG [WireMock]: Request received:
127.0.0.1 - GET /basic-auth/test_user/test_pass
Connection: [keep-alive]
User-Agent: [Apache-HttpClient/4.5 (Java/1.8.0_91)]
Host: [localhost:59564]
Accept-Encoding: [gzip,deflate]
Matched response definition:
{
"status" : 200,
"proxyBaseUrl" : "http://httpbin.org"
}
Response:
HTTP/1.1 401
Connection: [keep-alive]
Server: [meinheld/0.6.1]
Date: [Mon, 31 Jul 2017 13:05:06 GMT]
X-Powered-By: [Flask]
X-Processed-Time: [0.000400066375732]
Www-Authenticate: [Basic realm="Fake Realm"]
Access-Control-Allow-Origin: [*]
Access-Control-Allow-Credentials: [true]
Content-Length: [0]
Via: [1.1 vegur]
31-07-2017_16:05:09 DEBUG [WireMock]: Recording mappings for /basic-auth/test_user/test_pass
[Fatal Error] :1:1: Premature end of file.
31-07-2017_16:05:09 DEBUG [WireMock]: Proxying: GET http://httpbin.org/basic-auth/test_user/test_pass
31-07-2017_16:05:09 DEBUG [WireMock]: Request received:
127.0.0.1 - GET /basic-auth/test_user/test_pass
Connection: [keep-alive]
User-Agent: [Apache-HttpClient/4.5 (Java/1.8.0_91)]
Authorization: [Basic dGVzdF91c2VyOnRlc3RfcGFzcw==]
Host: [localhost:59564]
Accept-Encoding: [gzip,deflate]
Matched response definition:
{
"status" : 200,
"proxyBaseUrl" : "http://httpbin.org"
}
Response:
HTTP/1.1 200
Connection: [keep-alive]
Server: [meinheld/0.6.1]
Date: [Mon, 31 Jul 2017 13:05:07 GMT]
Content-Type: [application/json]
Access-Control-Allow-Origin: [*]
Access-Control-Allow-Credentials: [true]
X-Powered-By: [Flask]
X-Processed-Time: [0.000518083572388]
Content-Length: [52]
Via: [1.1 vegur]
{
"authenticated": true,
"user": "test_user"
}
31-07-2017_16:05:09 DEBUG [WireMock]: Not recording mapping for /basic-auth/test_user/test_pass as this has already been received
Thank you,