是否可以在提供者验证期间修改主体中定义的参数值?
契约wiki(https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245)提供了修改请求的功能:
@TargetRequestFilter
public void exampleRequestFilter(HttpRequest request) {
request.addHeader("Authorization", "OAUTH hdsagasjhgdjashgdah...");
}
但是org.apache.http.HttpRequest
只能修改headers
,而不能修改body
。
这是我的相关公约信息:
"request": {
"method": "POST",
"path": "/testApi",
"headers": {
"Content-Type": "application/json"
},
"body": {
"fileName": {
"s3ObjectKey": "1649a6d0-4aee-11e9-8646-d663bd873d93"
}
},
"matchingRules": {
"body": {
"$['fileName'].s3ObjectKey": {
"matchers": [
{
"match": "regex",
"regex": "([a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12})"
}
]
}
}
}
},
在上面的示例中,我想将s3ObjectKey
修改为其他UUID。
此答案(https://stackoverflow.com/a/46377050/3714922)说,您可以修改URL(我认为上面的协定中指的是path
),但我不知道如何修改URL或正文。