Slackbot
02/01/2024, 12:15 PMTom
02/01/2024, 2:40 PMname
parameter defines as standard. These examples aren’t great TBH - we should replace with some more realistic ones.
That page does contain a list of all the attributes on the request model, so I’d suggest starting there to find the data you need.
If you want to fetch data out of a JSON request body then {{jsonPath request.body '$.myAttribute'}}
is the place to startOswald Quek
02/01/2024, 3:26 PM{{jsonPath request.body '$.myAttribute'}}
in my code snippet. I was implying it doesn't seem to work with the {{#eq}}
and {{else}}
. I always get the resulting code block in the {{else}}
block, i.e. <td id="threeds-sim-pa-res">authorised</td>
, even if the jsonPath request.body '$.PaReq'
is equal to authorisation_fail
Tom
02/01/2024, 3:55 PMOswald Quek
02/01/2024, 4:07 PMwm.register(post(urlMatching("/3ds-simulator\\?orderCode=.*"))
.willReturn(aResponse()
.withStatus(200)
.withTransformers("response-template")
.withBody(readFile("3dsSimulator.html"))
.withHeader("Content-Type", "text/html")));
3dsSimulator.html
looks something like:
<table>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Value</th>
</tr>
</thead>
<tr>
<td><strong>PaRes</strong></td>
{{#eq jsonPath request.body '$.PaReq' 'authorisation_fail'}}
<td id="threeds-sim-pa-res">authorisation_fail</td>
{{else}}
<td id="threeds-sim-pa-res">authorised</td> <---this line is always returned
{{/eq}}
</tr>
<tr>
<td><strong>MD</strong></td>
<td id="threeds-sim-md">{{jsonPath request.body '$.MD'}}</td>
</tr>
</table>
I'm finding no matter the value of the PaReq
in the POST request body is, I always get <td id="threeds-sim-pa-res">authorised</td>
in the response body from Wiremock.Tom
02/01/2024, 7:39 PM{{#eq (jsonPath request.body '$.PaReq') 'authorisation_fail'}}
Oswald Quek
02/07/2024, 9:33 AM