Merge branch '2.1.x'
This commit is contained in:
@@ -126,6 +126,9 @@ class WireMockRequestStubStrategy extends BaseWireMockStubStrategy {
|
||||
if (bodyHasMatchingStrategy) {
|
||||
requestPattern.withRequestBody(
|
||||
convertToValuePattern(matchingStrategy))
|
||||
} else if (containsPattern(request?.body)) {
|
||||
requestPattern.withRequestBody(
|
||||
convertToValuePattern(appendBodyRegexpMatchPattern(request.body)))
|
||||
}
|
||||
else {
|
||||
def body = JsonToJsonPathsConverter.
|
||||
@@ -181,6 +184,13 @@ class WireMockRequestStubStrategy extends BaseWireMockStubStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
private Object generateConcreteValue(Object originalBody) {
|
||||
if (originalBody instanceof Pattern || originalBody instanceof RegexProperty) {
|
||||
return new RegexProperty(originalBody).generate()
|
||||
}
|
||||
return originalBody
|
||||
}
|
||||
|
||||
private RequestPatternBuilder requestBodyGuessedFromMatchingStrategy(RequestPatternBuilder requestPattern) {
|
||||
return requestPattern.withRequestBody(convertToValuePattern(
|
||||
getMatchingStrategy(request.body.clientValue)))
|
||||
|
||||
@@ -2793,6 +2793,31 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
stubMappingIsValidWireMockStub(wireMockStub)
|
||||
}
|
||||
|
||||
@Issue("#94")
|
||||
def "should not produce any cursors in the stub"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'POST'
|
||||
urlPath $(test('/resource/resourceId/another-resource/another-resource-id/sth'), stub(regex('/resource/[\\w\\.]+/another-resource/([\\w+\\.-]|%[a-fA-F0-9]{2})+/sth')))
|
||||
body($(stub(regex(".+")), test(execute("encrypt('a lot of code')"))))
|
||||
}
|
||||
response {
|
||||
status 201
|
||||
}
|
||||
// 1 is the highest
|
||||
priority 1000
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy("Test",
|
||||
new ContractMetadata(null, false, 0, null, contractDsl), contractDsl)
|
||||
.toWireMockClientStub()
|
||||
|
||||
then:
|
||||
stubMappingIsValidWireMockStub(wireMockStub)
|
||||
|
||||
}
|
||||
|
||||
WireMockConfiguration config() {
|
||||
return new WireMockConfiguration().extensions(responseTemplateTransformer())
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ trait WireMockStubVerifier {
|
||||
Pattern.compile(it.getValue())
|
||||
}
|
||||
assert !mappingDefinition.contains('org.springframework.cloud.contract.spec.internal')
|
||||
assert !mappingDefinition.contains('cursor')
|
||||
}
|
||||
|
||||
void stubMappingIsValidWireMockStub(Contract contractDsl) {
|
||||
|
||||
Reference in New Issue
Block a user