When using the wiremock Docker image, wiremock is started as a remote server.
The current implementation of extensions in this repository only supports local invocation of wiremock (eg within a test runner). We want to use this extension on our wiremock remote server as well.
What changes did you make?
GraphqlBodyMatcher's match method now checks parameters: Parameter (this allows the remote server to communicate with the local client via Parameter)
Updated jvmTarget to 1.8. This is for compatibility in the execution environment because the wiremock image assumes jre8 :)
Added maven-assembly-plugin. This will create a jar with all dependencies when you run mvn package. The reason for this is that it is convenient to make the remote wiremock server aware
I wanted the unit test to pass, so I changed it (mockk<Parameter>)
About what we tested
mvn package
On docker, include jar in wiremock and start the container
FROM wiremock/wiremock:latest-alpine
COPY ./wiremock-graphql-extension-0.3.0-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.3.0-jar-with-dependencies.jar
CMD ["--verbose", "--enable-stub-cors", "--extensions", "io.github.nilwurtz.GraphqlBodyMatcher"]
Added wiremock extension for remote servers.
Motivation
When using the wiremock Docker image, wiremock is started as a remote server. The current implementation of extensions in this repository only supports local invocation of wiremock (eg within a test runner). We want to use this extension on our wiremock remote server as well.
What changes did you make?
parameters: Parameter
(this allows the remote server to communicate with the local client via Parameter)mvn package
. The reason for this is that it is convenient to make the remote wiremock server awaremockk<Parameter>
)About what we tested
mvn package
fun registerGraphQLWiremock(endpoint: String, token: String, request: Request, responseJson: String) { post(urlPathEqualTo(endPoint)) .withQueryParam("access_token", matching(token)) .andMatching("graphql-body-matcher", Parameters.one("expectedQuery", Json.encodeToString(request))) .willReturn( aResponse() .withStatus(200) .withBody(responseJson) .withHeader("Content-Type", "application/json; charset=utf-8") ).let(mock::register) }
fun registerGraphQLWiremock(endpoint: String, token: String, request: Request, responseJson: String) { post(urlPathEqualTo(endPoint)) .withQueryParam("access_token", matching(token)) .andMatching("graphql-body-matcher", Parameters.one("expectedQuery", Json.encodeToString(request))) .willReturn( aResponse() .withStatus(200) .withBody(responseJson) .withHeader("Content-Type", "application/json; charset=utf-8") ).let(mock::register) }