我正在尝试编写一个测试,以确保name
JSON 响应中的属性不是MYGROUP
. 我被困在这里,因为我正在尝试使用测试中的代码来检查name
属性是否为MYGROUP
. 我知道我需要在这个测试的 if 条件下修复一些东西:
# Check AD group deletion
- url: ${ADSubscriptions}/${NetworkID}/clientsyncs/${syncId}/groups
label: 1360_CheckADGroupDeletion
method: GET
headers:
Authorization: Bearer ${access_token}
Content-Type: "application/json"
Accept: "application/json, text/plain, */*"
assert-httpcode:
- 200
- 202
jsr223:
- langauge: groovy
execute: after
script-text: |
import groovy.json.JsonSlurper
def slurperresponse = new JsonSlurper().parseText(prev.getResponseDataAsString())
for (entry in slurperresponse){
if(entry.name == "MYGROUP" || entry.name == "mygroup" ){
{RETURN FALSE HERE}
break;
}
}
- langauge: groovy
execute: after
script-file: jsr223/logger.groovy
parameters: check_adgroup_deletion
测试中使用的请求的预期 json 结构如下所示:
[
{
"id": "id1",
"name": "MYGROUP",
"selected": true
}
]
上述响应将等同于测试失败。以下将等同于通过测试。
[
{
"id": "id1",
"name": "MYGROUP",
"selected": false
}
]