Skip to content

momenton/mountebank-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Mountebank

Demo code for the usage of mountebank: http://www.mbtest.org/

Introduction

Mountebank is an open source tool that allows to run multi-protocol test doubles.

This demo will allow to stand up a simple application then record some tests and replay them with mountebank.

Read this article for instructions on how to use this repo with Mountebank: https://medium.com/p/9f252b7b4a7a/ (locally: article)

The goal of the article is to stand up an api and record some hits to its endpoints with Mountebank as a proxy, then shut down the api and hit the endpoints using Mountebank port and see how Mountebank has created an imposter for the original api.

Installing pre-requisites

Installing mountebank

$ wget --no-check-certificate https://s3.amazonaws.com/mountebank/v1.14/mountebank-v1.14.1-darwin-x64.tar.gz
  • Expand the downloaded file wherever you will be using it
$ tar -xvf mountebank-v1.14.1-darwin-x64.tar.gz
  • Navigate to the directory and execute the script
runnerdave-mac:mountebank-v1.14.1-darwin-x64 p766894$ ./mb
info: [mb:2525] mountebank v1.14.1 now taking orders - point your browser to http://localhost:2525 for help

Installing Stubby4J (optional)

$ java -jar stubby4j-6.0.1.jar -d hello-world-config.yml

Your endpoints are:

Installing Postman

You can install it as a chrome app, but they advice that this method will be deprecated in the near future, so it would be recommended to install natively.

With Postman you can create GET or POST requests to the endpoints describe below in this article, if you prefer not to use cURL.

For example, once you have the api from this repo running locally on port 8125, you can create a POST request like it is shown in this image:

POST request in Postman

Paste a JSON customer like the one shown and If you press the "SEND" button, you should see the following response:

POST response in Postman

Contents of the repository

running the app

  1. without installing nodeJS and using docker-compose

docker-compose up --build

This installs and exposes the two different applications described in the Contents section

  1. if you don't have/want to use docker and have nodeJS installed:
  • Start the form application:

    • Navigate to the ./form directory
    • run: node server.js
  • Start the api application:

    • Navigate to the ./api directory
    • run: node api.js

References

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.7%
  • HTML 9.6%
  • Dockerfile 2.7%