Hello
I am very new to gatling(about 2 days old) and I have a task in hand. I need to write a test for a Secure POST request which needs to contain
- Digest of the payload in the header
- Signature in the header which has digest and date as two of the 4 fields.
I first tried to use my customSignature to sign the request and calculate the digest
val scn = scenario("HelloWorldTest")
.feed(debitAccountFeeder)
.exec(http("request_1")
.post(baseClass.eAppResource)
.body(StringBody(baseClass.generateBody("${DEBITIBAN}", "${CREDITIBAN}"))).asJSON
.signatureCalculator(new MessageSignature())
.header("Authorization", "${ACCESSTOKEN}")
.header("Date", myHeaderDateString)
.header("Digest", baseClass.generateDigest(baseClass.myFinalMessage))
.header("Signature", baseClass.generateSignature(myHeaderDateString,
baseClass.messageDigest,
"${CLIENTID}",
"cert.pem"))
.header("host", baseClass.eAppHost))
This was giving wrong digest value and after reading through the logs and blogs I found that this was due the fact that the feeder replace the values in the request only at the last minute before sending the request to server.
There are a lot of forums which are suggesting to implement the SignatureCalculator interface. But I am not able to find a working example which caters to
- How this method is integrated with the scenario
- How the value of the request object is passed from the scenario to implemented method.
Is it possible to provide a sample code snippet which can help me understand how it is integrated and what needs to be done to make this work for me
Regards
Himanshu