我有下面的代码,看起来它不检查标题作为谓词。
{
"responses": [
{
"inject": "<%- stringify(filename, 'Scripts/MyDept/CutOffTime.ejs') %>"
}
],
"predicates": [
{
"matches": {
"method": "GET",
"path": "/cutoff-times",
"query": {
"country": "\w+"
},
"headers": {
"X-CLIENT-ID": "^[ A-Za-z0-9]*$"
}
}
}
]
}
奇怪的是,当我将@
作为值传递给标头X-CLIENT-ID
时,它会验证并显示消息没有谓词匹配。因为它不是正则表达式的一部分
发现问题,
基本上,如果你需要有多个谓词,需要像下面这样合并它们,(使用and/or)
{
"responses": [
{
"inject": "<%- stringify(filename, 'Scripts/MyDept/CutOffTime.ejs') %>"
}
],
"predicates": [
{
"and": [
{
"exists": {
"headers": {
"X-CLIENT-ID": true,
}
}
},
{
"matches": {
"method": "GET",
"path": "/cutoff-times",
"headers": {
"X-CLIENT-ID": "^[ A-Za-z0-9]*$"
},
"query": {
"country": "\w+"
}
}
}
]
}
]
}
骗子网站
进一步匹配谓词不检查是否存在(例如头是否存在)