I am using Gatling version 3.9.2. I have a chainbuilder scenario where a specific endpoint returns a jwt token that I need to decode and use the cid value stored in that token in the next request. I was trying something along the lines of this but I only need the token in that response body decoded not the entire response. I am not finding good examples online of using transformResponse for what I am trying to do. Curious if there is a way to decode this token using .check instead. Any help is greatly appreciated! Thanks in advance.
.exec(
http("POST /verification/verify")
.post("/verification/verify")
.headers(headers_10)
.header("authorization", token.concat("#{bearerToken}"))
.body(StringBody("{ \"VerificationType\": \"#####\", \"EmailAddress\": \"#{email}\", \"Token\": \"######\" , \"TransactionId\": \"#{transactionId}\"}"))
.check(jmesPath("token").find().saveAs("verifyToken"))
.check(status().is(200))
.transformResponse((response, session) -> {
if (response.status().code() == 200) {
return new io.gatling.http.response.Response(
response.request(),
response.startTimestamp(),
response.endTimestamp(),
response.status(),
response.headers(),
new io.gatling.http.response.ByteArrayResponseBody(Base64.getDecoder().decode(response.body().string()), StandardCharsets.UTF_8),
response.checksums(),
response.isHttp2()
);
} else {
return response;
}
}
)
)
.pause(1);