@mbtest/mountebank 2.9.2-beta.9050

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -0
  3. package/bin/mb +136 -0
  4. package/package.json +71 -0
  5. package/releases.json +52 -0
  6. package/src/cli/api.js +112 -0
  7. package/src/cli/cli.js +420 -0
  8. package/src/controllers/configController.js +64 -0
  9. package/src/controllers/feedController.js +115 -0
  10. package/src/controllers/homeController.js +58 -0
  11. package/src/controllers/imposterController.js +328 -0
  12. package/src/controllers/impostersController.js +215 -0
  13. package/src/controllers/logsController.js +52 -0
  14. package/src/models/behaviors.js +553 -0
  15. package/src/models/behaviorsValidator.js +186 -0
  16. package/src/models/compatibility.js +133 -0
  17. package/src/models/dryRunValidator.js +261 -0
  18. package/src/models/filesystemBackedImpostersRepository.js +908 -0
  19. package/src/models/http/baseHttpServer.js +207 -0
  20. package/src/models/http/headersMap.js +87 -0
  21. package/src/models/http/httpProxy.js +230 -0
  22. package/src/models/http/httpRequest.js +82 -0
  23. package/src/models/http/httpServer.js +18 -0
  24. package/src/models/http/index.js +18 -0
  25. package/src/models/https/cert/mb-cert.pem +20 -0
  26. package/src/models/https/cert/mb-csr.pem +16 -0
  27. package/src/models/https/cert/mb-key.pem +27 -0
  28. package/src/models/https/httpsServer.js +42 -0
  29. package/src/models/https/index.js +18 -0
  30. package/src/models/imposter.js +243 -0
  31. package/src/models/imposterPrinter.js +120 -0
  32. package/src/models/impostersRepository.js +49 -0
  33. package/src/models/inMemoryImpostersRepository.js +418 -0
  34. package/src/models/jsonpath.js +44 -0
  35. package/src/models/mbConnection.js +107 -0
  36. package/src/models/predicates.js +438 -0
  37. package/src/models/protocols.js +242 -0
  38. package/src/models/responseResolver.js +398 -0
  39. package/src/models/smtp/index.js +16 -0
  40. package/src/models/smtp/smtpRequest.js +60 -0
  41. package/src/models/smtp/smtpServer.js +109 -0
  42. package/src/models/tcp/index.js +18 -0
  43. package/src/models/tcp/tcpProxy.js +110 -0
  44. package/src/models/tcp/tcpRequest.js +23 -0
  45. package/src/models/tcp/tcpServer.js +156 -0
  46. package/src/models/tcp/tcpValidator.js +19 -0
  47. package/src/models/xpath.js +95 -0
  48. package/src/mountebank.js +245 -0
  49. package/src/public/images/arrow_down.png +0 -0
  50. package/src/public/images/arrow_up.png +0 -0
  51. package/src/public/images/book.jpg +0 -0
  52. package/src/public/images/dataflow.png +0 -0
  53. package/src/public/images/favicon.ico +0 -0
  54. package/src/public/images/forkme_right_orange_ff7600.png +0 -0
  55. package/src/public/images/mountebank.png +0 -0
  56. package/src/public/images/overview.gif +0 -0
  57. package/src/public/images/quote.png +0 -0
  58. package/src/public/images/tw-logo.png +0 -0
  59. package/src/public/scripts/jquery/jquery-3.6.1.min.js +2 -0
  60. package/src/public/scripts/urlHashHandler.js +31 -0
  61. package/src/public/stylesheets/application.css +424 -0
  62. package/src/public/stylesheets/ie.css +14 -0
  63. package/src/public/stylesheets/imposters.css +121 -0
  64. package/src/public/stylesheets/jqueryui/1.10.4/themes/smoothness/jquery-ui.css +1178 -0
  65. package/src/util/combinators.js +68 -0
  66. package/src/util/date.js +51 -0
  67. package/src/util/errors.js +55 -0
  68. package/src/util/helpers.js +131 -0
  69. package/src/util/inherit.js +28 -0
  70. package/src/util/ip.js +54 -0
  71. package/src/util/logger.js +83 -0
  72. package/src/util/middleware.js +256 -0
  73. package/src/util/scopedLogger.js +47 -0
  74. package/src/views/_footer.ejs +20 -0
  75. package/src/views/_header.ejs +113 -0
  76. package/src/views/_imposter.ejs +8 -0
  77. package/src/views/config.ejs +71 -0
  78. package/src/views/docs/api/behaviors/copy.ejs +427 -0
  79. package/src/views/docs/api/behaviors/decorate.ejs +182 -0
  80. package/src/views/docs/api/behaviors/lookup.ejs +220 -0
  81. package/src/views/docs/api/behaviors/shellTransform.ejs +153 -0
  82. package/src/views/docs/api/behaviors/wait.ejs +121 -0
  83. package/src/views/docs/api/behaviors.ejs +141 -0
  84. package/src/views/docs/api/contracts/addStub-description.ejs +10 -0
  85. package/src/views/docs/api/contracts/addStub.ejs +10 -0
  86. package/src/views/docs/api/contracts/config-description.ejs +32 -0
  87. package/src/views/docs/api/contracts/config.ejs +23 -0
  88. package/src/views/docs/api/contracts/home-description.ejs +18 -0
  89. package/src/views/docs/api/contracts/home.ejs +13 -0
  90. package/src/views/docs/api/contracts/imposter-description.ejs +439 -0
  91. package/src/views/docs/api/contracts/imposter.ejs +182 -0
  92. package/src/views/docs/api/contracts/imposters-description.ejs +13 -0
  93. package/src/views/docs/api/contracts/imposters.ejs +13 -0
  94. package/src/views/docs/api/contracts/logs-description.ejs +3 -0
  95. package/src/views/docs/api/contracts/logs.ejs +14 -0
  96. package/src/views/docs/api/contracts/stub-description.ejs +4 -0
  97. package/src/views/docs/api/contracts/stub.ejs +7 -0
  98. package/src/views/docs/api/contracts/stubs-description.ejs +4 -0
  99. package/src/views/docs/api/contracts/stubs.ejs +11 -0
  100. package/src/views/docs/api/contracts.ejs +133 -0
  101. package/src/views/docs/api/errors.ejs +64 -0
  102. package/src/views/docs/api/fault/connectionReset.ejs +31 -0
  103. package/src/views/docs/api/fault/randomDataThenClose.ejs +31 -0
  104. package/src/views/docs/api/faults.ejs +57 -0
  105. package/src/views/docs/api/injection.ejs +426 -0
  106. package/src/views/docs/api/json.ejs +205 -0
  107. package/src/views/docs/api/jsonpath.ejs +210 -0
  108. package/src/views/docs/api/mocks.ejs +130 -0
  109. package/src/views/docs/api/overview.ejs +968 -0
  110. package/src/views/docs/api/predicates/and.ejs +62 -0
  111. package/src/views/docs/api/predicates/contains.ejs +64 -0
  112. package/src/views/docs/api/predicates/deepEquals.ejs +114 -0
  113. package/src/views/docs/api/predicates/endsWith.ejs +66 -0
  114. package/src/views/docs/api/predicates/equals.ejs +125 -0
  115. package/src/views/docs/api/predicates/exists.ejs +118 -0
  116. package/src/views/docs/api/predicates/inject.ejs +67 -0
  117. package/src/views/docs/api/predicates/matches.ejs +66 -0
  118. package/src/views/docs/api/predicates/not.ejs +52 -0
  119. package/src/views/docs/api/predicates/or.ejs +79 -0
  120. package/src/views/docs/api/predicates/startsWith.ejs +62 -0
  121. package/src/views/docs/api/predicates.ejs +382 -0
  122. package/src/views/docs/api/proxies.ejs +191 -0
  123. package/src/views/docs/api/proxy/addDecorateBehavior.ejs +115 -0
  124. package/src/views/docs/api/proxy/addWaitBehavior.ejs +96 -0
  125. package/src/views/docs/api/proxy/injectHeaders.ejs +91 -0
  126. package/src/views/docs/api/proxy/predicateGenerators.ejs +600 -0
  127. package/src/views/docs/api/proxy/proxyModes.ejs +495 -0
  128. package/src/views/docs/api/stubs.ejs +391 -0
  129. package/src/views/docs/api/xpath.ejs +281 -0
  130. package/src/views/docs/cli/configFiles.ejs +133 -0
  131. package/src/views/docs/cli/customFormatters.ejs +53 -0
  132. package/src/views/docs/cli/help.ejs +6 -0
  133. package/src/views/docs/cli/replay.ejs +42 -0
  134. package/src/views/docs/cli/restart.ejs +10 -0
  135. package/src/views/docs/cli/save.ejs +68 -0
  136. package/src/views/docs/cli/start.ejs +234 -0
  137. package/src/views/docs/cli/stop.ejs +32 -0
  138. package/src/views/docs/commandLine.ejs +93 -0
  139. package/src/views/docs/communityExtensions.ejs +233 -0
  140. package/src/views/docs/gettingStarted.ejs +146 -0
  141. package/src/views/docs/mentalModel.ejs +51 -0
  142. package/src/views/docs/protocols/custom.ejs +231 -0
  143. package/src/views/docs/protocols/http.ejs +238 -0
  144. package/src/views/docs/protocols/https.ejs +246 -0
  145. package/src/views/docs/protocols/smtp.ejs +142 -0
  146. package/src/views/docs/protocols/tcp.ejs +431 -0
  147. package/src/views/docs/security.ejs +38 -0
  148. package/src/views/faqs.ejs +65 -0
  149. package/src/views/feed.ejs +33 -0
  150. package/src/views/imposter.ejs +22 -0
  151. package/src/views/imposters.ejs +33 -0
  152. package/src/views/index.ejs +89 -0
  153. package/src/views/license.ejs +30 -0
  154. package/src/views/logs.ejs +77 -0
  155. package/src/views/releases/v1.1.0.ejs +55 -0
  156. package/src/views/releases/v1.1.36.ejs +84 -0
  157. package/src/views/releases/v1.1.72.ejs +92 -0
  158. package/src/views/releases/v1.10.0.ejs +108 -0
  159. package/src/views/releases/v1.11.0.ejs +109 -0
  160. package/src/views/releases/v1.12.0.ejs +96 -0
  161. package/src/views/releases/v1.13.0.ejs +118 -0
  162. package/src/views/releases/v1.14.0.ejs +107 -0
  163. package/src/views/releases/v1.14.1.ejs +94 -0
  164. package/src/views/releases/v1.15.0.ejs +113 -0
  165. package/src/views/releases/v1.16.0.ejs +104 -0
  166. package/src/views/releases/v1.2.0.ejs +78 -0
  167. package/src/views/releases/v1.2.103.ejs +86 -0
  168. package/src/views/releases/v1.2.122.ejs +86 -0
  169. package/src/views/releases/v1.2.30.ejs +84 -0
  170. package/src/views/releases/v1.2.45.ejs +84 -0
  171. package/src/views/releases/v1.2.56.ejs +79 -0
  172. package/src/views/releases/v1.3.0.ejs +86 -0
  173. package/src/views/releases/v1.3.1.ejs +100 -0
  174. package/src/views/releases/v1.4.0.ejs +96 -0
  175. package/src/views/releases/v1.4.1.ejs +103 -0
  176. package/src/views/releases/v1.4.2.ejs +100 -0
  177. package/src/views/releases/v1.4.3.ejs +113 -0
  178. package/src/views/releases/v1.5.0.ejs +104 -0
  179. package/src/views/releases/v1.5.1.ejs +91 -0
  180. package/src/views/releases/v1.6.0.ejs +109 -0
  181. package/src/views/releases/v1.7.0.ejs +113 -0
  182. package/src/views/releases/v1.7.1.ejs +90 -0
  183. package/src/views/releases/v1.7.2.ejs +96 -0
  184. package/src/views/releases/v1.8.0.ejs +121 -0
  185. package/src/views/releases/v1.9.0.ejs +111 -0
  186. package/src/views/releases/v2.0.0.ejs +159 -0
  187. package/src/views/releases/v2.1.0.ejs +121 -0
  188. package/src/views/releases/v2.1.1.ejs +106 -0
  189. package/src/views/releases/v2.1.2.ejs +84 -0
  190. package/src/views/releases/v2.2.0.ejs +115 -0
  191. package/src/views/releases/v2.2.1.ejs +102 -0
  192. package/src/views/releases/v2.3.0.ejs +121 -0
  193. package/src/views/releases/v2.3.1.ejs +100 -0
  194. package/src/views/releases/v2.3.2.ejs +102 -0
  195. package/src/views/releases/v2.3.3.ejs +97 -0
  196. package/src/views/releases/v2.4.0.ejs +114 -0
  197. package/src/views/releases/v2.5.0.ejs +51 -0
  198. package/src/views/releases/v2.6.0.ejs +35 -0
  199. package/src/views/releases/v2.7.0.ejs +32 -0
  200. package/src/views/releases/v2.8.0.ejs +36 -0
  201. package/src/views/releases/v2.8.1.ejs +7 -0
  202. package/src/views/releases/v2.8.2.ejs +26 -0
  203. package/src/views/releases/v2.9.0.ejs +32 -0
  204. package/src/views/releases/v2.9.1.ejs +10 -0
  205. package/src/views/releases.ejs +26 -0
  206. package/src/views/sitemap.ejs +36 -0
  207. package/src/views/support.ejs +14 -0
