diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c70aa783..891a5d68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 with: - ruby-version: '2.7.6' # Not needed with a .ruby-version file + ruby-version: '2.7.2' # Not needed with a .ruby-version file bundler: '2.4.10' bundler-cache: false # runs 'bundle install' and caches installed gems automatically cache-version: 3 # Increment this number if you need to re-download cached gems @@ -28,7 +28,7 @@ jobs: id: pages uses: actions/configure-pages@v3 - name: Update RubyGems and Co - run: gem update --system + run: gem update - name: Install Ruby Bundles run: bundle install - name: Build with Jekyll diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index adfb4b90..b641376f 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -2,8 +2,8 @@ name: Deploy Jekyll site to Pages on: # Runs on pushes targeting the default branch - push: - branches: ["main"] + # push: + # branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -40,7 +40,7 @@ jobs: id: pages uses: actions/configure-pages@v3 - name: Update RubyGems and Co - run: gem update --system + run: gem update - name: Install Ruby Bundles run: bundle install - name: Build with Jekyll diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml deleted file mode 100644 index f3aafbcf..00000000 --- a/.github/workflows/updatecli.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: "Updatecli" - -on: - workflow_dispatch: - schedule: - # * is a special character in YAML so you have to quote this string - # trigger every hour the following pipeline - - cron: '0 * * * *' - -permissions: - contents: write - pull-requests: write - -jobs: - updatecli: - runs-on: ubuntu-latest - # Ensure we only run the following pipeline from main branch - # with a GITHUB_TOKEN that has "contents: write" permission - if: github.ref == 'refs/heads/main' - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Updatecli Binary - uses: updatecli/updatecli-action@v2 - - - name: Run Updatecli in enforce mode - run: "updatecli apply --config .github/updatecli/updatecli.d" - env: - GITHUB_ACTOR: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Gemfile.lock b/Gemfile.lock index b968d007..dae010b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,11 +108,11 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) - wdm (0.1.1) webrick (1.8.1) PLATFORMS arm64-darwin-21 + arm64-darwin-23 x64-mingw32 x86_64-linux @@ -126,7 +126,6 @@ DEPENDENCIES jemoji json (~> 1.8.6) nokogiri (>= 1.7.2) - wdm (~> 0.1.0) webrick (~> 1.7) BUNDLED WITH diff --git a/_config.yml b/_config.yml index 0dc9f33e..30b074cc 100644 --- a/_config.yml +++ b/_config.yml @@ -234,11 +234,11 @@ compress_html: ignore: envs: development -wiremock_version: 3.3.1 +wiremock_version: 3.6.0 wiremock_baseline: 3.x pageEditPrefix: https://github.com/wiremock/wiremock.org/edit/main/ -grpc_extension_version: 0.4.0 +grpc_extension_version: 0.6.0 community_slack: join_url: https://slack.wiremock.org/ diff --git a/_data/doc-categories.yml b/_data/doc-categories.yml index 2e6a15f4..abbae640 100644 --- a/_data/doc-categories.yml +++ b/_data/doc-categories.yml @@ -26,7 +26,9 @@ java: - java-usage - configuration - running-without-http-server + - jetty-12 - android + - pact stubbing-and-verifying: title: Stubbing & Verifying @@ -40,8 +42,8 @@ stubbing-and-verifying: - proxying - verifying -templating: - title: Templating +library: + title: Mock API Template Library link: /docs/mock-api-templates pages: - mock-api-templates @@ -59,6 +61,7 @@ protocols: - webhooks-and-callbacks - grpc - solutions/graphql + - jwt - https configuration: diff --git a/_docs/configuration.md b/_docs/configuration.md index accf16a5..69ec41c1 100644 --- a/_docs/configuration.md +++ b/_docs/configuration.md @@ -5,6 +5,8 @@ meta_title: Configuring WireMock in Java | WireMock description: Configuring WireMock progammatically in Java. --- +
+ Both `WireMockServer` and the `WireMockRule` take a configuration builder as the parameter to their constructor e.g. ```java @@ -98,6 +100,20 @@ WireMock uses the trust store for three purposes: 3. As a proxy, WireMock will trust a target server if it presents a public certificate in this trust store + +## HTTP/2 configuration + +HTTP/2 can be disabled separately for plain text (HTTP) and TLS (HTTPS): + +```java +// Disable HTTP/2 over HTTP +.http2PlainDisabled(true); + +// Disable HTTP/2 over HTTPS +.http2TlsDisabled(true); +``` + + ## Proxy settings ```java @@ -130,6 +146,11 @@ WireMock uses the trust store for three purposes: // The type of the CA key store .caKeystoreType("JKS") + +// Which proxy encodings to proxy through to the target if the request contains an Accept-Encoding header +// By default this is null, which means the header is sent to the target unchanged +// If there is an Accept-Encoding header on the request, and it does not contain any of the supported proxy encodings, the header is not sent to the target. +.withSupportedProxyEncodings("gzip", "deflate") ``` ## File locations diff --git a/_docs/download-and-installation.md b/_docs/download-and-installation.md index 6c7fa81a..11943b0b 100644 --- a/_docs/download-and-installation.md +++ b/_docs/download-and-installation.md @@ -4,17 +4,18 @@ title: Download and Installation meta_title: "How to Download and Install WireMock" toc_rank: 13 description: > - WireMock is available as a standalone service (for Docker of Java), Java library - and integrations for modern languages and technology stacks. -redirect_from: - - "/download.html" - - "/download/" - - "/downloads.html" - - "/downloads/" - - "/docs/download.html" - - "/docs/download/" + WireMock is available as a standalone service (for Docker of Java), Java library + and integrations for modern languages and technology stacks. +redirect_from: + - "/download.html" + - "/download/" + - "/downloads.html" + - "/downloads/" + - "/docs/download.html" + - "/docs/download/" --- + ## Download options @@ -58,7 +59,7 @@ docker run -it --rm -p 8080:8080 --name wiremock \ {% endcodetab %} -{% codetab Gradle Groovy %} +{% codetab Gradle %} ```groovy testImplementation "org.wiremock:wiremock-standalone:{{ site.wiremock_version }}" diff --git a/_docs/extending-wiremock.md b/_docs/extending-wiremock.md index bebd4462..be464785 100644 --- a/_docs/extending-wiremock.md +++ b/_docs/extending-wiremock.md @@ -7,6 +7,8 @@ redirect_from: "/extending-wiremock.html" description: You can register the extension programmatically via its class name, class or an instance --- + + WireMock can be customised via a variety of extension points. Each extension point is defined by an interface that extends from `Extension` and extension implementations are loaded at startup time. @@ -26,6 +28,10 @@ At present, the following extension interfaces are available: The interfaces in this list ending with `V2` supercede deprecated equivalents with an older, more restrictive interface. Additionally `ServeEventListener` deprecates `PostServeAction`. +As of WireMock version `3.6.0`, the `Extension` interface has two new lifecycle methods called `start()` and `stop()`. +The `start()` method is called on each extension when the WireMock server first starts (just before the stub mappings +are loaded) and the `stop()` method is called when the server is stopped. This allows extensions to perform any +initialisation or cleanup tasks. ## Registering Extensions diff --git a/_docs/extensibility/adding-template-model-data.md b/_docs/extensibility/adding-template-model-data.md index 7dc0f456..c4bb1be7 100644 --- a/_docs/extensibility/adding-template-model-data.md +++ b/_docs/extensibility/adding-template-model-data.md @@ -5,7 +5,7 @@ meta_title: Adding Template Model Data description: Adding extra elements to the template model during request processing --- -Extensions that implement the `TemplateHelperProviderExtension` interface provide additional Handlebars helpers to the templating system: +Extensions that implement the `TemplateModelDataProviderExtension` interface provide additional model elements to the templating system: ```java new WireMockServer(.extensions( diff --git a/_docs/extensibility/filtering-requests.md b/_docs/extensibility/filtering-requests.md index 3bda7a62..2d3be6a4 100644 --- a/_docs/extensibility/filtering-requests.md +++ b/_docs/extensibility/filtering-requests.md @@ -5,6 +5,8 @@ meta_title: Filtering and Modifying Requests description: Filtering and modifying requests via extensions --- + + Requests to both stubs and the admin API can be intercepted and either modified or halted with an immediate response. This supports a number of use cases including: authentication, URL rewriting and request header injection. diff --git a/_docs/getting-started.md b/_docs/getting-started.md index 76c09df5..8b3bbbe3 100644 --- a/_docs/getting-started.md +++ b/_docs/getting-started.md @@ -18,6 +18,7 @@ At the moment, we provide the following quick starts for beginners: - [API Mocking with Java and JUnit 4](../quickstart/java-junit) - [Downloading and Installing WireMock](../download-and-installation) +- [Using WireMock with Jetty 12](../jetty-12) diff --git a/_docs/grpc.md b/_docs/grpc.md index 7d264bc3..e7ffd8ff 100644 --- a/_docs/grpc.md +++ b/_docs/grpc.md @@ -32,7 +32,7 @@ Add the extension JAR dependency to your project: Gradle: ```gradle -implementation 'org.wiremock:wiremock-grpc-extension:{{ site.grpc_extension_version }}' +testImplementation 'org.wiremock:wiremock-grpc-extension:{{ site.grpc_extension_version }}' ``` Maven: @@ -42,6 +42,7 @@ Maven:
diff --git a/_docs/solutions/dotnet.md b/_docs/solutions/dotnet.md
index 81ac805e..a332c58c 100644
--- a/_docs/solutions/dotnet.md
+++ b/_docs/solutions/dotnet.md
@@ -6,6 +6,7 @@ description: "Additional solutions for WireMock when using .NET"
logo: /images/logos/technology/dotnet.svg
---
+
## WireMock.Net
diff --git a/_docs/solutions/golang.md b/_docs/solutions/golang.md
index 5e2b8c5a..78454888 100644
--- a/_docs/solutions/golang.md
+++ b/_docs/solutions/golang.md
@@ -10,6 +10,8 @@ redirect_from:
hide-disclaimer: true
---
+
+
## Testcontainers module for Go
The WireMock community provides a [Testcontainers for Go module](https://github.com/wiremock/wiremock-testcontainers-go) module
diff --git a/_docs/solutions/graphql.md b/_docs/solutions/graphql.md
index 24b0f91e..e25f55ce 100644
--- a/_docs/solutions/graphql.md
+++ b/_docs/solutions/graphql.md
@@ -11,6 +11,8 @@ redirect_from:
hide-disclaimer: true
---
+
+
## WireMock Extension
There is a [GraphQL extension for WireMock](https://github.com/wiremock/wiremock-graphql-extension)
diff --git a/_docs/solutions/groovy.md b/_docs/solutions/groovy.md
index 400f251c..11d3134d 100644
--- a/_docs/solutions/groovy.md
+++ b/_docs/solutions/groovy.md
@@ -6,6 +6,8 @@ description: "Additional solutions for WireMock when using Groovy"
logo: /images/logos/technology/groovy.svg
---
+
+
## DSL Bindings
There is a [Groovy DSL binding library](https://github.com/tomjankes/wiremock-groovy)
diff --git a/_docs/solutions/jvm.md b/_docs/solutions/jvm.md
index ff6c06d9..d647848b 100644
--- a/_docs/solutions/jvm.md
+++ b/_docs/solutions/jvm.md
@@ -7,6 +7,8 @@ logo: /images/logos/technology/java.svg
hide-disclaimer: true
---
+
+
WireMock was originally created for Java development,
and there are plenty of solutions when developing applications powered by the Java Virtual Machine.
@@ -64,5 +66,6 @@ sorted by alphabet:
- [Clojure](https://docs.google.com/document/d/1TQccT9Bk-o2lvRVN8_mMaGttaOnwbYFLkn0DsmwGIOA/edit#heading=h.gvb3rxc1ab9p)
- [Groovy](../groovy)
- [Kotlin](../kotlin)
+- [Pact](../pact)
- [Scala](https://docs.google.com/document/d/1TQccT9Bk-o2lvRVN8_mMaGttaOnwbYFLkn0DsmwGIOA/edit#heading=h.gvb3rxc1ab9p)
- [Spring Boot](../spring-boot)
diff --git a/_docs/solutions/kotlin.md b/_docs/solutions/kotlin.md
index 322b90d8..1fdb38bb 100644
--- a/_docs/solutions/kotlin.md
+++ b/_docs/solutions/kotlin.md
@@ -6,6 +6,7 @@ description: Additional solutions for WireMock when using Kotlin
logo: /images/logos/technology/kotlin.svg
---
+
## Kotlin DSL Bindings
diff --git a/_docs/solutions/kubernetes.md b/_docs/solutions/kubernetes.md
index 5e22728b..47bb695a 100644
--- a/_docs/solutions/kubernetes.md
+++ b/_docs/solutions/kubernetes.md
@@ -7,6 +7,8 @@ logo: /images/logos/technology/kubernetes.svg
hide-disclaimer: true
---
+
+
## WireMock Helm Chart (Experimental)
There is an [experimental Helm Chart](https://wiremock.github.io/helm-charts/) for WireMock.
diff --git a/_docs/solutions/nodejs.md b/_docs/solutions/nodejs.md
index 47f9f867..1d8a6c9b 100644
--- a/_docs/solutions/nodejs.md
+++ b/_docs/solutions/nodejs.md
@@ -6,6 +6,8 @@ description: Additional solutions for WireMock when using Node.js
logo: /images/logos/technology/nodejs.svg
---
+
+
## WireMock Captain
WireMock Captain provides an easy interface for testing HTTP-based APIs.
@@ -61,3 +63,11 @@ console.log(stubMappings);
await wireMock.global.shutdown();
```
+
+## WireMock NPM package
+
+The WireMock NPM package is the WireMock standalone JAR packaged inside an NPM package. It has the exact same features as WireMock standalone and uses the same versioning.
+
+The main benefit of packaging it inside an NPM package is that the user will only need access to an NPM registry to use it. This is often the situation when working behind firewalls in organizations.
+
+- [GitHUb Repository](https://github.com/wiremock/wiremock-npm)
diff --git a/_docs/solutions/pact.md b/_docs/solutions/pact.md
new file mode 100644
index 00000000..9ef7935d
--- /dev/null
+++ b/_docs/solutions/pact.md
@@ -0,0 +1,176 @@
+---
+layout: solution
+title: "Using WireMock with Pact"
+meta_title: Running WireMock with Pact | WireMock
+description: The recorded invocations on WireMock can be used to generate the JSON files that are needed to publish contracts to the Pactflow broker.
+redirect_from:
+- "/docs/pact.html"
+---
+
+## WireMock Pact
+
+WireMock Pact will get the requests from [WireMock](https://github.com/wiremock/wiremock/) and create [Pact JSON](https://docs.pact.io/) files on the filesystem. The Pact JSON can be published to a [Pactflow broker](https://test.pactflow.io/).
+
+WireMock Pact contains:
+
+- `wiremock-pact-lib` - *A library that can transform WireMock [ServeEvent](https://github.com/wiremock/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/stubbing/ServeEvent.java):s to Pact JSON.*
+- `wiremock-pact-extension-junit5` - *A WireMock extension, and JUnit 5, that is intended to ease usage of the library.*
+- `wiremock-pact-example-springboot-app` - *A SpringBoot application that shows how it can be used.*
+
+WireMock Pact is released to [Maven Central](https://central.sonatype.com/search?q=se.bjurr.wiremockpact). And [available on GitHub](https://github.com/wiremock/wiremock-pact).
+
+## Usage - Junit 5
+
+The extension is both a WireMock extension and a JUnit 5 extension. When using [`wiremock-spring-boot`](https://wiremock.org/docs/solutions/spring-boot/) it can be configured like this in a base class of your tests:
+
+```java
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import com.maciejwalkowiak.wiremock.spring.ConfigureWireMock;
+import com.maciejwalkowiak.wiremock.spring.EnableWireMock;
+import com.maciejwalkowiak.wiremock.spring.WireMockConfigurationCustomizer;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import se.bjurr.wiremockpact.wiremockpactextensionjunit5.WireMockPactExtension;
+import se.bjurr.wiremockpact.wiremockpactlib.api.WireMockPactConfig;
+
+@EnableWireMock({
+ @ConfigureWireMock(
+ name = "wiremock-service-name",
+ property = "wiremock.server.url",
+ stubLocation = "wiremock",
+ configurationCustomizers = {WireMockPactBaseTest.class})
+})
+public class WireMockPactBaseTest implements WireMockConfigurationCustomizer {
+ @RegisterExtension
+ static WireMockPactExtension WIREMOCK_PACT_EXTENSION =
+ new WireMockPactExtension(
+ WireMockPactConfig.builder() //
+ .setConsumerDefaultValue("WireMockPactExample") //
+ .setProviderDefaultValue("UnknownProvider") //
+ .setPactJsonFolder("src/test/resources/pact-json"));
+
+ @Override
+ public void customize(
+ final WireMockConfiguration configuration, final ConfigureWireMock options) {
+ configuration.extensions(WIREMOCK_PACT_EXTENSION);
+ }
+}
+```
+
+### Usage - Library
+
+It can be used as a library.
+
+```java
+public class ExampleTest {
+ private static WireMockServer server;
+ private static WireMockPactApi wireMockPactApi;
+
+ @BeforeAll
+ public static void beforeEach() throws IOException {
+ server = new WireMockServer();
+ server.start();
+
+ stubFor(
+ post(anyUrl())
+ .willReturn(
+ ok()
+ .withHeader("content-type", "application/json")
+ .withBody("""
+ {"a":"b"}
+ """))
+ .withMetadata(
+ new Metadata(
+ Map.of(
+ WireMockPactMetadata.METADATA_ATTR,
+ new WireMockPactMetadata()
+ .setProvider("some-specific-provider")))));
+
+ wireMockPactApi =
+ WireMockPactApi.create(
+ new WireMockPactConfig()
+ .setConsumerDefaultValue("my-service")
+ .setProviderDefaultValue("unknown-service")
+ .setPactJsonFolder("the/pact-json/folder"));
+ wireMockPactApi.clearAllSaved();
+ }
+
+ @Test
+ public void testInvoke() {
+ // Do stuff that invokes WireMock...
+ }
+
+ @AfterAll
+ public static void after() {
+ for (final ServeEvent serveEvent : server.getAllServeEvents()) {
+ wireMockPactApi.addServeEvent(serveEvent);
+ }
+ // Save pact-json to folder given in WireMockPactApi
+ wireMockPactApi.saveAll();
+ server.stop();
+ }
+}
+```
+
+### Mappings metadata - Set provider in mapping
+
+You can adjust any mappings file like this to specify the provider of a mapping in its [metadata](https://github.com/wiremock/spec/blob/main/wiremock/wiremock-admin-api/schemas/stub-mapping.yaml) field:
+
+```diff
+{
+ "id" : "d68fb4e2-48ed-40d2-bc73-0a18f54f3ece",
+ "request" : {
+ "urlPattern" : "/animals/1",
+ "method" : "GET"
+ },
+ "response" : {
+ "status" : 202
+ },
+ "uuid" : "d68fb4e2-48ed-40d2-bc73-0a18f54f3ece",
++ "metadata": {
++ "wireMockPactSettings": {
++ "provider":"some-other-system"
++ }
++ }
+}
+```
+
+Or programmatically:
+
+```java
+ stubFor(
+ post(anyUrl())
+ .withMetadata(
+ new Metadata(
+ Map.of(
+ WireMockPactMetadata.METADATA_ATTR,
+ new WireMockPactMetadata()
+ .setProvider("some-specific-provider")))));
+```
+
+### Publishing to Pact broker
+
+Pact has a [CLI tool](https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts) that can be used for publishing the contracts. But it requires Ruby or Docker. If you don't have that, perhaps `curl` is an option. There is [a shell script here](https://github.com/tomasbjerre/pactflow-publish-sh) that can also be used [via NPM](https://www.npmjs.com/package/pactflow-publish-sh).
+
+You may want to use something like [git-changelog-command-line](https://github.com/tomasbjerre/git-changelog-command-line) to get the next version.
+
+There is a test-server at https://test.pactflow.io/ that can be accessed with user `dXfltyFMgNOFZAxr8io9wJ37iUpY42M` and password `O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`.
+
+```sh
+current_version=$(npx git-changelog-command-line \
+ --patch-version-pattern "^fix.*" \
+ --print-current-version)
+git_hash=`git rev-parse --short HEAD`
+participant_version_number="$current_version-$git_hash"
+
+npx pactflow-publish-sh \
+ --username=dXfltyFMgNOFZAxr8io9wJ37iUpY42M \
+ --password=O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1 \
+ --pactflow-broker-url=https://test.pactflow.io/contracts/publish \
+ --build-url=http://whatever/ \
+ --pact-json-folder=wiremock-pact-example-springboot-app/src/test/resources/pact-json \
+ --participant-version-number=$participant_version_number
+```
+
+## Useful pages
+
+- [WireMock on Java and JVM](../jvm) - Most of JVM generic solutions are applicable to Spring Boot development too
diff --git a/_docs/solutions/python.md b/_docs/solutions/python.md
index 8f4f2f93..a57ce433 100644
--- a/_docs/solutions/python.md
+++ b/_docs/solutions/python.md
@@ -7,6 +7,7 @@ logo: /images/logos/technology/python.svg
hide-disclaimer: true
---
+
## Python WireMock
diff --git a/_docs/solutions/quarkus.md b/_docs/solutions/quarkus.md
index eb642a3d..b4360e88 100644
--- a/_docs/solutions/quarkus.md
+++ b/_docs/solutions/quarkus.md
@@ -6,6 +6,7 @@ description: "Additional solutions for WireMock when developing with Quarkus"
logo: /images/logos/technology/quarkus.svg
---
+
## WireMock Extension for Quarkus
diff --git a/_docs/solutions/rust.md b/_docs/solutions/rust.md
index 150db781..a2bceffc 100644
--- a/_docs/solutions/rust.md
+++ b/_docs/solutions/rust.md
@@ -6,6 +6,8 @@ description: "Additional solutions for WireMock when using Rust"
logo: /images/logos/technology/rust.svg
---
+
+
## wiremock-rs. Server implementation in Rust
[LukeMathWalker/wiremock-rs](https://github.com/LukeMathWalker/wiremock-rs) is an API Mock Server implementation in Rust.
diff --git a/_docs/solutions/spring-boot.md b/_docs/solutions/spring-boot.md
index bb27b622..9056da9c 100644
--- a/_docs/solutions/spring-boot.md
+++ b/_docs/solutions/spring-boot.md
@@ -9,6 +9,10 @@ redirect_from:
logo: /images/logos/technology/spring.svg
---
+
+
+
+
## WireMock Spring Boot
[WireMock Spring Boot](https://github.com/maciejwalkowiak/wiremock-spring-boot)
@@ -37,14 +41,14 @@ class TodoControllerTests {
void aTest() {
// returns a URL to WireMockServer instance
env.getProperty("user-client.url");
- wiremock.stubFor(stubFor(get("/todolist").willReturn(aResponse()
+ wiremock.stubFor(get("/todolist").willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody("""
[
{ "id": 1, "userId": 1, "title": "my todo" },
]
""")
- )));
+ ));
}
}
```
@@ -59,6 +63,14 @@ See [Spring Cloud Contract WireMock](https://docs.spring.io/spring-cloud-contrac
The article [Faking OAuth2 Single Sign-on in Spring](https://engineering.pivotal.io/post/faking_oauth_sso/)
from Pivotal's blog shows how WireMock can be used to test Spring apps that use 3rd party OAuth2 login.
+
+## Jetty version issues when running WireMock and Spring together.
+
+WireMock's main artifact is built on Jetty 11, largely so that Java 11 support can be maintained. However, many Spring applications depend on Jetty 12 and the presence of both on the classpath causes WireMock to fail with a `ClassNotFoundException` or `NoClassDefFoundError` for Servlet API classes thrown during startup.
+
+To rectify this, WireMock now has a dedicated Jetty 12 artifact which can be added to your project's classpath. See the [Jetty 12 page](../../jetty-12/) for details.
+
+
## Useful pages
-- [WireMock on Java and JVM](../solutions/jvm) - Most of JVM generic solutions are applicable to Spring Boot development too
+- [WireMock on Java and JVM](../jvm) - Most of JVM generic solutions are applicable to Spring Boot development too
diff --git a/_docs/solutions/testcontainers.md b/_docs/solutions/testcontainers.md
index c1d5f83b..0925f66d 100644
--- a/_docs/solutions/testcontainers.md
+++ b/_docs/solutions/testcontainers.md
@@ -12,6 +12,8 @@ redirect_from:
- "/testcontainers/"
---
+
+
The WireMock community provides modules for [Testcontainers](https://testcontainers.com/).
They allow provisioning the WireMock server as a standalone container within your tests,
based on [WireMock Docker](https://github.com/wiremock/wiremock-docker).
diff --git a/_docs/standalone.md b/_docs/standalone.md
index 5c731e2b..b539afcb 100644
--- a/_docs/standalone.md
+++ b/_docs/standalone.md
@@ -10,6 +10,8 @@ description: >
We provide the JAR file and Docker image distributions for it.
---
+
+
WireMock can run as a standalone service,
configured via the Java API, JSON over HTTP or JSON files.
We provide the JAR file and Docker image distributions for it.
diff --git a/_docs/standalone/admin-api-reference.md b/_docs/standalone/admin-api-reference.md
index 8476f05e..e0ee326c 100644
--- a/_docs/standalone/admin-api-reference.md
+++ b/_docs/standalone/admin-api-reference.md
@@ -10,6 +10,8 @@ redirect_from:
- "/docs/api/"
---
+
+
The WireMock admin API is described in [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md). The spec file plus an instance of Swagger UI can be accessed from a running WireMock instance under `/__admin/docs/`, e.g. `http://localhost:8080/__admin/docs/`.
Below is the full API reference:
diff --git a/_docs/standalone/administration.md b/_docs/standalone/administration.md
index ff573545..2197f2c1 100644
--- a/_docs/standalone/administration.md
+++ b/_docs/standalone/administration.md
@@ -5,12 +5,14 @@ meta_title: Administration API in WireMock Standalone | WireMock
description: Provides tips on managing standalone WireMock servers
---
+
+
WireMock Standalone offers the REST API for administration, troubleshooting and analysis purposes.
You can find the key use-cases and the full specification below.
## Fetching all of your stub mappings (and checking WireMock is working)
-A GET request to the root admin URL e.g `http://localhost:8080/__admin`
+A GET request to the mappings admin URL e.g `http://localhost:8080/__admin/mappings`
will return all currently registered stub mappings.
This is a useful way to check whether WireMock is running on the host and port you expect.
diff --git a/_docs/standalone/docker.md b/_docs/standalone/docker.md
index 2ebc00b4..1d6eee86 100644
--- a/_docs/standalone/docker.md
+++ b/_docs/standalone/docker.md
@@ -9,6 +9,8 @@ redirect_from:
- "/docs/docker/"
---
+
+
From version 2.31.0 WireMock has an [official Docker image](https://hub.docker.com/r/wiremock/wiremock).
## Getting started
@@ -123,6 +125,7 @@ services:
image: "wiremock/wiremock:latest"
container_name: my_wiremock
volumes:
+ - ./extensions:/var/wiremock/extensions
- ./__files:/home/wiremock/__files
- ./mappings:/home/wiremock/mappings
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]
diff --git a/_docs/standalone/java-jar.md b/_docs/standalone/java-jar.md
index fd949cff..c095e3c6 100644
--- a/_docs/standalone/java-jar.md
+++ b/_docs/standalone/java-jar.md
@@ -11,10 +11,12 @@ redirect_from:
description: The WireMock server can be run in its own process, and configured via the Java API, JSON over HTTP or JSON files.
---
+
+
The WireMock server can be run in its own process, and configured via
the Java API, JSON over HTTP or JSON files.
-Once you have [downloaded the standalone JAR](../../download) you can run it simply by doing this:
+Once you have [downloaded the standalone JAR](../../download-and-installation/) you can run it simply by doing this:
```bash
$ java -jar wiremock-standalone-{{ site.wiremock_version }}.jar
@@ -28,6 +30,10 @@ The following can optionally be specified on the command line:
`--disable-http`: Disable the HTTP listener, option available only if HTTPS is enabled.
+`--disable-http2-plain`: Disable HTTP/2 over plain text (HTTP).
+
+`--disable-http2-tls`: Disable HTTP/2 over TLS (HTTPS).
+
`--https-port`: If specified, enables HTTPS on the supplied port.
Note: When you specify this parameter, WireMock will still, additionally, bind to an HTTP port (8080 by default). So when running multiple WireMock servers you will also need to specify the `--port` parameter in order to avoid conflicts.
@@ -94,6 +100,10 @@ internet access via an opaque proxy). e.g.
`--proxy-via webproxy.mycorp.com:8080`. Also supports proxy authentication,
e.g. `--proxy-via http://username:password@webproxy.mycorp.com:8080/`.
+`--supported-proxy-encodings`: The set of acceptable compression methods represented in the `accept-encoding` request header
+sent by WireMock when proxying or recording expressed as a comma-separated list e.g `gzip,deflate`. This is particularly useful if you want to avoid recording e.g. brotli compresssed responses
+that can't then be viewed in the request log or served with a different compression scheme on playback, which can be achieved via `--supported-proxy-encodings=identity`.
+
`--enable-browser-proxying`: Run as a browser proxy. See
[Running as a browser proxy](../../proxying#running-as-a-browser-proxy).
@@ -212,7 +222,7 @@ You can create a stub mapping by posting to WireMock's HTTP API:
```bash
$ curl -X POST \
--data '{ "request": { "url": "/get/this", "method": "GET" }, "response": { "status": 200, "body": "Here it is!\n" }}' \
-http://localhost:8080/__admin/mappings/new
+http://localhost:8080/__admin/mappings
```
And then fetch it back:
diff --git a/_docs/stateful-behaviour.md b/_docs/stateful-behaviour.md
index d4a5838a..32ef3739 100644
--- a/_docs/stateful-behaviour.md
+++ b/_docs/stateful-behaviour.md
@@ -6,6 +6,8 @@ redirect_from: "/stateful-behaviour.html"
description: Most web services tend to have some state, which changes as you and others interact with it.
---
+
+
**Most web services tend to have some state, which changes as you and
others interact with it. So it's pretty useful to be able to simulate
this when you've swapped a real service for a test double.**
diff --git a/_docs/stubbing.md b/_docs/stubbing.md
index eb72e0c3..f323c344 100644
--- a/_docs/stubbing.md
+++ b/_docs/stubbing.md
@@ -7,6 +7,8 @@ redirect_from: "/stubbing.html"
description: A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. These are described in detail in Request Matching.
---
+
+
A core feature of WireMock [API mocking]({{ '/' | absolute_url }}) is the ability to return canned HTTP
responses for requests matching criteria. These are described in detail in [Request Matching](../request-matching/).
@@ -133,8 +135,31 @@ stubFor(put("/status-only")
More DSL examples [can be found here](https://github.com/tomakehurst/wiremock/tree/master/src/test/java/ignored/Examples.java#374).
HTTP methods currently supported are:
-`GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS`. You can specify `ANY` if
-you want the stub mapping to match on any request method.
+`GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS, GET_OR_HEAD`. You can specify `ANY` if
+you want the stub mapping to match on any request method. `GET_OR_HEAD` is a special
+method that could be used to match incoming requests for both `GET` or `HEAD` http
+method. A ```HEAD``` request will result in the same behaviour expected from a web server i.e.
+the ```Content-Type``` and ```Content-Length``` headers will be emitted but no response body.
+A detailed guide about various HTTP methods can be found [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
+```GET_OR_HEAD``` can be used the following way
+
+{% codetabs %}
+
+{% codetab Java %}
+
+```java
+@Test
+public void getOrHeadDemo() {
+ stubFor(getOrHead(urlEqualTo("/get-or-head-test"))
+ .willReturn(okJson("{\"key\": \"value\"}")));
+
+ assertThat(testClient.get("/get-or-head-test").statusCode(), is(200));
+}
+```
+
+{% endcodetab %}
+
+{% endcodetabs %}
### Setting the response status message
@@ -517,15 +542,29 @@ This feature is also available with the standard JAR. To use it, define the file
## Removing stubs
-Stub mappings can be deleted via the Java API as follows:
+Stub mappings can be deleted via the Java API, either by passing the stub object or the stub ID:
```java
-StubMapping stubMapping = stubFor(get(urlEqualTo("/delete-me"))
- .willReturn(aResponse().withStatus(200)));
-
-// Do things with the stub
+UUID stubId = UUID.randomUUID();
+StubMapping stubMapping = stubFor(get("/delete-me")
+ .withId(stubId)
+ .willReturn(ok()));
removeStub(stubMapping);
+
+// or
+
+removeStub(stubId);
+```
+
+Where stubs have metadata set on them this can be used to remove them:
+
+```java
+stubFor(get("/delete-me")
+ .withMetadata(metadata().attr("tag", "payments"))
+ .willReturn(ok()));
+
+removeStubsByMetadata(matchingJsonPath("$.tag", equalTo("payments")));
```
They can be deleted via the HTTP API by issuing a `DELETE` to `http://