【发布时间】:2021-06-16 14:01:44
【问题描述】:
在 scala 中运行我的脚本时出现此错误:“无法构建请求:未定义名为 'jwtoken' 的属性”,我提取 jwtoken 的值,然后将其放入变量中,然后我想阅读它在另一个请求中,我放了 2 个对象,因为我想运行两个场景:
class PPT_GET extends Simulation
{ val httpProtocol = http
.baseUrl("") // Here is the root for all relative URLs
val acteurscsv = csv("./src/test/resources/Data/ksp-acteurs.csv").circular
val jwt = "123"
object TokenGen {
val tokenGen = exec(http("access_token")
.post("https://URL1/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.formParam("grant_type", value = "client_credentials")
.formParam("client_id", value = "PRTAPIPPD")
.formParam("client_secret", value = "xxxxxx")
.check(status is 200, jsonPath("$.access_token").saveAs("atoken")))
.exec(http("jwt_token")
.get("https://bsc-ppd.web.bpifrance.fr/mga/sps/apiauthsvc/policy/AT4JWT")
.header("Authorization", "Bearer ${atoken}")
.header("CorrelationID", "someID")
.header("UsercallerSecret", "user1")
.header("UsercallerID", "X1")
.header("Accept", "application/json")
.check(status is 200, jsonPath("$.JWTFull").saveAs("jwtoken"))) //here i extract the variable jwtoken
}
object Acteurs {
val acteurs =
pause(80)
.feed(acteurscsv)
.exec(http("ksp-acteurs")
.get("https://URL1/ksp-acteurs/${ACTCODE}")
.header("Authorization", "Bearer ${jwtoken}" ) // here where i have the erreor
.check(status is 200))
}
【问题讨论】:
标签: scala gatling scala-gatling