I'm attempting to use gatling against a server that uses HAWK Authentication. The issue is that the header needs to be generated for each request and pass in the key id and key. Which makes sending requests from multiple users hard. I've gotten this Hawk java library working with hard coded keys. However, I'd like to simulate multiple users using a feeder. I can't seem to get this working as the feeders aren't properly passed into function calls.
I have the following code:
class TestRampSimulation extends Simulation {
{
...
def generateHawk(key: String, secret: String, method: String, url: String): String = {
val hawkCredentials: HawkCredentials = new HawkCredentials.Builder()
.keyId(key)
.key(secret)
.algorithm(HawkCredentials.Algorithm.SHA256)
.build();
val hawkClient: HawkClient = new HawkClient.Builder().credentials(hawkCredentials).build();
val authorizationHeader: String = hawkClient.generateAuthorizationHeader(URI.create(url), method, null, null, null, null);
return authorizationHeader
}
val nbUsers = Integer.getInteger("users", 1).toInt
val rmpTime = Integer.getInteger("ramp", 1).toInt
val feeder = csv("tokens.csv").random
val scn = scenario("Test API")
.feed(feeder)
.exec(http("[POST] /some/api/call")
.post("/some/api/call")
.headers(Map("Authorization" -> "".concat(generateHawk("${keyId}",
"${keySecret}",
"POST",
"http://localhost:8080/some/api/call"))))
.check(status.is(201)))
setUp(scn.inject(rampUsers(nbUsers) over (rmpTime seconds)).protocols(httpConf))
}
When I do this, key and secret are evaluated as "${keyId}"/"${keySecret}" instead of the feeder values. Is what I'm trying to do possible?