我是加特林新手,还是scala新手。我希望在Gatling 3.2中执行与this question类似的操作
我需要从其他端点保存json,将数据插入保存到会话中的json,然后返回json。
json看起来像这样:
{
"authnId": "abc123",
"authnData": [
{
"type": "Username",
"input": [
{
"name": "token1",
"value": ""
}
],
"id": 0
},
{
"type": "Password",
"input": [
{
"name": "token2",
"value": ""
}
],
"id": 1
}
]}
我有一个供料器:
val userFeeder: Iterator[Map[String, String]] = Iterator.continually(Map(
"""username""" -> (simConfig.userPrefix + random.nextInt(simConfig.userPoolSize).toString),
"""password""" -> simConfig.userPassword)
)
而且我需要返回此值(假设最好在此处插入gatling占位符,我不确定是这样的:]]]
{ "authnId": "abc123", "authnData": [ { "type": "Username", "input": [ { "name": "token1", "value": "${username}" } ], "id": 0 }, { "type": "Password", "input": [ { "name": "token2", "value": "${password}" } ], "id": 1 } ]
}
这是我的模拟的一部分:
.exec( http("get json") .post(simConfig.authnUrl) .check(status.is(200)) .check(jsonPath("$.authnId").find.saveAs("authnId")) .check(jsonPath("$").find.saveAs("jsonbody"))) .exitHereIfFailed .exec(session => { //modify jsonbody here }) .feed(userFeeder) .exec(http("submit credentials") .post(config.authnUrl) .disableUrlEncoding .asJson .body(StringBody("$jsonbody") ) .check(status.is(200)) .check(jsonPath("$.authnId").find.saveAs("ssoToken")) ).exitHereIfFailed
3.2战斗中最好的方法是什么?
我是加特林新手,还是scala新手。我想在Gatling 3.2中执行与此问题类似的操作,我需要从其余端点保存json,将数据插入保存到....>
如果我清楚地了解您,请尝试使用ElFileBody
首先创建json,其中使用加特林el表达式"value": "${password}"
定义变量