A language agnostic HTTP mock server for quick stub testing

MockItOut

Build Status Coverage Status Go Report Card Docker Pulls

Test external services faster and better with an HTTP stub server.

MockItOut is a simple to use HTTP stub server. With a small YAML configuration you can quickly create test end-points for HTTP APIs. Unlike other mock servers this project is language agnostic and easy to setup.

Key Features

  • HTTP response stubbing, maching URI with pre-canned body, header and status code replies.
  • Logging request data for troubleshooting and diagnostics.
  • Runs as a docker container or as a local binary.
  • Callable as an external service for unit or functional tests.
  • Simple YAML configuration.

Running MockItOut

To run MockItOut is simple, just run the following commands.

$ docker run -p 443:8443 madflojo/mockitout:latest

This will start the service with our example mock file. To test it you can use curl.

$ curl -vk https://localhost/hi

Specifying your own mocks file

To add your own mocks file, simply use volume mounts with the docker run command.

$ docker run -p 443:8443 -v stubs/:stubs -e MOCKS_FILE="stubs/mystubs.yml" madflojo/mockitout:latest

Mocks Configuration File

To define end-points create a YAML file with the following format.

routes:
  hello:
    path: "/hi"
    response_headers:
      "content-type": "application/json"
      "server": "MockItOut"
    # Multi-line values can be created like this
    body: | 
      {
        "greeting": "Hello",
        "name": "World"
      }
  deny:
    path: "/no"
    response_headers:
      "content-type": "application/json"
      "server": "MockItOut"
    body: |
      {"status": false}
    return_code: 403
  names:
    path: "/names/*"
    response_headers:
      "content-type": "application/json"
      "server": "WalkItOut"
    return_code: 200
    body: |
      {
        "1": {
          "name": "DJ Unk"
        },
        "2": {
          "name": "Andre 3000"
        },
        "3": {
          "name": "Jim Jones"
        }
      }

Configuring with Environment Variables

MockItOut is controlled via environment variables. The below is a list of all environment variables available and what they control.

  • DEBUG can be true or false. This will enable or disable debug logs. Default is false.
  • DISABLE_LOGGING can be true or false. This will disable all logging. Default is false.
  • ENABLE_TLS can be true or false. This will have the server use HTTPS by default. Default is true.
  • LISTEN_ADDR defines the server listener address and port. Default is 0.0.0.0:8443
  • CERT_FILE defines the location of the TLS Certificate file.
  • KEY_FILE defines the location of the TLS Certificate Key file.
  • GEN_CERTS can be true or false. This will enable the server to create temporary testing certs on boot. Default is true.
  • MOCKS_FILE defines the location of the mocks configuration file.

Contributing

Thank you for your interest in helping develop MockItOut. The time, skills, and perspectives you contribute to this project are valued.

Please reference our Contributing Guide for details.

License

Apache License 2.0

Owner
Benjamin Cane
Thoughts and opinions are my own.
Benjamin Cane
Similar Resources

📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

mock 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs. About mock Mock allows you to spin up a local http server based of a .m

May 6, 2022

A tool that integrates SQL, HTTP,interface,Redis mock

Mockit 目标:将mock变得简单,让代码维护变得容易 分支介绍 main 主分支,覆盖了单元测试 light 轻分支,去除了单元测试,简化了依赖项,方便其他团队使用 常见Mock难点 不同中间件,mock库设计模式不一致,学习代价高,差异化明显 mock方案强依赖服务端,无法灵活解耦 单元测试

Sep 22, 2022

Create your own mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Create your own blazing fast mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Apple Push Notification service (APNs) mock server

APNs Mock Server Server

Dec 8, 2022

Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go.

BDCS Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go. Features Security Authorization works using UbiSer

Nov 10, 2021

A simple mock server configurable via JSON, built using GoLang.

A simple mock server configurable via JSON, built using GoLang.

GoMock Server A simple mock server configurable via JSON, built using GoLang. How To A file name endpoint.json must be placed in the context root, wit

Nov 19, 2022

Mockserver - Super slim & blazing fast mock server to replace the Java/NPM counterpart mockserver

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to ma

Jan 30, 2022

Grpcmock - Mock grpc server with golang

grpcmock Mock gRPC server. Inspired by Prism. Add example responses to your prot

May 8, 2022
Comments
  • Adding some additional logging

    Adding some additional logging

    Description

    Just adding some additional logging, like logging the request payload and content length.

    Type of change

    Please delete options that are not relevant.

    • [x] Tech Debt or other code clean up

    Checklist:

    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, ensuring GoDoc readability and clarity in hard-to-understand areas
    • [x] I have made corresponding changes to documentation
    • [x] I have added tests that ensure my fix is effective or that my feature works
    • [x] Any dependent changes have been merged and published in downstream modules

    If checklist items are unchecked please explain.

  • Adding Wildcard support

    Adding Wildcard support

    This pull request adds support for wildcards. This is using the native httprouter wildcard pattern however, there is some fix up in the backend so that users don't have to specify a parameter name.

CLI tool to mock TCP connections. You can use it with Detox, Cypress or any other framework to automatically mock your backend or database.

Falso It is a CLI that allows you to mock requests/responses between you and any server without any configuration or previous knowledge about how it w

Sep 23, 2022
Mock-the-fck - Mock exercise for human

Mock the fck Originally, Mockery-example Example case for mockery issue #128 fil

Jan 21, 2022
mock server to aid testing the jaguar-java client API

stripe-mock stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's test mode to make test suites

Dec 24, 2021
Quick and Easy server testing/validation
Quick and Easy server testing/validation

Goss - Quick and Easy server validation Goss in 45 seconds Note: For an even faster way of doing this, see: autoadd Note: For testing docker container

Oct 7, 2022
A go server which will respond with data to mock a server!

Mocker A go program which will respond with data to mock a server; mainly useful while developing a frontend application, whose backend is not running

Jan 5, 2023
Merge Mock - testing tool for the Ethereum Merge

MergeMock Experimental debug tooling, mocking the execution engine and consensus node for testing. work in progress Quick Start To get started, build

Oct 21, 2022
A mock of Go's net package for unit/integration testing

netmock: Simulate Go network connections netmock is a Go package for simulating net connections, including delays and disconnects. This is work in pro

Oct 27, 2021
Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022
Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022
A basic lightweight HTTP client for Go with included mock features.

A basic lightweight HTTP client for Go with included mock features. Features Support almost all http method like G

May 2, 2022