繁体   English   中英

在 Gatling 中使用 basicAuth 发出 Gatling Post 请求

[英]Make a Gatling Post request with basicAuth in Gatling

在我的加特林测试中,我有这个测试:

  val HorizonPost: ChainBuilder = exec(
    http("Horizon Post")
      .post(getRouteInfoURI).basicAuth(s"${{EnvValues.RoadsApi_Username}}", s"${{EnvValues.RoadsApi_Password}}")
      .body(ElFileBody("bodies/horizonPost.json")).asJson
      .check(status.is(200))
  )

似乎它与“current_timestamp”有问题并给出了这个错误:

    body=
The request content was malformed:
Text '{{$current_timestamp}}' could not be parsed at index 0

JSON 文件为:

 "locationTimestamp": "{{$current_timestamp}}",

有人可以解释我需要改变什么吗? 我对加特林比较陌生。

如果您尝试使用Scala 字符串插值,正确的语法是s"${foo}" ,而不是s"${{foo}}"

如果您尝试使用Gatling Expression Language ,正确的语法是"${foo}" (no s ),而不是s"${{foo}}"

我们通过将时间戳存储在单独的 csv 文件中解决了这个问题,唯一的问题是它不是 current_timestamp。 感谢您的可能性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM