I need when do first request then get stub response code = 401.
When do second SAME request then get stub response code = 200.
To do this I use scenario.
Here my WireMock mapping in ONE file:
{
"scenarioName": "Request transfer, 401",
"requiredScenarioState": "Started",
"newScenarioState": "Triggered Once",
"request": {
"method": "POST",
"urlPattern": "/api/T2A"
},
"response": {
"headers": {
"Content-Type": "application/json"
},
"status": 401
}
}
{
"scenarioName": "Request transfer, 200",
"requiredScenarioState": "Triggered Once",
"newScenarioState": "Started",
"request": {
"method": "POST",
"urlPattern": "/api/T2A"
},
"response": {
"headers": {
"Content-Type": "application/json"
},
"status": 200,
"bodyFileName": "VB/back/request_transfer.json"
}
}
When do first request I get stub response = 401.
Nice. But when do second same request WireMock return error code = 404.
Request was not matched
=======================
-----------------------------------------------------------------------------------------------------------------------
| Closest stub | Request |
-----------------------------------------------------------------------------------------------------------------------
|
POST | POST
/api/T2A | /api/T2A
|
|
-----------------------------------------------------------------------------------------------------------------------
2021-03-02 22:44:34.802 Request received:
127.0.0.1 - POST /api/T2A
{"MTS":"2be192ca-dabe-47b9-b","IDNP":"1"}
Matched response definition:
(no response definition configured)
Response:
HTTP/1.1 404
(no headers)
2021-03-02 22:44:34.805 Received request to /not-matched with body
Why second SAME request not return stub response status = 200?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…