Chapter 6. Programming mountebank

 

This chapter covers

  • Matching requests even when none of the standard predicates do the trick
  • Adding dynamic data to mountebank responses
  • Making network calls to create a stub response
  • Securing mountebank against unwanted remote execution
  • Debugging your scripts within mountebank

Most developers have the experience of a tool or framework that makes solving a problem harder than it should be or outright impossible. A primary goal in mountebank is to keep things that should be easy actually easy, and to make hard things possible. Comprehensive default settings, predicates, and simple is responses enable you to solve easy problems with simple solutions. Support for certificates, JSON, XML, and proxies help you to create solutions for a harder set of problems. But sometimes, that’s not enough.

At times, the built-in features of mountebank may not directly support your use case. Matching predicates based on JSON and XML is nice, but what if your requests use CSV format? Or say you have a service that needs to replay information from an earlier request in a subsequent response, requiring stateful memory. Maybe your use case extends beyond what a proxy is capable of doing. Or perhaps you need to grab some data from outside mountebank itself and insert it into the stub response.

You need inject.

6.1. Creating your own predicate

6.2. Creating your own dynamic response

6.3. A word of caution: security matters

6.4. Debugging tips

Summary

sitemap