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.
- 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.
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
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
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"
}
}
MockItOut is controlled via environment variables. The below is a list of all environment variables available and what they control.
DEBUG
can betrue
orfalse
. This will enable or disable debug logs. Default isfalse
.DISABLE_LOGGING
can betrue
orfalse
. This will disable all logging. Default isfalse
.ENABLE_TLS
can betrue
orfalse
. This will have the server use HTTPS by default. Default istrue
.LISTEN_ADDR
defines the server listener address and port. Default is0.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 betrue
orfalse
. This will enable the server to create temporary testing certs on boot. Default istrue
.MOCKS_FILE
defines the location of the mocks configuration file.
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.