Skip to main content

Mockintosh

GitHub Latest Release GitHub License Travis Docker Build Status Code Coverage (Codecov)

Quick Links

Documentation Website

YouTube Video Series

Bug Tracker

Slack

Stack Overflow

Faker API Reference

About

You've just found a new way of mocking microservices!

Control Plane

An example config that demonstrates the common features of Mockintosh:

services:
  - name: Mock for Service1
    hostname: localhost
    port: 8000
    managementRoot: __admin  # open http://localhost:8001/__admin it in browser to see the UI  
    endpoints:

      - path: "/"  # simplest mock

      - path: "/api/users/{{param}}"  # parameterized URLs
        response: "simple string response with {{param}} included"

      - path: /comprehensive-matching-and-response
        method: POST
        queryString:
          qName1: qValue  # will only match if query string parameter exists
          qName2: "{{regEx '\\d+'}}"  # will require numeric value
        headers:
          x-required-header: someval  # will cause only requests with specific header to work
        body:
          text: "{{regEx '.+'}}"  # will require non-empty POST body
        response: # the mocked response specification goes below
          status: 202
          body: "It worked"
          headers:
            x-response-header: "{{random.uuid4}}"  # a selection of random/dynamic functions is available
            x-query-string-value: "{{request.queryString.qName2}}"  # request parts can be referenced in response

Mockintosh is a service virtualization tool that's capable to generate mocks for RESTful APIs and communicate with message queues to either mimic asynchronous tasks or to simulate microservice architectures in a blink of an eye.

The state-of-the-art mocking capabilities of Mockintosh enables software development teams to work independently while building and maintaining a complicated microservice architecture.

Key features:

In this article we explain how and why Mockintosh was born as a new way of mocking microservices.

Quick Start

Install on MacOS

Install Mockintosh app on Mac using Homebrew package manager:

$ brew install up9inc/repo/mockintosh

Install on Windows

Download an installer from releases section and launch it. Follow the steps in wizard to install Mockintosh.

Install on Linux

Install Mockintosh Python package using pip (or pip3 on some machines):

$ pip install -U mockintosh

Use Demo Sample Config

Run following command to generate example.yaml file in the current directory:

$ mockintosh --sample-config example.yaml

then, run that config with Mockintosh:

$ mockintosh example.yaml

And open http://localhost:9999 in your web browser.

You can also issue some CURL requests against it:

curl -v http://localhost:8888/

curl -v http://localhost:8888/api/myURLParamValue123/action

curl -v "http://localhost:8888/someMoreFields?qName1=qValue&qName2=12345" -X POST -H"X-Required-Header: someval" --data "payload"

Command-line Arguments

The list of command-line arguments can be seen by running mockintosh --help.

If you don't want to listen all of the services in a configuration file then you can specify a list of service names (name is a string attribute you can set per service):

$ mockintosh example.yaml 'Mock for Service1' 'Mock for Service2'

Using --quiet and --verbose options the logging level can be changed.

Using --bind option the bind address for the mock server can be specified, e.g. mockintosh --bind 0.0.0.0

Using --enable-tags option the tags in the configuration file can be enabled in startup time, e.g. mockintosh --enable-tags first,second

OpenAPI Specification to Mockintosh Config Conversion (experimental)

Note: This feature is experimental. One-to-one transpilation of OAS documents is not guaranteed.

It could be a good kickstart if you have already an OpenAPI Specification for your API. Mockintosh is able to transpile an OpenAPI Specification to its own config format in two different ways:

CLI Option --convert

Using the --convert one can convert an OpenAPI Specification to Mockintosh config.

JSON output example:

$ wget https://petstore.swagger.io/v2/swagger.json
$ mockintosh swagger.json -c new_config.json json

YAML example:

$ mockintosh swagger.json -c new_config.yaml yaml

Automatic Conversion

If you start Mockintosh with a valid OpenAPI Specification file then it automatically detects that the input is an OpenAPI Specification file:

$ mockintosh swagger.json

and automatically starts itself from that file. Without producing any new files. So you can start to edit this file through the management UI without even restarting Mockintosh.

Build the Docs

Single-command from /docs to review docs locally:

docker run -p 8080:4000 -v $(pwd):/site bretfisher/jekyll-serve

Or manual:

Install Jekyll and Bundler:

$ gem install jekyll bundler

Install the gems:

$ cd docs/
$ bundle config set --local path 'vendor/bundle'
$ bundle install

Run the server:

$ bundle exec jekyll serve

Metadata

Release files for mockintosh 0.13.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mockintosh 0.13.17
File Size Uploaded Provenance
mockintosh-0.13.17.tar.gz 99.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mockintosh 0.13.17
File Interpreter ABI Platform
mockintosh-0.13.17-py3-none-any.whl Python 3 none any Details

Total release size: 210.1 kB

Release files / mockintosh-0.13.17.tar.gz

Download URL mockintosh-0.13.17.tar.gz
Size 99.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7ffbef0b08985cc9b74c8012408919c2d3313b1a0c820030a3418705e4cd7897
BLAKE2b-256 checksum
How to use checksums
6014d82ea1ef784cf879a002b623001ad5fd32410195862c025154e832938f40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

Release files / mockintosh-0.13.17-py3-none-any.whl

Download URL mockintosh-0.13.17-py3-none-any.whl
Size 110.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3809134a44cf435ceeb431b5a9056c89b82cc3c3d5bc38e6c87e94ad0d55cba
BLAKE2b-256 checksum
How to use checksums
65d6af2ec532d1f5fc88539f538823e335e176a873cb70129e7566436696a473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

Security for mockintosh 0.13.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page