Post Request with JWT


I have this Scenario

class IssueWebhook extends Simulation {

//val session : Session

val httpProtocol = http.baseURL(CONNECT_APP)

val paramsMutableMapHack = collection.mutable.MapString, Array[String]

val fireIssueWebhookScenario = scenario(s"Register ${NUM_TENANTS} Tenants")
.queryParam(“jwt”,JwtSigner.generateSignature(“POST”,"/jira-issue_updated", paramsMutableMapHack.toMap,"${tenant}","${user}",“mock-tenant-shared-secret”))
.pause(1 second)

setUp(fireIssueWebhookScenario.inject(ramp(NUM_TENANTS users) over (10 seconds)))


I need to do Post Request with JWT. Gatling-jwt only supports GET. So what I try to do is call to JwtSigner.generateSignature (from Gatling-jwt) to Generate the JWT token and pass it as parameter. The problem is that JwtSigner.generateSignature is generating the Token with exactly “${tenant}” and “${user}”. I though both “${tenant}” and “${user}” are replaced by the current tentant an user of session. Obviusly I am doing something wrong. Pls Help me.

This is the code of JWTSigner.generateSignature

This is an example of what is generating:

{ “alg”: “HS256”, “typ”: “JWT” }
{ “iss”: “${tenant}”, “iat”: 1423749763, “qsh”: “17cf901e7574ec13905582237c2741dece664398dcb6fdc32384b25d4a8fcfa9”, “sub”: “${user}”, “exp”: 1423749943 }
Signature (encoded)

Thanks a lot!

You have to pass a function to queryParam, not a value.

thanks for the quickly answer.

I think i get it. There is no possible to get the current value of ${tenant} and ${user} and pass it to JwtSigner.generateSignature to build with the JWT to current tenant and user?.

You can’t use Gatling EL inside custom code.