Is it possible to modify parameter values defined in the body during provider verification?
The pact wiki(https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245) provides a feature to modify the request:
@TargetRequestFilter
public void exampleRequestFilter(HttpRequest request) {
request.addHeader("Authorization", "OAUTH hdsagasjhgdjashgdah...");
}
but org.apache.http.HttpRequest
can only modify the headers
and not the body
.
This is my relevant pact information:
"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})"
}
]
}
}
}
},
In the above example, I would like to modify the s3ObjectKey
to a different UUID.
This answer(https://stackoverflow.com/a/46377050/3714922) says you can modify URL(I think it refers to path
in my pact above) but I couldn't figure out how to modify URL or body.