Skip to content

arbindo/mimock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Mimock

logo

Setup mocks for REST endpoints


Overview

Mimock is a utility to setup mocks for REST API endpoints to mimic the response of the actual endpoints. This tool will be helpful for testing UI applications locally or in CI/CD pipelines. Mimock follows an interceptor-based pattern which enables the users to setup and use the mocks in real time without any need for re-deployment.

This project is geared towards both open-source and enterprise applications that offer REST API based solutions. Mimock functions as a faster, easier to set up and automate testing utility tool that can be easily integrated into the deliverables pipeline of various projects.

Mimock is published under the open-source Apache-2.0 license.

mock-dashboard

Features

Some of the key features offered by the Mimock are as follows

  • Intuitive UI: Provides an intuitive UI which lets anyone manage mocks without any coding experience.
  • No Re-Deployment: Mocks can be added in real time, and no application restart is required. Mocks are created and updated on-the-go, which ensures faster development and turn-around time.
  • Access Management: The platform follows a role-based user management model and the admin can assign roles to the users to setup and restrict their access.
  • Support for multiple response types: Mimock supports both text and binary response for mocks. So if you want a mock to serve a normal JSON response or a JPEG image file or a PDF document, it can be done in a jiffy.

Download Options

JAR with start-up script

Mimock is a Java based application, hence it requires Java 8+ to run the application.

Docker image

There are two variants of docker images available for mimock

  • complete version [recommended]

The docker image with the latest tag includes all the required artifacts to use mimock with no additional setup. The container can be directly started to use the application and this variant is best suited for local developments workflows.

docker pull mimock/mimock:latest

docker run --name mimock -d -p <destination port>:8080 mimock/mimock:latest

# Once the container is ready, mimock will be available on https://localhost:<destination port>
  • slim version

The slim variant includes only the jar file of the application. The database and keystore setup need to be done by the user, and the required environment variables must be passed to run the container. This image variant is intended for a highly customized setup

docker pull mimock/mimock:slim

# Ensure that PostgreSQL Database is setup before starting the container
# The Dockerfile.pg has a minimal setup for spinning up a DB container

docker run --name mimock-slim -d -p <destination port>:8080 \
 -e MIMOCK_LOG_LEVEL=INFO \
 -e MIMOCK_KEYSTORE_ENABLE=false \
 -e MIMOCK_DB_SCHEMA=mimock_schema_dev \
 -e MIMOCK_DB_URL=jdbc:postgresql://mimock-db:5432/mimock_db \
 -e MIMOCK_DB_USER=mimock \
 -e MIMOCK_DB_PASSWORD=<db password> \
 -e MIMOCK_JWT_EXPIRY_DURATION=24h \
 -e MIMOCK_JWT_SECRET=<key with 32 characters> \
 -e MIMOCK_CORS_ORIGINS=http://localhost:3001 \
 -e MIMOCK_CORS_METHODS=GET,POST,PUT,DELETE,OPTIONS \
 -e MIMOCK_CORS_ALLOWED_HEADERS=Authorization,Content-Type,X-Requested-With,Accept,X-XSRF-TOKEN \
 -e MIMOCK_CORS_EXPOSED_HEADERS=Cache-Control,Content-Language,Content-Length,Content-Type,Content-Disposition,Expires,Last-Modified,Pragma \
 mimock/mimock:slim
 
 # Once the container is ready, mimock will be available on http://localhost:<destination port>

Docker setup using docker-compose file

If docker-compose is preferred, then the docker-compose.yml file includes the services to setup the DB and the app container.

docker-compose up -d

# Destination port can be updated to the desired value if another service is running on port 8080
#     ports:
#      - "<desired port>:8080"

# Mimock will be available on https://localhost:8080

How to login?

Mimock follows a role based user management system and the services can be accessed only by an authenticated user. To handle initial application setup, a default ADMIN user is created, which can be used to create other users.

Username Password Role
mimock_admin password ADMIN

More details about user roles are available here

It is recommended to create a new ADMIN user and then use that to disable the default mimock_admin user

Setup Instructions

Requirements
Java 8+
PostgreSQL 13+

Run mimock locally

Ensure PostgreSQL is setup with a user and a schema for mimock to automatically complete the required table setup.

mimock.properties - The bundle includes the properties file with the required configuration to start mimock. Check the config file and ensure the custom config items are properly setup.

Download the platform-specific bundle from [above]. (#download-options) and run the following command to start mimock.

java -jar mimock.jar --spring.config.location=./mimock.properties

Run mimock within a k8s cluster

The mimock-k8s directory has a set of kubernetes manifest files to give an idea of how to setup mimock within a k8s cluster.

Run mimock in a CI pipeline

A demo project is available on Github, which simulates a scenario of running an UI automation test by setting up mocks using mimock. The project is a simple web application which relies on two endpoints, one for a json response and the other for a webp image. The mocks for both the endpoints are setup within the workflow and the UI automation script captures the results as snapshots, and publishes the same to the workflow summary

Support

  • Use issues to report bugs or for requesting new features
  • Follow discussions to get community updates
  • Contributors are most welcome. Read the guidelines for more information