Hi All,
I’m using gatling-charts-highcharts-bundle-3.2.0 and have a simple 2-stage scenario where I need to POST for a bearer token before using it in the next request in an authorization header. After some debugging I’ve found gatling is dropping the header when I set the ‘Authorization’ header value to ‘Bearer ${token}’. If for example I set the value to ‘foo ${token}’, I can see the token is captured correctly and added to the headers for the request.
Can anyone help point me in the right direction?
Thanks,
Tony
Here’s my scenario file:
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class NewSimulation extends Simulation {
val bearerHeader = Map(“Content-Type” → “application/x-www-form-urlencoded”)
val authURI = “https://someurl/v1/token”
val endpoint = “https://someendpoint/api/test”
val scn = scenario(“Testing”)
.exec(http(“Auth”)
.post(authURI)
.headers(headerAuth)
.formParam(“grant_type”, “client_credentials”)
.basicAuth(“user”,“PASS”)
.check(status.is(200))
.check(regex("“access_token”:"(.+?)"").find.saveAs(“token”)))
.exec(http(“Rate”)
.post(rateURI)
.header(“Authorization”, “Bearer ${token}”)
.check(status.is(307)))
setUp(scn.inject(atOnceUsers(1))).protocols()
}
Here’s the output with 'Bearer ${token}":
HTTP request:
POST https://someendpoint/api/test
headers=
accept: /
Referer: https://someendpoint/api/test
origin: https://someendpoint
host: someendpoint
content-length: 0
And here is with ‘foo ${token}’
HTTP request:
POST https://someendpoint/api/test
headers=
Authorization: foo $TOKEN_DATA_IS_HERE
accept: /
Referer: https://someendpoint/api/test
origin: https://someendpoint
host: someendpoint
content-length: 0