This service enables you to create and destroy mountebank hosts for use in your service testing.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
service-test
src
test
.flowconfig
.gitignore
.travis.yml
LICENSE
README.md
environment
package.json
serverless.yml
webpack.config.js
yarn.lock

README.md

Mountebank as a Service

This service enables you to create and destroy mountebank hosts for use in your testing. All mountebank instances are exposed to the public internet, so there are no VPC requirements. The tool is designed for use by developers from their workstations (interactively), as well as from CI servers. Interaction with MBAAS requires the use of a valid JWT.

Deploying to AWS

Deploying this to your own AWS account involves using serverless.com. Prior to running that deployment, however, you need to define some environment variables, as well as creating resources in your account:

  • IMAGE_ID: the AMI you wish to use for mountebank instances. The AMI must automatically start mountebank on boot.
  • SECURITY_GROUP_IDS: security groups you want to apply to the instances. Keep in mind that you will need at least 2525 open to your clients, plus the other ports you plan to use for imposters.
  • SUMO_URL: Optionally, the URL of the SumoLogic web hook you want to use for logging. You will also have logs in CloudWatch.
  • AUTHORIZER_ARN: The ARN of your custom authorizer, which ensures only your users are able to use the API.
  • AUTHORIZATION_URI: The URL of the service providing OAuth V2 tokens.
  • AUDIENCE: The audience used in authorization response headers.

Creating and deleting mountebank servers

The main command you will be using is one to create a server.

Create mountebank:

curl -H "Authorization: Bearer <your auth token>" https://<yourcname or ip address>/v1/servers -X POST

This will create a server for you and return the details of the server it created, including the id, the DNS name, and the public IP address. It also contains the URL you can use to terminate the instance when it is no longer needed.

Once you have a server to work with, use its API found at port 2525. For more information on how to use mountebank, see the mountebank website. We recommend using a localhost instance of mountebank for your script development. mountebank is distributed as an npm module, and can be started with the mb command.

You should delete the server when you are finished with it. These servers do cost a small amount of money in the form of the EC2 instance. However, the system will automatically shut down servers running longer than two hours.

Delete a mountebank server:

curl -H "Authorization: Bearer <your auth token>" <the self link returned by the POST operation> -X DELETE

Policies

  • Through the REST API, you will only be able to interact with servers created for the OAuth principal supplied in the request.
  • Instances are automatically removed after two hours. You should delete them when you are finished with them (say, when your service test run is complete).
  • A user may not have more than two servers active at any given time. Additional POSTs will receive a 422 error.
  • Attempts to create and destroy too many instances within a short timespan will result in 422 errors.

Contributing

Create a pull request.