@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,968 @@
1
+ <%
2
+ title = 'API overview'
3
+ description = "An overview of mountebank's RESTful API"
4
+ %>
5
+
6
+ <%- include('../../_header') -%>
7
+
8
+ <h1>API Overview</h1>
9
+
10
+ <p>mountebank uses a basic REST style API with standard HTTP status codes. Every effort has
11
+ gone into providing <a href='/docs/api/errors'>response bodies</a> to help you diagnose the problems.
12
+ Each error response returned will have a <code>code</code> and <code>message</code> at a minimum.
13
+ If extra information is available, mountebank will happily pass it to you. If you get stuck,
14
+ email the group on the <a href='/support'>support page</a>, along with your logs, and mountebank
15
+ will happily assist you.</p>
16
+
17
+ <h2>Capabilities</h2>
18
+
19
+ <p>mountebank supports the following capabilities:</p>
20
+
21
+ <table>
22
+ <tr>
23
+ <th style='width: 25em;'>Capability</th>
24
+ <th>Request Body</th>
25
+ <th>Response Body</th>
26
+ </tr>
27
+ <tr>
28
+ <td><a href='#get-home'>Get entry hypermedia</a></td>
29
+ <td></td>
30
+ <td><a href='/docs/api/contracts?type=home'>home</a></td>
31
+ </tr>
32
+ <tr>
33
+ <td><a href='#post-imposters'>Create a single imposter</a></td>
34
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
35
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
36
+ </tr>
37
+ <tr>
38
+ <td><a href='#get-imposter'>Get a single imposter</a></td>
39
+ <td></td>
40
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
41
+ </tr>
42
+ <tr>
43
+ <td><a href='#add-stub'>Add a stub to an existing imposter</a></td>
44
+ <td><a href='/docs/api/contracts?type=addStub'>add stub</a></td>
45
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
46
+ </tr>
47
+ <tr>
48
+ <td><a href='#change-stub'>Overwrite a stub of an existing imposter</a></td>
49
+ <td><a href='/docs/api/contracts?type=stub'>stub</a></td>
50
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
51
+ </tr>
52
+ <tr>
53
+ <td><a href='#change-stubs'>Overwrite all stubs of an existing imposter</a></td>
54
+ <td><a href='/docs/api/contracts?type=stubs'>stubs</a></td>
55
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
56
+ </tr>
57
+ <tr>
58
+ <td><a href='#delete-stub'>Remove a stub of an existing imposter</a></td>
59
+ <td></td>
60
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
61
+ </tr>
62
+ <tr>
63
+ <td><a href='#delete-imposter'>Delete a single imposter</a></td>
64
+ <td></td>
65
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
66
+ </tr>
67
+ <tr>
68
+ <td><a href='#delete-proxy-responses'>Delete saved proxy responses from an imposter</a></td>
69
+ <td></td>
70
+ <td></td>
71
+ </tr>
72
+ <tr>
73
+ <td><a href='#delete-requests'>Delete saved requests from an imposter</a></td>
74
+ <td></td>
75
+ <td><a href='/docs/api/contracts?type=imposter'>imposter</a></td>
76
+ </tr>
77
+ <tr>
78
+ <td><a href='#put-imposters'>Overwrite all imposters with a new set of imposters</a></td>
79
+ <td><a href='/docs/api/contracts?type=imposters'>imposters</a></td>
80
+ <td><a href='/docs/api/contracts?type=imposters'>imposters</a></td>
81
+ </tr>
82
+ <tr>
83
+ <td><a href='#get-imposters'>Get a list of all imposters</a></td>
84
+ <td></td>
85
+ <td><a href='/docs/api/contracts?type=imposters'>imposters</a></td>
86
+ </tr>
87
+ <tr>
88
+ <td><a href='#delete-imposters'>Delete all imposters</a></td>
89
+ <td></td>
90
+ <td><a href='/docs/api/contracts?type=imposters'>imposters</a></td>
91
+ </tr>
92
+ <tr>
93
+ <td><a href='#get-config'>Get mountebank configuration and process information</a></td>
94
+ <td></td>
95
+ <td><a href='/docs/api/contracts?type=config'>config</a></td>
96
+ </tr>
97
+ <tr>
98
+ <td><a href='#get-logs'>Get the logs</a></td>
99
+ <td></td>
100
+ <td><a href='/docs/api/contracts?type=logs'>logs</a></td>
101
+ </tr>
102
+ </table>
103
+
104
+ <h3 id='get-home'>Get entry hypermedia</h3>
105
+
106
+ <pre><code>GET /</code></pre>
107
+
108
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=home'>home</a></p>
109
+
110
+ <p>This endpoint exists for those who aspire to the
111
+ <a href='http://martinfowler.com/articles/richardsonMaturityModel.html'>upper echelons of REST</a>,
112
+ using hypermedia as the engine of application state. For those with more humble aspirations, mountebank
113
+ provides URL templates for all capabilities.</p>
114
+
115
+ <testScenario name='home'>
116
+ <step type='http'>
117
+ <pre><code>GET / HTTP/1.1
118
+ Host: localhost:<%= port %>
119
+ Accept: application/json</code></pre>
120
+
121
+ <assertResponse>
122
+ <pre><code>HTTP/1.1 200 OK
123
+ Vary: Accept
124
+ Content-Type: application/json; charset=utf-8
125
+ Content-Length: 226
126
+ Date: <volatile>Sun, 05 Jan 2014 16:16:08 GMT</volatile>
127
+ Connection: keep-alive
128
+
129
+ {
130
+ "_links": {
131
+ "imposters": { "href": "http://localhost:<%= port %>/imposters" },
132
+ "config": { "href": "http://localhost:<%= port %>/config" },
133
+ "logs": { "href": "http://localhost:<%= port %>/logs" }
134
+ }
135
+ }</code></pre>
136
+ </assertResponse>
137
+ </step>
138
+ </testScenario>
139
+
140
+ <h3 id='post-imposters'>Create a single imposter</h3>
141
+
142
+ <pre><code>POST /imposters</code></pre>
143
+
144
+ <p><b>Request contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
145
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
146
+
147
+ <p>Though he's not proud to admit it, mountebank employs an army of imposters to
148
+ fulfill your orders. Because your needs are varied and sundry, his imposters
149
+ are all different, and all are identified by a port number and associated with
150
+ a protocol. The value you get out of mountebank always starts by creating an imposter,
151
+ which represents a test double listening on a socket.</p>
152
+
153
+ <p><strong>Parameters:</strong></p>
154
+
155
+ <p>If you don't need stubbing, then the port and protocol are all you need. The parameters
156
+ each type of imposter accepts are explained on the page for the particular protocol
157
+ you're interested in. See the protocols section on the sidebar on the left.</p>
158
+
159
+ <p>mountebank expects that you will be responsible for providing the
160
+ port, since you'll need to configure the application under test with the same
161
+ port. However, the port is not required, and if you do not include it in the
162
+ request, mountebank will randomly assign one for you and return the port number
163
+ in the response.</p>
164
+
165
+ <testScenario name='imposters'>
166
+ <step type='http'>
167
+ <pre><code>POST /imposters HTTP/1.1
168
+ Host: localhost:<%= port %>
169
+ Accept: application/json
170
+ Content-Type: application/json
171
+
172
+ {
173
+ "port": 4545,
174
+ "protocol": "http"
175
+ }</code></pre>
176
+
177
+ <assertResponse>
178
+ <pre><code>HTTP/1.1 201 Created
179
+ Location: http://localhost:<%= port %>/imposters/4545
180
+ Content-Type: application/json; charset=utf-8
181
+ Content-Length: 298
182
+ Date: <volatile>Sun, 05 Jan 2014 16:28:40 GMT</volatile>
183
+ Connection: keep-alive
184
+
185
+ {
186
+ "protocol": "http",
187
+ "port": 4545,
188
+ "numberOfRequests": 0,
189
+ "recordRequests": false,
190
+ "requests": [],
191
+ "stubs": [],
192
+ "_links": {
193
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
194
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
195
+ }
196
+ }</code></pre>
197
+ </assertResponse>
198
+ </step>
199
+
200
+ <p>You can also initialize <a href='/docs/api/stubs'>stubs</a> in the <code>POST</code> call.</p>
201
+
202
+ <p>mountebank expects you to configure your application under test to point to the imposter. In
203
+ the case above, that would mean that your application has an http dependency configured to
204
+ http://localhost:4545. To retrieve a list of all imposters, simply issue a <code>GET</code>:</p>
205
+
206
+ <h3 id='get-imposter'>Get a single imposter</h3>
207
+
208
+ <pre><code>GET /imposters/:port</code></pre>
209
+
210
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
211
+
212
+ <p>Retrieving an imposter is generally useful for one the following reasons:</p>
213
+
214
+ <ul class='bullet-list'>
215
+ <li>You want to perform <a href='/docs/api/mocks'>mock verifications</a> by inspecting the
216
+ <a href='/docs/api/mocks'><code>requests</code> array</a>).</li>
217
+ <li>You want to debug <a href='/docs/api/predicates'>stub predicates</a> by inspecting the
218
+ <a href='/docs/api/stubs#matches-array'><code>matches</code> array</a> (you must run
219
+ <code>mb</code> with the <a href='/docs/commandLine'> <code>--debug</code> command line
220
+ parameter</a> for this to work).</li>
221
+ <li>You <a href='/docs/api/proxies'>proxied</a> a real service, and want to be save off the
222
+ saved responses in a subsequent disconnected test run.</li>
223
+ </ul>
224
+
225
+ <p><strong>Query Parameters:</strong></p>
226
+
227
+ <table>
228
+ <tr>
229
+ <th>Name</th>
230
+ <th>Type</th>
231
+ <th>Description</th>
232
+ </tr>
233
+ <tr>
234
+ <td><code>replayable</code></td>
235
+ <td>boolean</td>
236
+ <td>Set to <code>true</code> to retrieve the minimum amount of information for
237
+ <a href='#post-imposters'>creating the imposter</a> in the future. This leaves
238
+ out the <a href='/docs/api/mocks'><code>requests</code> array</a> and any hypermedia.</td>
239
+ </tr>
240
+ <tr>
241
+ <td><code>removeProxies</code></td>
242
+ <td>boolean</td>
243
+ <td>Set to <code>true</code> to remove all proxy responses (and stubs) from the response.
244
+ This is useful in record-playback scenarios where you want to seed the imposters with
245
+ proxy information but leave it out on subsequent test runs. You can
246
+ <a href='#post-imposters'>recreate the imposter</a> in the future by using the response.</td>
247
+ </tr>
248
+ </table>
249
+
250
+ <step type='http'>
251
+ <pre><code>GET /imposters/4545 HTTP/1.1
252
+ Host: localhost:<%= port %>
253
+ Accept: application/json
254
+ </code></pre>
255
+
256
+ <assertResponse>
257
+ <pre><code>HTTP/1.1 200 OK
258
+ Vary: Accept
259
+ Content-Type: application/json; charset=utf-8
260
+ Content-Length: 298
261
+ Date: <volatile>Sun, 05 Jan 2014 16:59:33 GMT</volatile>
262
+ Connection: keep-alive
263
+
264
+ {
265
+ "protocol": "http",
266
+ "port": 4545,
267
+ "numberOfRequests": 0,
268
+ "recordRequests": false,
269
+ "requests": [],
270
+ "stubs": [],
271
+ "_links": {
272
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
273
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
274
+ }
275
+ }</code></pre>
276
+ </assertResponse>
277
+ </step>
278
+
279
+ <p>Had we set the <code>replayable</code> query parameter, the
280
+ <a href='/docs/api/mocks'><code>requests</code> array</a> and
281
+ <code>_links</code> elements would not be there. If we had any <a href='/docs/api/stubs'>stubs</a>,
282
+ the <a href='/docs/api/stubs#matches-array'><code>matches</code> array</a> would also not be present
283
+ regardless of whether we ran <code>mb</code> with the <code>--debug</code> command line parameter or
284
+ not. None of those fields are used during the creation of an imposter.</p>
285
+
286
+ <step type='http'>
287
+ <pre><code>GET /imposters/4545?replayable=true HTTP/1.1
288
+ Host: localhost:<%= port %>
289
+ Accept: application/json</code></pre>
290
+
291
+ <assertResponse>
292
+ <pre><code>HTTP/1.1 200 OK
293
+ Vary: Accept
294
+ Content-Type: application/json; charset=utf-8
295
+ Content-Length: 82
296
+ Date: <volatile>Sun, 05 Jan 2014 16:59:33 GMT</volatile>
297
+ Connection: keep-alive
298
+
299
+ {
300
+ "protocol": "http",
301
+ "port": 4545,
302
+ "recordRequests": false,
303
+ "stubs": []
304
+ }</code></pre>
305
+ </assertResponse>
306
+ </step>
307
+
308
+ <h3 id='add-stub'>Add a stub to an existing imposter</h3>
309
+
310
+ <p><b>Request contract</b>: <a href='/docs/api/contracts?type=addStub'>add stub</a></p>
311
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
312
+
313
+ <pre><code>POST /imposters/:port/stubs</code></pre>
314
+
315
+ <p>In most cases, you would add the stubs at the time you create the imposter, but this call
316
+ allows you to add a stub to an existing imposter without restarting it. You can add the
317
+ new stub at any index between 0 and the end of the existing array. If you leave off the
318
+ <code>index</code> field, the stub will be added to the end of the existing <code>stubs</code>
319
+ array. On a successful request, mountebank will return the updated imposter resource.</p>
320
+
321
+ <step type='http'>
322
+ <pre><code>POST /imposters/4545/stubs HTTP/1.1
323
+ Host: localhost:<%= port %>
324
+ Accept: application/json
325
+
326
+ {
327
+ "index": 0,
328
+ "stub": {
329
+ "responses": [{
330
+ "is": {
331
+ "body": "Hello, world!"
332
+ }
333
+ }]
334
+ }
335
+ }</code></pre>
336
+
337
+ <assertResponse>
338
+ <pre><code>HTTP/1.1 200 OK
339
+ Content-Type: application/json; charset=utf-8
340
+ Content-Length: 548
341
+ Date: <volatile>Wed, 19 Jun 2019 01:00:55 GMT</volatile>
342
+ Connection: keep-alive
343
+
344
+ {
345
+ "protocol": "http",
346
+ "port": 4545,
347
+ "numberOfRequests": 0,
348
+ "recordRequests": false,
349
+ "requests": [],
350
+ "stubs": [{
351
+ "responses": [{
352
+ "is": {
353
+ "body": "Hello, world!"
354
+ }
355
+ }],
356
+ "_links": {
357
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545/stubs/0" }
358
+ }
359
+ }],
360
+ "_links": {
361
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
362
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
363
+ }
364
+ }</code></pre>
365
+ </assertResponse>
366
+ </step>
367
+
368
+ <h3 id='change-stub'>Change a stub in an existing imposter</h3>
369
+
370
+ <pre><code>PUT /imposters/:port/stubs/:stubIndex</code></pre>
371
+
372
+ <p><b>Request contract</b>: <a href='/docs/api/contracts?type=stub'>stub</a></p>
373
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
374
+
375
+ <p>Use this endpoint to overwrite an existing stub without restarting the imposter. The
376
+ <code>stubIndex</code> must match the array index of the stub you wish to change. Pass
377
+ the new stub as the body of the request. The response will provide the updated imposter
378
+ resource.</p>
379
+
380
+ <step type='http'>
381
+ <pre><code>PUT /imposters/4545/stubs/0 HTTP/1.1
382
+ Host: localhost:<%= port %>
383
+ Accept: application/json
384
+
385
+ {
386
+ "responses": [{
387
+ "is": {
388
+ "body": "Goodbye, world!"
389
+ }
390
+ }]
391
+ }</code></pre>
392
+
393
+ <assertResponse>
394
+ <pre><code>HTTP/1.1 200 OK
395
+ Content-Type: application/json; charset=utf-8
396
+ Content-Length: 550
397
+ Date: <volatile>Wed, 19 Jun 2019 01:00:55 GMT</volatile>
398
+ Connection: keep-alive
399
+
400
+ {
401
+ "protocol": "http",
402
+ "port": 4545,
403
+ "numberOfRequests": 0,
404
+ "recordRequests": false,
405
+ "requests": [],
406
+ "stubs": [{
407
+ "responses": [{
408
+ "is": {
409
+ "body": "Goodbye, world!"
410
+ }
411
+ }],
412
+ "_links": {
413
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545/stubs/0" }
414
+ }
415
+ }],
416
+ "_links": {
417
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
418
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
419
+ }
420
+ }</code></pre>
421
+ </assertResponse>
422
+ </step>
423
+
424
+ <h3 id='change-stubs'>Overwrite all stubs in an existing imposter</h3>
425
+
426
+ <pre><code>PUT /imposters/:port/stubs</code></pre>
427
+
428
+ <p><b>Request contract</b>: <a href='/docs/api/contracts?type=stubs'>stubs</a></p>
429
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
430
+
431
+ <p>Use this endpoint to overwrite all existing stub without restarting the imposter. The
432
+ response will provide the updated imposter resource.</p>
433
+
434
+ <step type='http'>
435
+ <pre><code>PUT /imposters/4545/stubs HTTP/1.1
436
+ Host: localhost:<%= port %>
437
+ Accept: application/json
438
+
439
+ {
440
+ "stubs": [{
441
+ "responses": [{
442
+ "is": { "body": "New stub" }
443
+ }]
444
+ }]
445
+ }</code></pre>
446
+
447
+ <assertResponse>
448
+ <pre><code>HTTP/1.1 200 OK
449
+ Content-Type: application/json; charset=utf-8
450
+ Content-Length: 543
451
+ Date: <volatile>Wed, 19 Jun 2019 01:00:55 GMT</volatile>
452
+ Connection: keep-alive
453
+
454
+ {
455
+ "protocol": "http",
456
+ "port": 4545,
457
+ "numberOfRequests": 0,
458
+ "recordRequests": false,
459
+ "requests": [],
460
+ "stubs": [
461
+ {
462
+ "responses": [{
463
+ "is": { "body": "New stub" }
464
+ }],
465
+ "_links": {
466
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545/stubs/0" }
467
+ }
468
+ }
469
+ ],
470
+ "_links": {
471
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
472
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
473
+ }
474
+ }</code></pre>
475
+ </assertResponse>
476
+ </step>
477
+
478
+ <h3 id='delete-stub'>Remove a single stub from an existing imposter</h3>
479
+
480
+ <pre><code>DELETE /imposters/:port/stubs/:stubIndex</code></pre>
481
+
482
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
483
+
484
+ <p>Use this endpoint to remove the stub at the given array index without restarting the imposter. The
485
+ response will provide the updated imposter resource.</p>
486
+
487
+ <step type='http'>
488
+ <pre><code>DELETE /imposters/4545/stubs/0 HTTP/1.1
489
+ Host: localhost:<%= port %>
490
+ Accept: application/json</code></pre>
491
+
492
+ <assertResponse>
493
+ <pre><code>HTTP/1.1 200 OK
494
+ Content-Type: application/json; charset=utf-8
495
+ Content-Length: 298
496
+ Date: <volatile>Wed, 19 Jun 2019 01:00:55 GMT</volatile>
497
+ Connection: keep-alive
498
+
499
+ {
500
+ "protocol": "http",
501
+ "port": 4545,
502
+ "numberOfRequests": 0,
503
+ "recordRequests": false,
504
+ "requests": [],
505
+ "stubs": [],
506
+ "_links": {
507
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
508
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
509
+ }
510
+ }</code></pre>
511
+ </assertResponse>
512
+ </step>
513
+
514
+ <h3 id='delete-imposter'>Delete a single imposter</h3>
515
+
516
+ <pre><code>DELETE /imposters/:port</code></pre>
517
+
518
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
519
+
520
+ <p>As mentioned above, typically you want to delete the imposter after each test run. This
521
+ frees up the socket and removes the resource. As a convenience, the <code>DELETE</code> call
522
+ also returns the imposter representation just like a <a href='#get-imposter'><code>GET</code> imposter</a>
523
+ would. This allows you to optimize the number of REST calls made during a test run when looking
524
+ at the <code>requests</code> array for <a href='/docs/api/mocks'>mock verification.</a><p>
525
+
526
+ <p><strong>Query Parameters:</strong></p>
527
+
528
+ <table>
529
+ <tr>
530
+ <th>Name</th>
531
+ <th>Type</th>
532
+ <th>Description</th>
533
+ </tr>
534
+ <tr>
535
+ <td><code>replayable</code></td>
536
+ <td>boolean</td>
537
+ <td>Set to <code>true</code> to retrieve the minimum amount of information for
538
+ <a href='#post-imposters'>creating the imposter</a> in the future. This leaves
539
+ out the <a href='/docs/api/mocks'><code>requests</code> array</a> and any hypermedia.</td>
540
+ </tr>
541
+ <tr>
542
+ <td><code>removeProxies</code></td>
543
+ <td>boolean</td>
544
+ <td>Set to <code>true</code> to remove all proxy responses (and stubs) from the response.
545
+ This is useful in record-playback scenarios where you want to seed the imposters with
546
+ proxy information but leave it out on subsequent test runs. You can
547
+ <a href='#post-imposters'>recreate the imposter</a> in the future by using the response.</td>
548
+ </tr>
549
+ </table>
550
+
551
+ <step type='http'>
552
+ <pre><code>DELETE /imposters/4545 HTTP/1.1
553
+ Host: localhost:<%= port %>
554
+ Accept: application/json</code></pre>
555
+
556
+ <assertResponse>
557
+ <pre><code>HTTP/1.1 200 OK
558
+ Content-Type: application/json; charset=utf-8
559
+ Content-Length: 298
560
+ Date: <volatile>Sun, 05 Jan 2014 16:59:33 GMT</volatile>
561
+ Connection: keep-alive
562
+
563
+ {
564
+ "protocol": "http",
565
+ "port": 4545,
566
+ "numberOfRequests": 0,
567
+ "recordRequests": false,
568
+ "requests": [],
569
+ "stubs": [],
570
+ "_links": {
571
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
572
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
573
+ }
574
+ }
575
+ </code></pre>
576
+ </assertResponse>
577
+ </step>
578
+
579
+ <h3 id='delete-proxy-responses'>Delete saved proxy responses from an imposter</h3>
580
+
581
+ <pre><code>DELETE /imposters/:port/savedProxyResponses</code></pre>
582
+
583
+ <p><a href='/docs/api/proxies'>Proxy stubs</a> save all responses returned from downstream systems. Usually
584
+ this is what you want, as they can be played back at a later time without the actual downstream system
585
+ available. However, if you need to clear them but keep the stubs intact, you can do so with this call.<p>
586
+
587
+ <p class='info-icon'>Note that you can prevent the proxy from saving responses by setting the <code>mode</code>
588
+ to <a href='/docs/api/proxies#proxy-modes'><code>proxyTransparent</code></a>.</p>
589
+
590
+ <h3 id='delete-requests'>Delete saved requests from an imposter</h3>
591
+
592
+ <pre><code>DELETE /imposters/:port/savedRequests</code></pre>
593
+
594
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposter'>imposter</a></p>
595
+
596
+ <p>Clear an imposter's recorded requests (used for <a href='/docs/api/mocks'>mock verification</a>) while leaving the rest of the imposter intact.
597
+ On a successful request, mountebank will return the updated imposter resource.</p>
598
+
599
+ <h3 id='put-imposters'>Overwrite all imposters with a new set of imposters</h3>
600
+
601
+ <pre><code>PUT /imposters</code></pre>
602
+
603
+ <p><b>Request contract</b>: <a href='/docs/api/contracts?type=imposters'>imposters</a></p>
604
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposters'>imposters</a></p>
605
+
606
+ <p>Sometimes you want to create a batch of imposters in a single call, overwriting
607
+ any imposters already created. This call is destructive - it will first delete all
608
+ existing imposters. The output of a <code>GET /imposters?replayable=true</code> can
609
+ directly be replayed through this call. This call is also used during startup
610
+ if you set the <code>--configfile</code> <a href='/docs/commandLine'>command line</a>
611
+ flag.</p>
612
+
613
+ <p><strong>Parameters:</strong></p>
614
+
615
+ <p>You must provide mountebank an <code>imposters</code> array. Each element in the
616
+ array is the same as what's needed to <a href='#post-imposters'>create a single imposter</a>,
617
+ the parameters for which vary by protocol. View the protocol pages on the left for details.</p>
618
+
619
+ <step type='http'>
620
+ <pre><code>PUT /imposters HTTP/1.1
621
+ Host: localhost:<%= port %>
622
+ Content-Type: application/json
623
+
624
+ {
625
+ "imposters": [
626
+ {
627
+ "protocol": "http",
628
+ "port": 4546
629
+ },
630
+ {
631
+ "protocol": "tcp",
632
+ "port": 4547,
633
+ "mode": "binary"
634
+ },
635
+ {
636
+ "protocol": "smtp",
637
+ "port": 4548
638
+ }
639
+ ]
640
+ }</code></pre>
641
+
642
+ <assertResponse>
643
+ <pre><code>
644
+ HTTP/1.1 200 OK
645
+ Content-Type: application/json; charset=utf-8
646
+ Content-Length: 898
647
+ Date: <volatile>Sun, 05 Jan 2014 16:59:33 GMT</volatile>
648
+ Connection: keep-alive
649
+
650
+ {
651
+ "imposters": [
652
+ {
653
+ "protocol": "http",
654
+ "port": 4546,
655
+ "numberOfRequests": 0,
656
+ "_links": {
657
+ "self": { "href": "http://localhost:<%= port %>/imposters/4546" },
658
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4546/stubs" }
659
+ }
660
+ },
661
+ {
662
+ "protocol": "tcp",
663
+ "port": 4547,
664
+ "numberOfRequests": 0,
665
+ "_links": {
666
+ "self": { "href": "http://localhost:<%= port %>/imposters/4547" },
667
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4547/stubs" }
668
+ }
669
+ },
670
+ {
671
+ "protocol": "smtp",
672
+ "port": 4548,
673
+ "numberOfRequests": 0,
674
+ "_links": {
675
+ "self": { "href": "http://localhost:<%= port %>/imposters/4548" },
676
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4548/stubs" }
677
+ }
678
+ }
679
+ ]
680
+ }</code></pre>
681
+ </assertResponse>
682
+ </step>
683
+
684
+ <h3 id='get-imposters'>Get a list of all imposters</h3>
685
+
686
+ <pre><code>GET /imposters</code></pre>
687
+
688
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposters'>imposters</a></p>
689
+
690
+ <p>This is where you will come to retrieve a list of all active imposters. By default,
691
+ mountebank returns some basic information and hypermedia. If you want more information,
692
+ either <a href='#get-imposter'>get the single imposter</a> or use the
693
+ <code>replayable</code> flag.</p>
694
+
695
+ <p><strong>Query Parameters:</strong></p>
696
+
697
+ <table>
698
+ <tr>
699
+ <th>Name</th>
700
+ <th>Type</th>
701
+ <th>Description</th>
702
+ </tr>
703
+ <tr>
704
+ <td><code>replayable</code></td>
705
+ <td>boolean</td>
706
+ <td>Set to <code>true</code> to retrieve the minimum amount of information for replaying
707
+ the set of imposters in the future through a <a href='#put-imposters'>mass create</a>
708
+ call. This leaves out the <a href='/docs/api/mocks'><code>requests</code> array</a>
709
+ and any hypermedia.</td>
710
+ </tr>
711
+ <tr>
712
+ <td><code>removeProxies</code></td>
713
+ <td>boolean</td>
714
+ <td>Set to <code>true</code> to remove all proxy responses (and stubs) from the response.
715
+ This is useful in record-playback scenarios where you want to seed the imposters with
716
+ proxy information but leave it out on subsequent test runs. You can
717
+ <a href='#put-imposters'>recreate the imposter</a> in the future by using the response.</td>
718
+ </tr>
719
+ </table>
720
+
721
+ <step type='http'>
722
+ <pre><code>GET /imposters HTTP/1.1
723
+ Host: localhost:<%= port %>
724
+ Accept: application/json</code></pre>
725
+
726
+ <assertResponse>
727
+ <pre><code>HTTP/1.1 200 OK
728
+ Vary: Accept
729
+ Content-Type: application/json; charset=utf-8
730
+ Content-Length: 898
731
+ Date: <volatile>Sun, 05 Jan 2014 16:58:25 GMT</volatile>
732
+ Connection: keep-alive
733
+
734
+ {
735
+ "imposters": [
736
+ {
737
+ "protocol": "http",
738
+ "port": 4546,
739
+ "numberOfRequests": 0,
740
+ "_links": {
741
+ "self": { "href": "http://localhost:<%= port %>/imposters/4546" },
742
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4546/stubs" }
743
+ }
744
+ },
745
+ {
746
+ "protocol": "tcp",
747
+ "port": 4547,
748
+ "numberOfRequests": 0,
749
+ "_links": {
750
+ "self": { "href": "http://localhost:<%= port %>/imposters/4547" },
751
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4547/stubs" }
752
+ }
753
+ },
754
+ {
755
+ "protocol": "smtp",
756
+ "port": 4548,
757
+ "numberOfRequests": 0,
758
+ "_links": {
759
+ "self": { "href": "http://localhost:<%= port %>/imposters/4548" },
760
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4548/stubs" }
761
+ }
762
+ }
763
+ ]
764
+ }</code></pre>
765
+ </assertResponse>
766
+ </step>
767
+
768
+ <h3 id='delete-imposters'>Delete all imposters</h3>
769
+
770
+ <pre><code>DELETE /imposters</code></pre>
771
+
772
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=imposters'>imposters</a></p>
773
+
774
+ <p>The surest way to reset to a clean slate is to delete all imposters. Any imposter sockets
775
+ mountebank has open will be closed, and the response body will contain exactly what you need
776
+ to <a href='#put-imposters'>mass create</a> the same imposters in the future.</p>
777
+
778
+ <p><strong>Query Parameters:</strong></p>
779
+
780
+ <table>
781
+ <tr>
782
+ <th>Name</th>
783
+ <th>Type</th>
784
+ <th>Description</th>
785
+ </tr>
786
+ <tr>
787
+ <td><code>replayable</code></td>
788
+ <td>boolean</td>
789
+ <td>Defaults to true. Set to <code>false</code> to retrieve the
790
+ <a href='/docs/api/mocks'><code>requests</code></a> arrays with the response. You can still
791
+ <a href='#put-imposters'>mass create</a> using this JSON; it just has extraneous information.</td>
792
+ </tr>
793
+ <tr>
794
+ <td><code>removeProxies</code></td>
795
+ <td>boolean</td>
796
+ <td>Set to <code>true</code> to remove all proxy responses (and stubs) from the response.
797
+ This is useful in record-playback scenarios where you want to seed the imposters with
798
+ proxy information but leave it out on subsequent test runs. You can
799
+ <a href='#put-imposters'>recreate the imposters</a> in the future by using the response.</td>
800
+ </tr>
801
+ </table>
802
+
803
+ <step type='http'>
804
+ <pre><code>DELETE /imposters HTTP/1.1
805
+ Host: localhost:<%= port %>
806
+ Accept: application/json</code></pre>
807
+
808
+ <assertResponse>
809
+ <pre><code>HTTP/1.1 200 OK
810
+ Content-Type: application/json; charset=utf-8
811
+ Content-Length: 370
812
+ Date: <volatile>Sun, 05 Jan 2014 16:58:25 GMT</volatile>
813
+ Connection: keep-alive
814
+
815
+ {
816
+ "imposters": [
817
+ {
818
+ "protocol": "http",
819
+ "port": 4546,
820
+ "recordRequests": false,
821
+ "stubs": []
822
+ },
823
+ {
824
+ "protocol": "tcp",
825
+ "port": 4547,
826
+ "recordRequests": false,
827
+ "mode": "binary",
828
+ "stubs": []
829
+ },
830
+ {
831
+ "protocol": "smtp",
832
+ "port": 4548,
833
+ "recordRequests": false,
834
+ "stubs": []
835
+ }
836
+ ]
837
+ }</code></pre>
838
+ </assertResponse>
839
+ </step>
840
+
841
+ <h3 id='get-config'>Get mountebank configuration and process information</h3>
842
+
843
+ <pre><code>GET /config</code></pre>
844
+
845
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=config'>config</a></p>
846
+
847
+ <p>If you want to know about the environment mountebank is running it, this resource will give you
848
+ what you need. It describes the version, command line flags, and process information.</p>
849
+
850
+ <step type='http'>
851
+ <pre><code>GET /config HTTP/1.1
852
+ Host: localhost:<%= port %>
853
+ Accept: application/json</code></pre>
854
+
855
+ <assertResponse>
856
+ <pre><code>HTTP/1.1 200 OK
857
+ Vary: Accept
858
+ Content-Type: application/json; charset=utf-8
859
+ Content-Length: <volatile>550</volatile>
860
+ Date: <volatile>Sat, 13 May 2017 23:41:31 GMT</volatile>
861
+ Connection: keep-alive
862
+
863
+ {
864
+ "version": "<%= version %>",
865
+ "options": {
866
+ "port": <%= port %>,
867
+ "pidfile": "mb.pid",
868
+ "allowInjection": true,
869
+ "apikey": null,
870
+ "localOnly": true, <% if (process.env.MB_PERSISTENT === 'true') { %>
871
+ "datadir": ".mbdb", <% } %>
872
+ "noParse": false,
873
+ "formatter": "mountebank-formatters",
874
+ "ipWhitelist": [
875
+ "*"
876
+ ],
877
+ "debug": false,
878
+ "protofile": "protocols.json",
879
+ "origin": false,
880
+ "log": {
881
+ "level": "info",
882
+ "transports": {
883
+ "console": {
884
+ "colorize": true,
885
+ "format": "%level: %message"
886
+ },
887
+ "file": {
888
+ "path": "mb.log",
889
+ "format": "json"
890
+ }
891
+ }
892
+ }
893
+ },
894
+ "process": {
895
+ "nodeVersion": "<volatile>v5.8.0</volatile>",
896
+ "architecture": "<volatile>x64</volatile>",
897
+ "platform": "<volatile>darwin</volatile>",
898
+ "rss": <volatile>43393024</volatile>,
899
+ "heapTotal": <volatile>32266016</volatile>,
900
+ "heapUsed": <volatile>20060904</volatile>,
901
+ "uptime": <volatile>69.108</volatile>,
902
+ "cwd": "<volatile>/Users/bbyars/src/mountebank</volatile>"
903
+ }
904
+ }</code></pre>
905
+ </assertResponse>
906
+ </step>
907
+
908
+ <h3 id='get-logs'>Get the logs</h3>
909
+
910
+ <pre><code>GET /logs</code></pre>
911
+
912
+ <p><b>Response contract</b>: <a href='/docs/api/contracts?type=logs'>logs</a></p>
913
+
914
+ <p><strong>Query Parameters:</strong></p>
915
+
916
+ <table>
917
+ <tr>
918
+ <th>Name</th>
919
+ <th>Type</th>
920
+ <th>Description</th>
921
+ </tr>
922
+ <tr>
923
+ <td><code>startIndex</code></td>
924
+ <td>integer</td>
925
+ <td>Set to array index of the first log entry you want returned.</td>
926
+ </tr>
927
+ <tr>
928
+ <td><code>endIndex</code></td>
929
+ <td>integer</td>
930
+ <td>Set to the array index of the last log entry you want returned</td>
931
+ </tr>
932
+ </table>
933
+
934
+ <step type='http'>
935
+ <pre><code>GET /logs?startIndex=0&endIndex=1 HTTP/1.1
936
+ Host: localhost:<%= port %>
937
+ Accept: application/json</code></pre>
938
+
939
+ <assertResponse>
940
+ <pre><code>HTTP/1.1 200 OK
941
+ Vary: Accept
942
+ Content-Type: application/json; charset=utf-8
943
+ Content-Length: <volatile>5249</volatile>
944
+ Date: <volatile>Sat, 13 May 2017 23:45:07 GMT</volatile>
945
+ Connection: keep-alive
946
+
947
+ {
948
+ "logs": [
949
+ {
950
+ "message": "[mb:<%= port %>] Running with --allowInjection set. See http://localhost:<%= port %>/docs/security for security info",
951
+ "level": "warn",
952
+ "timestamp": "<volatile>2015-10-20T03:33:23.019Z</volatile>"
953
+ },
954
+ {
955
+ "message": "[mb:<%= port %>] mountebank v<%= version %> now taking orders - point your browser to http://localhost:<%= port %>/ for help",
956
+ "level": "info",
957
+ "timestamp": "<volatile>2015-10-20T03:33:23.018Z</volatile>"
958
+ }
959
+ ]
960
+ }</code></pre>
961
+ </assertResponse>
962
+ </step>
963
+ </testScenario>
964
+
965
+ <p>In the rare scenario where mountebank is hosted on a different server and you need access to the logs,
966
+ they are accessible through this endpoint.</p>
967
+
968
+ <%- include('../../_footer') -%>