Skip to content

Instantly share code, notes, and snippets.

@zeburek
Created October 1, 2018 11:35
Show Gist options
  • Save zeburek/4d27ac363beae579d5aebebc60c99f9b to your computer and use it in GitHub Desktop.
Save zeburek/4d27ac363beae579d5aebebc60c99f9b to your computer and use it in GitHub Desktop.
An example of SignatureCalculator for Gatling 2.3.1
package test.utils
import java.net.URI
import test.Test
import org.asynchttpclient.{Request, RequestBuilderBase, SignatureCalculator}
class HawkAuth extends SignatureCalculator {
override def calculateAndAddSignature(request: Request, requestBuilder: RequestBuilderBase[_]): Unit = {
val creds = Test.hawk.hawk_creds(Test.sessionToken)
val url = request.getUrl
val method = request.getMethod
val authHeader = Test.hawk.generate_hawk(creds.getId, creds.getKey, new URI(url), method)
requestBuilder.setHeader("Authorization", authHeader)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment