Hi all,
I am developing a gatling test where I read from CVS circular feeder the email address (column “username”) and encode the password “1111” with email with Base64 to use as “Authorization” header in form of:
Authorization: AppBasic xxxxx(Base64 encoded "test1@app.com:1111")
Here comes the question: the EL expression “${username}” is not working when I use:
`
feed(env.feeder).exec(
http(Seq(env.base, “authorize”).mkString(":"))
.post(env.base + “/authorize”)
.asJSON // “Accept” and “ContentType” set to JSON
.header(HttpHeaderNames.AcceptCharset, “UTF-8”)
.header(HttpHeaderNames.Authorization, Base64.getEncoder().encodeToString(("${username}" + “:” + “1111”).getBytes()))
.body(StringBody(env.authorizeBody))
.check(
status.is(200),
header(HttpHeaderNames.ContentType).is(HttpHeaderValues.ApplicationJson),
header(HttpHeaderNames.AcceptCharset).is(“UTF-8”),
jsonPath("$…id_token") exists
)
)
`
Because interpolation in a method seems not to work.
So, I am trying something like:
.header(HttpHeaderNames.Authorization, "${username}".map(username => Base64.getEncoder().encodeToString((username + ":" + "1111").getBytes())))
which leads to a “Vector” of Base64-encoded each letter of the email address, which is not what I want; because “String.map” changes the string into a vector of byte.
So, what can I do here?? Why using the interpolation of EL expression works only out of a function, not inside?