diff --git a/provider/junit5spring/src/test/groovy/au/com/dius/pact/provider/spring/junit5/WebFluxTargetSpec.groovy b/provider/junit5spring/src/test/groovy/au/com/dius/pact/provider/spring/junit5/WebFluxTargetSpec.groovy index 819494a4c..bef1cfa9f 100644 --- a/provider/junit5spring/src/test/groovy/au/com/dius/pact/provider/spring/junit5/WebFluxTargetSpec.groovy +++ b/provider/junit5spring/src/test/groovy/au/com/dius/pact/provider/spring/junit5/WebFluxTargetSpec.groovy @@ -13,6 +13,7 @@ import org.springframework.web.reactive.function.server.RequestPredicates import org.springframework.web.reactive.function.server.RouterFunction import org.springframework.web.reactive.function.server.RouterFunctions import org.springframework.web.reactive.function.server.ServerResponse +import spock.lang.Issue import spock.lang.Specification import java.nio.charset.StandardCharsets @@ -98,4 +99,17 @@ class WebFluxTargetSpec extends Specification { new V4Interaction.SynchronousMessages('test') | false new V4Interaction.SynchronousHttp('test') | true } + + @Issue('#1788') + def 'query parameters with null and empty values'() { + given: + def pactRequest = new Request('GET', '/', ['A': ['', ''], 'B': [null, null]]) + WebFluxTarget webFluxTarget = new WebFluxTarget(routerFunction) + + when: + def request = webFluxTarget.requestUriString(pactRequest) + + then: + request == '/?A=&A=&B&B' + } } diff --git a/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/WebFluxProviderVerifierSpec.groovy b/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/WebFluxProviderVerifierSpec.groovy index 10779852c..865bafbf4 100644 --- a/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/WebFluxProviderVerifierSpec.groovy +++ b/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/WebFluxProviderVerifierSpec.groovy @@ -11,6 +11,7 @@ import org.springframework.web.reactive.function.server.RouterFunctions import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.ServerResponse import reactor.core.publisher.Mono +import spock.lang.Issue import spock.lang.Specification import static org.springframework.web.reactive.function.server.RequestPredicates.GET @@ -96,4 +97,15 @@ class WebFluxProviderVerifierSpec extends Specification { new String(bytes) } + @Issue('#1788') + def 'query parameters with null and empty values'() { + given: + def pactRequest = new Request('GET', '/', ['A': ['', ''], 'B': [null, null]]) + + when: + def request = verifier.requestUriString(pactRequest) + + then: + request == '/?A=&A=&B&B' + } } diff --git a/provider/spring6/src/test/groovy/au/com/dius/pact/provider/spring/spring6/MockMvcTestTargetSpec.groovy b/provider/spring6/src/test/groovy/au/com/dius/pact/provider/spring/spring6/MockMvcTestTargetSpec.groovy index 20d5a8208..5ea99f3ac 100644 --- a/provider/spring6/src/test/groovy/au/com/dius/pact/provider/spring/spring6/MockMvcTestTargetSpec.groovy +++ b/provider/spring6/src/test/groovy/au/com/dius/pact/provider/spring/spring6/MockMvcTestTargetSpec.groovy @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestController +import spock.lang.Issue import spock.lang.Specification import java.nio.charset.StandardCharsets @@ -123,6 +124,18 @@ class MockMvcTestTargetSpec extends Specification { responseMap.body.valueAsString() == 'Hello 1234' } + @Issue('#1788') + def 'query parameters with null and empty values'() { + given: + def pactRequest = new Request('GET', '/', ['A': ['', ''], 'B': [null, null]]) + + when: + def request = mockMvcTestTarget.requestUriString(pactRequest) + + then: + request.query == 'A=&A=&B&B' + } + @RestController static class TestResource { @GetMapping(value = '/data', produces = 'application/json') diff --git a/provider/src/test/groovy/au/com/dius/pact/provider/groovysupport/ProviderClientSpec.groovy b/provider/src/test/groovy/au/com/dius/pact/provider/groovysupport/ProviderClientSpec.groovy index 9e7b21b3d..9a821fe31 100644 --- a/provider/src/test/groovy/au/com/dius/pact/provider/groovysupport/ProviderClientSpec.groovy +++ b/provider/src/test/groovy/au/com/dius/pact/provider/groovysupport/ProviderClientSpec.groovy @@ -789,4 +789,16 @@ class ProviderClientSpec extends Specification { entity.content.text == '{"ä": "äbc"}' entity.contentType == 'application/json; charset=UTF-8' } + + @Issue('#1788') + def 'query parameters with null and empty values'() { + given: + def pactRequest = new Request('GET', '/', ['A': ['', ''], 'B': [null, null]]) + + when: + def request = client.newRequest(pactRequest) + + then: + request.uri.query == 'A=&A=&B&B' + } }