@@ -0,0 +1,32 @@
1
+ <div id='config-version-description'>
2
+ <p>The mountebank version</p>
3
+ </div>
4
+
5
+ <div id='config-options-description'>
6
+ <p>The command line options used to start <code>mb</code>.</p>
7
+ <p class='info-icon'>More information: <a href='/docs/commandLine'>command line options</a></p>
8
+ </div>
9
+
10
+ <div id='config-process-description'>
11
+ <p>Information about the running <code>mb</code> process</p>
12
+ </div>
13
+
14
+ <div id='config-process-nodeVersion-description'>
15
+ <p>The version of node.js</p>
16
+ </div>
17
+
18
+ <div id='config-process-architecture-description'>
19
+ <p>The operating system and architecture of the machine running mountebank.</p>
20
+ </div>
21
+
22
+ <div id='config-process-memory-description'>
23
+ <p>The memory (in bytes) used by mountebank, and heap usage of the V8 JavaScript engine.</p>
24
+ </div>
25
+
26
+ <div id='config-process-uptime-description'>
27
+ <p>The number of seconds this process has been running.</p>
28
+ </div>
29
+
30
+ <div id='config-process-cwd-description'>
31
+ <p>The current directory, used to start <code>mb</code></p>
32
+ </div>
@@ -0,0 +1,23 @@
1
+ <pre id='config-specification'><code>{
2
+ <span id='config-version'><%- indent(2) %>&quot;version&quot;: &quot;1.4.1&quot;,</span>
3
+ <span id='config-options'><%- indent(2) %>&quot;options&quot;: {
4
+ &quot;port&quot;: 2525,
5
+ &quot;pidfile&quot;: &quot;mb.pid&quot;,
6
+ &quot;logfile&quot;: &quot;mb.log&quot;,
7
+ &quot;loglevel&quot;: &quot;info&quot;,
8
+ &quot;configfile&quot;: &quot;&quot;,
9
+ &quot;allowInjection&quot;: false,
10
+ &quot;mock&quot;: true,
11
+ &quot;debug&quot;: true
12
+ },</span>
13
+ <span id='config-process'><%- indent(2) %>&quot;process&quot;: {</span>
14
+ <span id='config-process-nodeVersion'><%- indent(4) %>&quot;nodeVersion&quot;: &quot;v6.9.1&quot;,</span>
15
+ <span id='config-process-architecture'><%- indent(4) %>&quot;architecture&quot;: &quot;x64&quot;,
16
+ &quot;platform&quot;: &quot;darwin&quot;,</span>
17
+ <span id='config-process-memory'><%- indent(4) %>&quot;rss&quot;: 29822976,
18
+ &quot;heapTotal&quot;: 18635008,
19
+ &quot;heapUsed&quot;: 9294352,</span>
20
+ <span id='config-process-uptime'><%- indent(4) %>&quot;uptime&quot;: 16,</span>
21
+ <span id='config-process-cwd'><%- indent(4) %>&quot;cwd&quot;: &quot;/Users/bbyars/src/mountebank&quot;</span>
22
+ }
23
+ }</code></pre>
@@ -0,0 +1,18 @@
1
+ <div id='home-_links-description'>
2
+ <p>Defines the hypermedia relationships for mountebank.</p>
3
+ </div>
4
+
5
+ <div id='home-_links-imposters-description'>
6
+ <p>Defines the URL for the imposters resource.</p>
7
+ <p class='info-icon'>More information: <a href='/docs/api/contracts?type=imposter'>imposter contract</a></p>
8
+ </div>
9
+
10
+ <div id='home-_links-config-description'>
11
+ <p>Defines the URL for the config resource.</p>
12
+ <p class='info-icon'>More information: <a href='/docs/api/contracts?type=config'>config contract</a></p>
13
+ </div>
14
+
15
+ <div id='home-_links-logs-description'>
16
+ <p>Defines the URL for the log resource.</p>
17
+ <p class='info-icon'>More information: <a href='/docs/api/contracts?type=logs'>log contract</a></p>
18
+ </div>
@@ -0,0 +1,13 @@
1
+ <pre id='home-specification'><code>{
2
+ <span id='home-_links'><%- indent(2) %>&quot;_links&quot;: {</span>
3
+ <span id='home-_links-imposters'><%- indent(4) %>&quot;imposters&quot;: {
4
+ &quot;href&quot;: &quot;http://localhost:2525/imposters&quot;
5
+ },</span>
6
+ <span id='home-_links-config'><%- indent(4) %>&quot;config&quot;: {
7
+ &quot;href&quot;: &quot;http://localhost:2525/config&quot;
8
+ },</span>
9
+ <span id='home-_links-logs'><%- indent(4) %>&quot;logs&quot;: {
10
+ &quot;href&quot;: &quot;http://localhost:2525/logs&quot;
11
+ }</span>
12
+ }
13
+ }</code></pre>
@@ -0,0 +1,439 @@
1
+ <div id='imposter-port-description'>
2
+ <p>The port to run the imposter on.<p>
3
+ <p>Optional. Defaults to a randomly assigned port that will be returned in the response</p>
4
+ <p class='warning-icon'>On Linux and Mac, requires <code>sudo</code> to set to a privileged port (1-1023)</p>
5
+ </div>
6
+
7
+ <div id='imposter-protocol-description'>
8
+ <p>Defines the protocol that the imposter will respond to. Valid values are:</p>
9
+ <ul class='bullet-list indent'>
10
+ <li><a href='/docs/protocols/http'>http</a></li>
11
+ <li><a href='/docs/protocols/https'>https</a></li>
12
+ <li><a href='/docs/protocols/tcp'>tcp</a></li>
13
+ <li><a href='/docs/protocols/smtp'>smtp</a></li>
14
+ </ul>
15
+ </div>
16
+
17
+ <div id='imposter-name-description'>
18
+ <p>Optional. Allows you to provide a descriptive name that will show up in the <a href='/logs'>logs</a>
19
+ and the <a href='/imposters'>imposters UI</a>.</p>
20
+ </div>
21
+
22
+ <div id='imposter-recordRequests-description'>
23
+ <p>Optional. If set to <code>true</code>, the server will record requests received, for mock verification purposes.</p>
24
+ </div>
25
+
26
+ <div id='imposter-numberOfRequests-description'>
27
+ <p>The number of requests to this imposter</p>
28
+
29
+ <p class='info-icon'>Set <code>recordRequests</code> to <code>true</code> on the imposter to also record
30
+ the details of each request in the <code>requests</code> array below</p>
31
+ </div>
32
+
33
+ <div id='imposter-key-description'>
34
+ <p>Optional. Allows you to pass in an SSL private key for creating an https server (this field only applies
35
+ to https). Must be a PEM-formatted string. Defaults to a built-in private key.</p>
36
+
37
+ <p class='info-icon'>More information: <a href='/docs/protocols/https'>https</a></p>
38
+ </div>
39
+
40
+ <div id='imposter-cert-description'>
41
+ <p>Optional. Allows you to pass in an SSL certificate for creating an https server (this field only applies
42
+ to https). Must be a PEM-formatted string. Defaults to a built-in self-signed certificate.</p>
43
+
44
+ <p class='info-icon'>More information: <a href='/docs/protocols/https'>https</a></p>
45
+ </div>
46
+
47
+ <div id='imposter-mutualAuth-description'>
48
+ <p>Optional. If set to <code>true</code>, the server will request a client certificate. Since the goal
49
+ is simply to virtualize a server requiring mutual auth, invalid certificates will not be rejected.</p>
50
+
51
+ <p class='info-icon'>More information: <a href='/docs/protocols/https'>https</a></p>
52
+ </div>
53
+
54
+ <div id='imposter-defaultResponse-description'>
55
+ <p>Optional. Allows you to override the default response that mountebank sends back if no predicate matches
56
+ a request. Even if a predicate does match but the response isn't fully specified, these values get merged
57
+ in to complete the response.</p>
58
+
59
+ <p class='info-icon'>More information: <a href='/docs/protocols/http'>http</a>,
60
+ <a href='/docs/protocols/https'>https</a>, and <a href='/docs/protocols/tcp'>tcp</a></p>
61
+ </div>
62
+
63
+ <div id='imposter-stubs-description'>
64
+ <p>A set of behaviors used to generate a response for an imposter. An imposter can have 0 or more stubs,
65
+ each of which are associated with different predicates and support different responses.</p>
66
+
67
+ <p>You would use multiple stubs for an imposter if the types of response you return depends on something
68
+ in the request, matched with a predicate.</p>
69
+ </div>
70
+
71
+ <div id='imposter-stubs-responses-description'>
72
+ <p>An array of responses to return for this stub. The responses array defines a circular buffer - every
73
+ time the stub is used for the request, the first response is pulled from the front of the
74
+ <code>responses</code> array, evaluated, and pushed to the back of the array. This elegantly does what
75
+ you want. In the common case, when you always want to return the same response, you just add one response
76
+ to the array. More complex scenarios will require that the same endpoint returns a sequence of
77
+ different responses for the same predicates. Simply add them all to the array in order.
78
+ When the sequence finishes, it will start over. More complexity can be added by simply
79
+ adding more responses to the array without complicating the contract.</p>
80
+
81
+ <p>Each response is defined by one and only one <i>response type</i>. This defines the type of response
82
+ generated. The following response types are supported, and described in more detail in the contract
83
+ example to the left as well as the links provided below.</p>
84
+
85
+ <ul class='bullet-list indent'>
86
+ <li><a href='/docs/api/stubs'>is</a>: A canned response</li>
87
+ <li><a href='/docs/api/proxies'>proxy</a>: A record/replay response</li>
88
+ <li><a href='/docs/api/injection'>inject</a>: A scripted response</li>
89
+ </ul>
90
+
91
+ <p class='info-icon'>More informaton: <a href='/docs/api/stubs'>stubs</a></p>
92
+ </div>
93
+
94
+ <div id='imposter-stubs-responses-is-description'>
95
+ <p>The <code>is</code> response type represents a canned response that you define. The response fields will
96
+ be those defined with each protocol according to the links below (the http response fields
97
+ are shown in this example). smtp stubbing is not supported.</p>
98
+
99
+ <p>You do not need to fill in every response field; mountebank will merge the specified response fields
100
+ with the response defaults (see the protocol pages below for the defaults).</p>
101
+
102
+ <ul class='bullet-list indent'>
103
+ <li><a href='/docs/protocols/http'>http</a></li>
104
+ <li><a href='/docs/protocols/https'>https</a></li>
105
+ <li><a href='/docs/protocols/tcp'>tcp</a></li>
106
+ </ul>
107
+
108
+ <p class='info-icon'>More information: <a href='/docs/api/stubs'>stubs</a></p>
109
+ </div>
110
+
111
+ <div id='imposter-stubs-responses-repeat-description'>
112
+ <p>Causes the response to repeat a given number of times before returning the next response
113
+ in the <code>responses</code> array.</p>
114
+
115
+ <p class='info-icon'>More information: <a href='/docs/api/stubs'>stub responses</a></p>
116
+ </div>
117
+
118
+ <div id='imposter-stubs-behaviors-description'>
119
+ <p>Behaviors alter the generated response in some way. The following behaviors are supported:</p>
120
+
121
+ <ul class='bullet-list indent'>
122
+ <li><code>wait</code> - adds latency to the response</li>
123
+ <li><code>decorate</code> - post-processes the response using a JavaScript function</li>
124
+ <li><code>shellTransform</code> - post-processes the response using a command line application</li>
125
+ <li><code>copy</code> - copies a value from the request into the response</li>
126
+ <li><code>lookup</code> - lookups values from an external data source</li>
127
+ </ul>
128
+
129
+ <p>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
130
+ </div>
131
+
132
+ <div id='imposter-stubs-behaviors-wait-description'>
133
+ <p>Adds latency to a response by waiting a specified number of milliseconds before sending the response.</p>
134
+
135
+ <p class='info-icon'>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
136
+ </div>
137
+
138
+ <div id='imposter-stubs-behaviors-decorate-description'>
139
+ <p>Post-processes the response before sending it. Since post-processing requires JavaScript
140
+ injection, the <code><a href='/docs/commandLine'>--allowInjection</a></code> flag must be passed.
141
+ Post-processing opens up a world of opportunities - you can use a <code>decorate</code> behavior
142
+ to add data to a proxied response or substitute dynamic data into the response, for
143
+ example. The value passed into the <code>decorate</code> behavior is a JavaScript function that
144
+ can take up to an object containing the request, the response, and a logger. You can either mutate the
145
+ response passed in (and return nothing), or return an altogether new response.</p>
146
+
147
+ <p class='warning-icon'>JavaScript injection requires the
148
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
149
+
150
+ <p class='info-icon'>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
151
+ </div>
152
+
153
+ <div id='imposter-stubs-behaviors-shellTransform-description'>
154
+ <p>Post-processes the response before sending it. Unlike a <code>decorate</code>, the post-processing
155
+ occurs through a command line application, which still requires the <code><a href='/docs/commandLine'>
156
+ --allowInjection</a></code> flag to be set. The command line application will be passed the request JSON
157
+ and the response JSON through environment variables, and should write the transformed response
158
+ JSON to <code>stdout</code>.</p>
159
+
160
+ <p class='warning-icon'>Shell execution requires the
161
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
162
+
163
+ <p class='info-icon'>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
164
+ </div>
165
+
166
+ <div id='imposter-stubs-behaviors-copy-description'>
167
+ <p>Post-processes the response by replacing the given tokens with values from the specified request fields.
168
+ You can select the appropriate values from the request using regular expressions, xpath, or jsonpath.</p>
169
+
170
+ <p class='info-icon'>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
171
+ </div>
172
+
173
+ <div id='imposter-stubs-behaviors-lookup-description'>
174
+ <p>Post-processes the response by looking up data from an external data source using a key
175
+ selected from the request. The given tokens in the response are replaced with the looked up values.
176
+ You can select the appropriate keys from the request using regular expressions, xpath, or jsonpath.</p>
177
+
178
+ <p class='info-icon'>More information: <a href='/docs/api/behaviors'>behaviors</a></p>
179
+ </div>
180
+
181
+ <div id='imposter-stubs-responses-proxy-description'>
182
+ <p>The response is generated by proxying the request to a different server. You can configure mountebank
183
+ to return the saved response on subsequent requests based on certain conditions within the request.</p>
184
+
185
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
186
+ </div>
187
+
188
+ <div id='imposter-stubs-responses-proxy-to-description'>
189
+ <p>Represents the destination to send the request. This should be a URL with the protocol and
190
+ host but without a path (as shown to the left). http and https imposters can both proxy to
191
+ http and https. tcp proxies can only proxy to tcp (e.g. tcp://someserver:3000).</p>
192
+
193
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
194
+ </div>
195
+
196
+ <div id='imposter-stubs-responses-proxy-mode-description'>
197
+ <p>Defines the replay behavior of the proxy. Proxy responses work by creating new elements in the
198
+ <code>stubs</code> array. This field determines whether that newly created stub will be before or
199
+ after the current stub in the array. There are two options:</p>
200
+
201
+ <ul class='bullet-list indent'>
202
+ <li><code>proxyOnce</code> - always records the proxied call in the <code>stubs</code> array in
203
+ front of itself, so the same call is never proxied twice.</li>
204
+ <li><code>proxyAlways</code> - saves the proxied call <em>after</em> itself in the <code>stubs</code>
205
+ array. This allows you to capture different responses for the same call.
206
+ You can later replay <code>proxyAlways</code> stubs by issuing a <code>GET</code>
207
+ or <code>DELETE</code> to the imposter with the <code>removeProxies</code> and
208
+ <code>replayable</code> query params, and re-<code>POST</code>ing the imposter.</li>
209
+ </ul>
210
+
211
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
212
+ </div>
213
+
214
+ <div id='imposter-stubs-responses-proxy-key-description'>
215
+ <p>In situations where the destination expects to use SSL mutual authentication, it will request a client
216
+ certificate. This field can contain the PEM-formatted client private key.</p>
217
+
218
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
219
+ </div>
220
+
221
+ <div id='imposter-stubs-responses-proxy-cert-description'>
222
+ <p>In situations where the destination expects to use SSL mutual authentication, it will request a client
223
+ certificate. This field can contain the PEM-formatted client certificate.</p>
224
+
225
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
226
+ </div>
227
+
228
+ <div id='imposter-stubs-responses-proxy-ciphers-description'>
229
+ <p>In nearly all cases, you'll never need to use this field. However if you need to proxy to an
230
+ older HTTPS server using insecure ciphers that are no longer used, you can override the
231
+ cipher using one of the <a href='https://nodejs.org/api/tls.html#tls_modifying_the_default_tls_cipher_suite'>standard formats</a>.</p>
232
+
233
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
234
+ </div>
235
+
236
+ <div id='imposter-stubs-responses-proxy-secureProtocol-description'>
237
+ <p>A legacy mechanism to select the TLS protocol to use. Learn more at the
238
+ <a href='https://nodejs.org/api/tls.html#tls_tls_connect_options_callback'>node documentation</a>.</p>
239
+
240
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
241
+ </div>
242
+
243
+ <div id='imposter-stubs-responses-proxy-passphrase-description'>
244
+ <p>The shared passphrase for a private key</p>
245
+
246
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
247
+ </div>
248
+
249
+ <div id='imposter-stubs-responses-proxy-addWaitBehavior-description'>
250
+ <p>When this field is true, mountebank will add latency to the saved responses that mirrors the time
251
+ the actual proxied call took. This is useful in load testing when you want to virtualize downstream services
252
+ but keep the latency of those services.</p>
253
+
254
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a> and the
255
+ <a href='/docs/api/behaviors#behavior-wait'>wait behavior</a></p>
256
+ </div>
257
+
258
+ <div id='imposter-stubs-responses-proxy-addDecorateBehavior-description'>
259
+ <p>When present, adds the given function as a <code>decorate</code> behavior to each newly created response.</p>
260
+
261
+ <p class='warning-icon'>JavaScript injection requires the
262
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
263
+
264
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
265
+ </div>
266
+
267
+ <div id='imposter-stubs-responses-proxy-injectHeaders-description'>
268
+ <p>Allows you to add or override headers returned from the proxy.</p>
269
+
270
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
271
+ </div>
272
+
273
+ <div id='imposter-stubs-responses-proxy-predicateGenerators-description'>
274
+ <p>An array of objects that defines how the predicates for new stubs are created. Proxy responses work
275
+ by creating new elements in the <code>stubs</code> array, either before the current stub (if
276
+ <code>mode</code> is <code>proxyOnce</code>) or after the current stub (if <code>mode</code> is
277
+ <code>proxyAlways</code>). Each element in the <code>predicateGenerators</code> array
278
+ will create a single element in the <code>predicates</code> array for newly created stub.</p>
279
+
280
+ <p>Each generator should contain a <code>matches</code> field containing all the request elements you
281
+ want to create predicates for. You can configure the newly created predicate with standard predicate
282
+ parameters. The created predicates will be generally be <code>deepEquals</code> predicates.</p>
283
+
284
+ <p>Alternatively, if you need more fine-grained control, you can use an <code>inject</code> field
285
+ containing a JavaScript function to create the predicates.</p>
286
+
287
+ <p class='info-icon'>More information: <a href='/docs/api/proxies'>proxies</a></p>
288
+ </div>
289
+
290
+ <div id='imposter-stubs-responses-inject-description'>
291
+ <p>mountebank is scriptable, which allows you to use JavaScript to craft the response you want in situations
292
+ where canned responses and proxy responses are not sufficient. The injected function takes four parameters
293
+ as shown on the left:</p>
294
+
295
+ <ul class='bullet-list indent'>
296
+ <li><code>request</code> - the protocol-specific request object</li>
297
+ <li><code>state</code> - initially an empty object, the same instance will be passed into every response
298
+ injection function within the same imposter. You can use it to add any cross-response state you need to save.</li>
299
+ <li><code>logger</code> - mountebank's logger, with standard <code>debug</code>, <code>info</code>,
300
+ <code>warn</code>, and <code>error</code> functions</li>
301
+ <li><code>callback</code> - For asynchronous use only, execute (with the response as a parameter) to return</li>
302
+ </ul>
303
+
304
+ <p>Injection can by synchronous or asnychronous. Simply return a value representing the response for synchronous
305
+ execution. For asynchronous execution, pass the response object into the <code>callback</code> function.</p>
306
+
307
+ <p class='warning-icon'>JavaScript injection requires the
308
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
309
+
310
+ <p class='info-icon'>More information: <a href='/docs/api/injection'>injection</a></p>
311
+ </div>
312
+
313
+ <div id='imposter-stubs-predicates-description'>
314
+ <p>In the absence of a predicate, a stub always matches, and there's never a reason to
315
+ add more than one stub to an imposter. Predicates allow imposters to have much richer
316
+ behavior by defining whether or not a stub matches a request. When multiple stubs are
317
+ created on an imposter, the first stub that matches is selected.</p>
318
+
319
+ <p>Each predicate object contains one or more of the request fields as keys. Predicates
320
+ are added to a stub in an array, and all predicates are AND'd together. The following
321
+ predicate operators are allowed:</p>
322
+
323
+ <ul class='bullet-list indent'>
324
+ <li><code>equals</code> - The request field matches the predicate</li>
325
+ <li><code>deepEquals</code> - Performs nested set equality on the request field, useful when
326
+ the request field is an object (e.g. the <code>query</code> field in http)</li>
327
+ <li><code>contains</code> - The request field contains the predicate</li>
328
+ <li><code>startsWith</code> - The request field starts with the predicate</li>
329
+ <li><code>endsWith</code> - The request field ends with the predicate</li>
330
+ <li><code>matches</code> - The request field matches the JavaScript regular expression defined
331
+ with the predicate.</li>
332
+ <li><code>exists</code> - If <code>true</code>, the request field must exist. If <code>false</code>,
333
+ the request field must not exist.</li>
334
+ <li><code>not</code> - Inverts a predicate</li>
335
+ <li><code>or</code> - Logically or's two predicates together</li>
336
+ <li><code>and</code> - Logically and's two predicates together</li>
337
+ <li><code>inject</code> - Injects JavaScript to decide whether the request matches or not.</li>
338
+ </ul>
339
+
340
+ <p class='info-icon'>More information: <a href='/docs/api/predicates'>predicates</a></p>
341
+ </div>
342
+
343
+ <div id='imposter-stubs-predicates-0-equals-description'>
344
+ <p>A type of predicate that requires the given request fields to equal the predicate value.
345
+ By default, mountebank uses a case-insensitive equality.</p>
346
+
347
+ <p class='info-icon'>More information: <a href='/docs/api/predicates'>predicates</a></p>
348
+ </div>
349
+
350
+ <div id='imposter-stubs-predicates-0-caseSensitive-description'>
351
+ <p>If true, mountebank will require the request field to satisfy the predicate value in
352
+ a case sensitive comparison.</p>
353
+
354
+ <p class='info-icon'>More information: <a href='/docs/api/predicates'>predicates</a></p>
355
+ </div>
356
+
357
+ <div id='imposter-stubs-predicates-0-except-description'>
358
+ <p>Defines a regular expression that is stripped out of the request field before matching.</p>
359
+
360
+ <p class='info-icon'>More information: <a href='/docs/api/predicates'>predicates</a></p>
361
+ </div>
362
+
363
+ <div id='imposter-stubs-predicates-0-jsonpath-description'>
364
+ <p>It is common to want to use predicates on JSON response bodies, but annoying to treat the JSON as
365
+ simple text with many of the predicates. mountebank uses the <code>json</code> predicate parameter
366
+ to narrow the scope of the predicate value to a value matched by the json selector.</p>
367
+
368
+ <p class='info-icon'>More information: <a href='/docs/api/jsonpath'>jsonpath</a></p>
369
+ </div>
370
+
371
+ <div id='imposter-stubs-predicates-0-xpath-description'>
372
+ <p>It is common to want to use predicates on XML response bodies, but annoying to treat the XML as
373
+ simple text with many of the predicates. mountebank uses the <code>xpath</code> predicate parameter
374
+ to narrow the scope of the predicate value to a value matched by the xpath selector.</p>
375
+
376
+ <p class='info-icon'>More information: <a href='/docs/api/xpath'>xpath</a></p>
377
+ </div>
378
+
379
+ <div id='imposter-stubs-predicates-1-inject-description'>
380
+ <p>When none of the built-in predicates are sufficient, mountebank allows you to script the
381
+ predicate. The injected function accepts the following parameters:</p>
382
+
383
+ <ul class='bullet-list indent'>
384
+ <li><code>request</code> - the full request object</li>
385
+ <li><code>logger</code> - mountebank's logger, with standard <code>debug</code>, <code>info</code>,
386
+ <code>warn</code>, and <code>error</code> functions</li>
387
+ </ul>
388
+
389
+ <p>Return <code>true</code> to pass the predicate.</p>
390
+
391
+ <p class='warning-icon'>JavaScript injection requires the
392
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
393
+
394
+ <p class='info-icon'>More information: <a href='/docs/api/injection'>injection</a></p>
395
+ </div>
396
+
397
+ <div id='imposter-stubs-matches-description' class='response'>
398
+ <p>An array of all activity by this stub, useful in troubleshooting why a stub is or is not
399
+ responding (generally for debugging your predicates). Each object will contain the incoming
400
+ <code>request></code>, the outgoing <code>response</code>, and a <code>timestamp</code>.</p>
401
+
402
+ <p class='warning-icon'>The <code>matches</code> array only shows up in the response if the
403
+ <a href='/docs/commandLine'><code>--debug command line parameter</code></a> is passed.</p>
404
+ </div>
405
+
406
+ <div id='imposter-endOfRequestResolver-description'>
407
+ <p>The tricky bit about using the raw TCP protocol is knowing when a request ends. Application
408
+ protocols give some way of determining this, such as the <code>Content-Length</code> header in
409
+ HTTP or by embedding the message length in binary protocols. By default, mountebank assumes
410
+ each packet represents a separate request, which typically limits the size of each request
411
+ to somewhere between 1500 and 64k bytes (you'll get a larger payload using the loopback interface
412
+ on localhost, but lower level protocols like Ethernet will force a smaller payload over the network).
413
+ This strategy works for many scenarios as simple serialized requests tend to fall below this size,
414
+ but breaks down with large requests.</p>
415
+
416
+ <p>mountebank allows you the flexibility to determine when a request ends using the
417
+ <code>endOfRequestResolver</code> at the imposter level. The value is a JavaScript function
418
+ that takes a parameter that represents all request data captured from all packets so far. If the
419
+ imposter is in <code>text</code> mode, the parameter will be a string; in binary it will be a
420
+ <a href='http://nodejs.org/api/buffer.html'>node.js Buffer object</a>.
421
+ mountebank's <code>logger</code> object is also passed as an optional second parameter to
422
+ assist in troubleshooting.</p>
423
+
424
+ <p class='warning-icon'>JavaScript injection requires the
425
+ <a href='/docs/commandLine'>--allowInjection command line flag</a> to execute.</p>
426
+
427
+ <p class='info-icon'>More information: <a href='/docs/protocols/tcp'>tcp</a></p>
428
+ </div>
429
+
430
+ <div id='imposter-requests-description' class='response'>
431
+ <p>mountebank will save off all requests to the imposter for mock verification. By retrieving
432
+ the imposter, your client code can determine if an expected service call was in fact made.</p>
433
+
434
+ <p class='info-icon'>More information: <a href='/docs/api/mocks'>mocks</a></p>
435
+ </div>
436
+
437
+ <div id='imposter-_links-description' class='response'>
438
+ <p>Defines the hypermedia relationships for the imposter.</p>
439
+ </div>