Skip to content

Releases

v0.9.0

Choose a tag to compare

@FalkWoldmann FalkWoldmann released this 20 Oct 21:12
d6fe1cc

The crate was upgraded to the Rust 2024 edition. The minimum supported Rust version
remains 1.88.

Breaking changes

  • server::matchers is now crate-private
    (#312). Its matcher, comparator and reader
    types are implementation details rather than a supported extension API; there is no
    replacement public path. Custom predicates remain possible with When::is_true.
  • The body helpers is_blank, contains_str, contains_slice and contains_vec
    were removed (#246). Use
    request.body_string().contains(".."), which also works inside respond_with, or
    request.body_ref().windows(n).any(|w| w == b"..") with a non-empty needle, and
    When::body_includes when matching.
  • HttpMockRequest::query_params_map() was removed
    (#246). Collect query_params() instead:
    let params: HashMap<String, String> = request.query_params().into_iter().collect();
    keeps the last value for duplicate keys, as the removed method did. query_params() has
    returned Vec<(String, String)> since 0.8.2.
  • The MockExt trait was removed and Mock's public id field is now private
    (#285). Remove MockExt imports and
    replace direct mock.id field access with mock.id(). Mock::new(id, &server) is
    unchanged.
  • The mock server only accepts cleartext HTTP/2 connections (prior knowledge, as gRPC clients
    send it) when the http2 cargo feature is enabled
    (#297). Previously this worked without the
    feature. It fails at runtime, not at compile time: the client sees the connection closed
    after the preface and the server logs "invalid HTTP version parsed (found HTTP2 preface)".
    Enable http2 to keep serving such clients; standalone and the Docker image already
    include it. HTTPS via ALPN is unaffected, as h2 was already only offered with the feature
    enabled. The crate also no longer enables tokio/signal or hyper/http2 for other crates
    in the build, so a crate that relied on that has to enable them itself.
  • server::state::MockServerState and server::state::HttpMockStateManager are now
    crate-private (#289,
    #326). Neither could be used from outside
    the crate beyond constructing it; code using the MockServer API is unaffected.
  • The empty experimental Cargo feature was removed
    (#316). Remove it from your dependency's
    feature list; it did not enable any functionality.
  • The Docker image now uses a slim Debian runtime without the Rust toolchain or source tree
    (#202,
    1231c63). curl and wget are no
    longer installed, so healthchecks that call them need another probe: an httpGet probe
    against /__httpmock__/ping, or from inside the container
    bash -c 'exec 3<>/dev/tcp/127.0.0.1/5050'. The CA files are no longer in the image either;
    use certs/ca.pem from the repository or server::DEFAULT_CA_CERTIFICATE. The executable
    is now at /usr/local/bin/httpmock, with a compatibility symlink at
    /usr/local/cargo/bin/httpmock so existing absolute paths continue to work.
  • The tls-detect cargo feature was removed
    (#333). It only enabled an internal
    dependency that https already pulled in; remove it from your feature list.
  • Optional dependencies no longer double as cargo features: clap, colored, headers,
    hyper-rustls, if-addrs, rcgen, rustls, rustls-pki-types, serde_yaml,
    tokio-rustls and tracing-subscriber are enabled through the documented features only.
    Replace any of these names in your feature list with the feature that needs them, such as
    https or standalone.
  • RecordingRuleBuilder::config is now private
    (#322). Its type could only be used through
    type inference; configure recordings through the builder's methods.

Upgrading from 0.8

Most code needs no changes. Remove MockExt imports and use mock.id() to read a mock's
ID. Replace body().is_blank() with body_string().trim().is_empty() and
body().contains_str("x") with body_string().contains("x"). Replace query_params_map()
with query_params().into_iter().collect::<HashMap<_, _>>().

Direct imports from server::matchers must be removed; use the When API to configure
matchers instead.

Tests whose clients speak cleartext HTTP/2 to the mock server additionally need the http2
feature.

The methods deprecated since 0.8.0 (Mock::hits, hits_async, assert_hits,
assert_hits_async and When::matches) are still available and will be removed in 1.0.

Improvements

  • #326: Add HttpMockResponse::to_http_response()
    for converting to an HTTP response with a byte body. The method borrows the response and
    returns any conversion error.
  • #108: Mocks can be limited to a number of
    calls with Then::up_to_n_times, Mock::up_to_n_times or Mock::up_to_n_times_async,
    after which they stop matching requests. Static mock YAML files support the same limit as
    up_to_n_times under then. MockServer::reset(), which start() and connect() call,
    now also resets the call counters of static YAML mocks. (resolves
    #96)
    (thanks @wfchandler)
  • Async mock, forwarding, proxy and recording setup futures implement Send when their
    inputs do, allowing registration inside tokio::spawn
    (#325).
  • When, Then and the forwarding, proxy and recording rule builders are now Send and
    Sync (#322).
  • #297: httpmock's own dependency tree is about
    30% smaller (74 to 52 crates without default features, 86 to 64 with them), resolving
    #46
  • #333: async-trait and tls-detect are no
    longer dependencies. The server now tells TLS and plain HTTP connections apart by the first
    byte the client sends.
  • #275: Owned HTTP request and response
    conversions avoid unnecessary body clones.
  • #299: Static mock YAML files now support
    json_body and body_from_file (resolves issues
    #118 and
    #185)
  • #251: The default CA certificate and key are
    exposed for testing as server::DEFAULT_CA_CERTIFICATE and server::DEFAULT_CA_PRIVATE_KEY
    (https feature) (thanks @ErikMcClure)
  • #298: The case-sensitive body matching
    introduced in v0.8.0 is now documented

Bug fixes

  • HttpMockServerBuilder::build() returns an error instead of panicking when the directory
    of static mock files cannot be listed, and the YAML and file error messages were reworded
    (904fc03)
  • Two error messages of the admin API changed: static mocks now report "cannot be modified or
    deleted" and failed state operations "state operation failed: ...". Only clients that match
    on the response body of a failed request can notice
  • The http2 feature now also enables HTTP/2 in the HTTPS client, so remote, https and
    http2 compile together without remote-https
  • #229: The https feature builds correctly
    again (hyper-rustls/ring is enabled) (thanks @danieleades)
  • #242,
    #326: Server TLS falls back to ring when no
    rustls crypto provider is installed, instead of panicking when several providers are compiled
    in (thanks @danieleades)
  • #243: DELETE /recordings/:id now deletes
    recordings instead of proxy rules (thanks @danieleades)
  • #245: The configured history_limit is
    honored instead of a hardcoded cap (thanks @danieleades)
  • The *_prefix and *_suffix matchers no longer panic with a char-boundary error when
    building a mismatch report for a request value containing multi-byte UTF-8 characters
  • #315: Mismatch reports print request and mock
    values containing tab characters (e.g. TSV bodies) verbatim instead of re-aligning them into
    columns
  • #318: Recording::save and save_to no longer
    overwrite a recording saved under the same scenario name in the same second; the second file
    gets a counter suffix
    (<scenario>_<timestamp>_1.yaml)

Internal improvements and CI

Read more

v0.8.3

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 04 Feb 07:41

Minimum supported Rust version has been raised to 1.88.

The following PRs have been merged:

All changes between since the last release:
v0.8.2...v0.8.3

v0.8.2

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 17 Oct 04:04

This release includes bug fixes, documentation enhancements and new features, such as dynamic responders.

The following pull requests have been merged:

  • #178: "Expose proxy method to obtain the recorded yaml without saving to a file" (thanks @janeisklar)
  • #180: "Add missing query parameters in recordings"
  • #181: "Append Headers Instead of Inserting"
  • #182: "Add Dynamic Responses"
  • #184: "Use read_file in body_from_file"

v0.8.1

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 06 Oct 07:17
86ade61

This release includes bug fixes and documentation enhancements.

The following pull requests have been merged:

  • #179: "Use scheme of target url for forwarding"

v0.8.0

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 25 Sep 17:15

This release includes refactoring, dependency updates, and internal cleanups.
No breaking changes expected.

The minimum required Rust version has been increased to 1.82.

The following pull requests have been merged:

  • #172: "Update Rust edition to 2021" (thanks @FalkWoldmann)
  • #169: "Proxy HTTPS fix"
  • #167: "Replace log and env_logger with tracing and tracing-subscriber" (thanks @FalkWoldmann)
  • #166: "Remove unused code" (thanks @FalkWoldmann)
  • #163: "fix: issue 162, non localhost hosts match" (thanks @Thomblin)
  • #160: "Replace custom read_file with std::fs::read_to_string" (thanks @FalkWoldmann)
  • #158: "Improve async executor support"
  • #156: "Bump async-object-pool to replace async-std"
  • #153: "ci(deps): bump actions/checkout from 4 to 5"
  • #152: "Fix missing standalone routes"
  • #151: "Cleanup unused test functions"
  • #147: "ci(deps): bump codecov/codecov-action from 2 to 5"
  • #146: "cargo(deps): update thiserror requirement from 1 to 2"
  • #145: "ci(deps): bump actions/checkout from 2 to 4"
  • #144: "ci(deps): bump docker/build-push-action from 4 to 6
  • #141: "cargo(deps): update path-tree requirement from >=0.8.0, <0.8.1 to >=0.8.0, <0.8.4"
  • #140: "ci(deps): bump docker/login-action from 1 to 3"
  • #139: "ci(deps): bump withastro/action from 2 to 4"
  • #138: "Create dependabot.yml" (thanks @FalkWoldmann)
  • #136: "Replace async_std with tokio" (thanks @FalkWoldmann)

v0.8.0-alpha.1

v0.8.0-alpha.1 Pre-release
Pre-release

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 01 Sep 20:37

BREAKING CHANGES

Improvements

v0.7.0

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 05 Jan 23:28
  • BREAKING CHANGES:

  • Improvements:

    • The dependency tree has been significantly slimmed down when the remote feature is not enabled.
    • If the new remote feature is not enabled, httpmock no longer has a dependency on a real HTTP client.
      As a result, certain TLS issues previously reported by users
      should no longer arise.
  • This release also updates all dependencies to the most recent version.

  • The minimum Rust version has been bumped to 1.70.

v0.7.0-rc.1

v0.7.0-rc.1 Pre-release
Pre-release

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 15 Oct 19:28
78daf7e
  • BREAKING CHANGES:

  • Improvements:

    • The dependency tree has been significantly slimmed down when the remote feature is not enabled.
    • If the new remote feature is not enabled, httpmock no longer has a dependency on a real HTTP client.
      As a result, certain TLS issues previously reported by users
      should no longer arise.
  • This release also updates all dependencies to the most recent version.

  • The minimum Rust version has been bumped to 1.65 (and 1.70 for the remote and standalone features).

v0.6.8

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 05 Jul 19:59
  • This is a maintenance release that updates all dependencies to the most recent version.
  • Fixes some dependency issues with the Docker image.

v0.6.7

Choose a tag to compare

@alexliesenfeld alexliesenfeld released this 21 Nov 23:09

Version 0.6.7

  • This is a maintenance release that updates all dependencies to the most recent version.