@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,246 @@
1
+ <%
2
+ title = 'https'
3
+ description = 'The HTTPS protocol support provided by mountebank'
4
+ %>
5
+
6
+ <%- include('../../_header') -%>
7
+
8
+ <h1>https</h1>
9
+
10
+ <p>The https is very similar to the http protocol, except for the fact that it uses
11
+ a certificate key pair. If you use the built-in self-signed certificate, you may have to
12
+ configure your code to disable certificate validation (e.g. use the <code>-k</code>
13
+ switch in <code>curl</code>). Alternatively, you may pass in the key pair yourself.</p>
14
+
15
+ <h2>Imposter Creation Parameters</h2>
16
+
17
+ <table>
18
+ <tr>
19
+ <th>Parameter</th>
20
+ <th>Options</th>
21
+ <th>Required?</th>
22
+ <th>Default</th>
23
+ <th>Description</th>
24
+ </tr>
25
+ <tr>
26
+ <td><code>protocol</code></td>
27
+ <td><code>https</code></td>
28
+ <td>Yes</td>
29
+ <td>N/A</td>
30
+ <td>&nbsp;</td>
31
+ </tr>
32
+ <tr>
33
+ <td><code>port</code></td>
34
+ <td>Any valid port number</td>
35
+ <td>No</td>
36
+ <td>A randomly assigned port. mountebank will return the actual value
37
+ in the <code>POST</code> response.</td>
38
+ <td>The port to run the imposter on.</td>
39
+ </tr>
40
+ <tr>
41
+ <td><code>key</code></td>
42
+ <td>A PEM-formatted string</td>
43
+ <td>No</td>
44
+ <td>A built in private key</td>
45
+ <td>The SSL server private key</td>
46
+ </tr>
47
+ <tr>
48
+ <td><code>cert</code></td>
49
+ <td>A PEM-formatted string</td>
50
+ <td>No</td>
51
+ <td>A built in self-signed certificate</td>
52
+ <td>The SSL server certificate</td>
53
+ </tr>
54
+ <tr>
55
+ <td><code>mutualAuth</code></td>
56
+ <td><code>true</code> or <code>false</code></td>
57
+ <td>No</td>
58
+ <td><code>false</code></td>
59
+ <td>If <code>true</code>, the server will request a client certificate.
60
+ Since the goal is simply to virtualize a server requiring mutual auth,
61
+ invalid certificates will not be rejected.</td>
62
+ </tr>
63
+ <tr>
64
+ <td><code>ciphers</code></td>
65
+ <td><a href='https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_modifying_the_default_tls_cipher_suite'>See here</a></td>
66
+ <td>No</td>
67
+ <td><a href='https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_getciphers'>Here</a></td>
68
+ <td>For older (and insecure) https servers, this field allows you to override the cipher used to communicate</td>
69
+ </tr>
70
+ <tr>
71
+ <td><code>name</code></td>
72
+ <td>Any string</td>
73
+ <td>No</td>
74
+ <td>empty string</td>
75
+ <td>Included in the logs, useful when multiple imposters are set up.</td>
76
+ </tr>
77
+ <tr>
78
+ <td><code>recordRequests</code></td>
79
+ <td><code>true</code> or <code>false</code></td>
80
+ <td>No</td>
81
+ <td>false</td>
82
+ <td>Adds <a href='/docs/api/mocks'>mock verification</a> support by remembering the requests
83
+ made to this imposter. Note that this represents a memory leak for any long running
84
+ <code>mb</code> process, as requests are never forgotten.</td>
85
+ </tr>
86
+ <tr>
87
+ <td><code>stubs</code></td>
88
+ <td>Valid stubs</td>
89
+ <td>No</td>
90
+ <td>An empty array</td>
91
+ <td>The list of stubs responsible for matching a request and returning a response</td>
92
+ </tr>
93
+ <tr>
94
+ <td><code>defaultResponse</code></td>
95
+ <td>A valid response, see the <a href='/docs/protocols/http'>http</a> page for response fields</td>
96
+ <td>No</td>
97
+ <td><pre><code>
98
+ {
99
+ "statusCode": 200,
100
+ "headers": {
101
+ "connection": "close"
102
+ },
103
+ "body": ""
104
+ }
105
+ </code></pre></td>
106
+ <td>The default response to send if no predicate matches. Also represents the default values
107
+ that get merged into a response that doesn't specify every field</td>
108
+ </tr>
109
+ <tr>
110
+ <td><code>allowCORS</code></td>
111
+ <td>boolean</td>
112
+ <td>No</td>
113
+ <td>false</td>
114
+ <td>If true, mountebank will allow all CORS preflight requests on the imposter.</td>
115
+ </tr>
116
+ <tr>
117
+ <td><code>rejectUnauthorized</code></td>
118
+ <td>boolean</td>
119
+ <td>No</td>
120
+ <td>false</td>
121
+ <td>If true, mountebank will validate the certificate against the list of supplied CAs.</td>
122
+ </tr>
123
+ <tr>
124
+ <td><code>ca</code></td>
125
+ <td>Array of PEM-formatted certificates</td>
126
+ <td>No</td>
127
+ <td>null</td>
128
+ <td>Use when setting <code>rejectUnauthorized</code> to true to provide a list of certificates to validate against.
129
+ When <code>rejectUnauthorized</code> is true and <code>mutualAuth</code> is true, mountebank will request a client certificate.</td>
130
+ </tr>
131
+ </table>
132
+
133
+ <p>See the <a href='/docs/protocols/http'>http</a> page for examples. Just be sure
134
+ to change the <code>protocol</code> parameter to <code>https</code> during imposter
135
+ creation!</p>
136
+
137
+ <h2>Handling trust</h2>
138
+
139
+ <p>By default, mountebank will use an internal self-signed certificate. While this allows you
140
+ to explore the API in a simple zero-config manner, it also means that you need to configure
141
+ your system under test to ignore trust errors. This is A Very Bad Idea. It puts you at risk
142
+ of accidentally leaving that configuration in production, exposing your network to unnecessary risk.</p>
143
+
144
+ <p>There are at least three solutions that are safe for testing and remove the possibility
145
+ of your test strategy causing trust violations in production:</p>
146
+
147
+ <ul class='bullet-list'>
148
+ <li>Test against an http imposter, and trust that the SSL/TLS libraries your system under
149
+ test is using just work.</li>
150
+ <li>Create your own self-signed certificate for testing <i>and add it to your local trust store only.</i>
151
+ Have a look at <a href='https://github.com/FiloSottile/mkcert'>mkcert</a> for a simple way
152
+ of doing this.</li>
153
+ <li>Use a real trusted certificate for testing. If you can't have your organization create
154
+ one for you, <a href='https://letsencrypt.org/'>Let's Encrypt</a> offers a free service
155
+ to create trusted certificates.</li>
156
+ </ul>
157
+
158
+ <p>The mutual authentication example below shows including them in your imposter setup.</p>
159
+
160
+ <h2>Mutual Authentication</h2>
161
+
162
+ <p>mountebank supports mutual authentication involving client certificates both for the
163
+ server itself and through proxies. The following example demonstrates this capability,
164
+ as well as setting up your own certificate for the server. First we'll set up a server
165
+ that expects client certificates by using the <code>mutualAuth</code> field:</p>
166
+
167
+ <testScenario name='https-mutual-auth'>
168
+ <step type='http'>
169
+ <pre><code>POST /imposters HTTP/1.1
170
+ Host: localhost:<%= port %>
171
+ Accept: application/json
172
+ Content-Type: application/json
173
+
174
+ {
175
+ "port": 4545,
176
+ "protocol": "https",
177
+ "name": "origin server",
178
+ <strong class='highlight2'>"mutualAuth": true</strong>,
179
+ "key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCrvse04YkxtVGagyvGJCsvv7LTfLK5uR/ZIJKDYCnuF+BqBzM4\nlko8O39vx+Lz9FfF11Xl+CN1aY37YurLYOle3dC/qslSbQDe2TJN7lcVHVssePvc\nO5IExpvNFV5LYtmyCMKJHxpnIprv/trUso5obqzzXhFVPV9SQbFH/snInwIDAQAB\nAoGARywlqLD6YO4qJiULw+4DM6N2oSwBCPRN3XYhIW59kdy1NFtNf7rQgsuJUTJ9\nu+lbYnKNd2LwltyqaS4h7Sx5KRhpFNmMpyVsBf5J2q3fbfmrsXt+emY7XhVTc1NV\nizUWYyxCoTTeMWvN/6NYpPV0lSxq7jMTFVZrWQUMqJclxpECQQDTlGwALtAX1Y8u\nGKsEHPkoq9bhHA5N9WAboQ4LQCZVC8eBf/XH//2iosYTXRNgII2JLmHmmxJHo5iN\nJPFMbnoHAkEAz81osJf+yHm7PBBJP4zEWZCV25c+iJiPDpj5UoUXEbq47qVfy1mV\nDqy2zoDynAWitU7PeHyZ8ozfyribPoR2qQJAVmvMhXKZmvKnLivzRpXTC9LMzVwZ\nV6x/Wim5w8yrG5fZIMM0kEG2xwR3pZch/+SsCzl/0aLLn6lp+VT6nr6NZwJBAMxs\nHrvymoLvNeDtiJFK0nHliXafP7YyljDfDg4+vSYE0R57c1RhSQBJqgBV29TeumSw\nJes6cFuqeBE+MAJ9XxkCQDdUdhnA8HHQRNetqK7lygUep7EcHHCB6u/0FypoLw7o\nEUVo5KSEFq93UeMr3B7DDPIz3LOrFXlm7clCh1HFZhQ=\n-----END RSA PRIVATE KEY-----",
180
+ "cert": "-----BEGIN CERTIFICATE-----\nMIIB6TCCAVICCQCZgxbBD0CG4zANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKU29tZS1TdGF0ZTEVMBMGA1UEChMMVGhvdWdodFdvcmtzMB4X\nDTEzMTIyOTE2NDAzN1oXDTE0MDEyODE2NDAzN1owOTELMAkGA1UEBhMCVVMxEzAR\nBgNVBAgTClNvbWUtU3RhdGUxFTATBgNVBAoTDFRob3VnaHRXb3JrczCBnzANBgkq\nhkiG9w0BAQEFAAOBjQAwgYkCgYEAq77HtOGJMbVRmoMrxiQrL7+y03yyubkf2SCS\ng2Ap7hfgagczOJZKPDt/b8fi8/RXxddV5fgjdWmN+2Lqy2DpXt3Qv6rJUm0A3tky\nTe5XFR1bLHj73DuSBMabzRVeS2LZsgjCiR8aZyKa7/7a1LKOaG6s814RVT1fUkGx\nR/7JyJ8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQCPhixeKxIy+ftrfPikwjYo1uxp\ngQ18FdVN1pbI//IIx1o8kJuX8yZzO95PsCOU0GbIRCkFMhBlqHiD9H0/W/GvWzjf\n7WFW15lL61y/kH1J0wqEgoaMrUDjHZvKVr0HrN+vSxHlNQcSNFJ2KdvZ5a9dhpGf\nXOdprCdUUXzSoJWCCg==\n-----END CERTIFICATE-----",
181
+ "stubs": [{
182
+ "responses": [<strong class='highlight1'>{ "is": { "body": "It worked!" } }</strong>]
183
+ }]
184
+ }
185
+ </code></pre>
186
+ </step>
187
+
188
+ <p>If we try and connect to this server without providing a client certificate, it will immediately terminate the connection.
189
+ Let's create an imposter that will proxy to it, providing the necessary credentials:</p>
190
+
191
+ <step type='http'>
192
+ <pre><code>POST /imposters HTTP/1.1
193
+ Host: localhost:<%= port %>
194
+ Accept: application/json
195
+ Content-Type: application/json
196
+
197
+ {
198
+ "port": 5555,
199
+ "protocol": "http",
200
+ "name": "proxy",
201
+ "stubs": [
202
+ {
203
+ "responses": [
204
+ {
205
+ "proxy": {
206
+ "to": "https://localhost:4545",
207
+ <strong class='highlight2'>"key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCrvse04YkxtVGagyvGJCsvv7LTfLK5uR/ZIJKDYCnuF+BqBzM4\nlko8O39vx+Lz9FfF11Xl+CN1aY37YurLYOle3dC/qslSbQDe2TJN7lcVHVssePvc\nO5IExpvNFV5LYtmyCMKJHxpnIprv/trUso5obqzzXhFVPV9SQbFH/snInwIDAQAB\nAoGARywlqLD6YO4qJiULw+4DM6N2oSwBCPRN3XYhIW59kdy1NFtNf7rQgsuJUTJ9\nu+lbYnKNd2LwltyqaS4h7Sx5KRhpFNmMpyVsBf5J2q3fbfmrsXt+emY7XhVTc1NV\nizUWYyxCoTTeMWvN/6NYpPV0lSxq7jMTFVZrWQUMqJclxpECQQDTlGwALtAX1Y8u\nGKsEHPkoq9bhHA5N9WAboQ4LQCZVC8eBf/XH//2iosYTXRNgII2JLmHmmxJHo5iN\nJPFMbnoHAkEAz81osJf+yHm7PBBJP4zEWZCV25c+iJiPDpj5UoUXEbq47qVfy1mV\nDqy2zoDynAWitU7PeHyZ8ozfyribPoR2qQJAVmvMhXKZmvKnLivzRpXTC9LMzVwZ\nV6x/Wim5w8yrG5fZIMM0kEG2xwR3pZch/+SsCzl/0aLLn6lp+VT6nr6NZwJBAMxs\nHrvymoLvNeDtiJFK0nHliXafP7YyljDfDg4+vSYE0R57c1RhSQBJqgBV29TeumSw\nJes6cFuqeBE+MAJ9XxkCQDdUdhnA8HHQRNetqK7lygUep7EcHHCB6u/0FypoLw7o\nEUVo5KSEFq93UeMr3B7DDPIz3LOrFXlm7clCh1HFZhQ=\n-----END RSA PRIVATE KEY-----",
208
+ "cert": "-----BEGIN CERTIFICATE-----\nMIIB6TCCAVICCQCZgxbBD0CG4zANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKU29tZS1TdGF0ZTEVMBMGA1UEChMMVGhvdWdodFdvcmtzMB4X\nDTEzMTIyOTE2NDAzN1oXDTE0MDEyODE2NDAzN1owOTELMAkGA1UEBhMCVVMxEzAR\nBgNVBAgTClNvbWUtU3RhdGUxFTATBgNVBAoTDFRob3VnaHRXb3JrczCBnzANBgkq\nhkiG9w0BAQEFAAOBjQAwgYkCgYEAq77HtOGJMbVRmoMrxiQrL7+y03yyubkf2SCS\ng2Ap7hfgagczOJZKPDt/b8fi8/RXxddV5fgjdWmN+2Lqy2DpXt3Qv6rJUm0A3tky\nTe5XFR1bLHj73DuSBMabzRVeS2LZsgjCiR8aZyKa7/7a1LKOaG6s814RVT1fUkGx\nR/7JyJ8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQCPhixeKxIy+ftrfPikwjYo1uxp\ngQ18FdVN1pbI//IIx1o8kJuX8yZzO95PsCOU0GbIRCkFMhBlqHiD9H0/W/GvWzjf\n7WFW15lL61y/kH1J0wqEgoaMrUDjHZvKVr0HrN+vSxHlNQcSNFJ2KdvZ5a9dhpGf\nXOdprCdUUXzSoJWCCg==\n-----END CERTIFICATE-----"</strong>
209
+ }
210
+ }
211
+ ]
212
+ }
213
+ ]
214
+ }</code></pre>
215
+ </step>
216
+
217
+ <p>With the client certificate specified, we should now be able to successfully proxy:</p>
218
+
219
+ <step type='http'>
220
+ <pre><code>GET / HTTP/1.1
221
+ Host: localhost:5555</code></pre>
222
+
223
+ <assertResponse>
224
+ <pre><code>HTTP/1.1 200 OK
225
+ Connection: close
226
+ Date: <volatile>Thu, 09 Jan 2014 02:30:31 GMT</volatile>
227
+ Transfer-Encoding: chunked
228
+
229
+ <strong class='highlight1'>It worked!</strong></code></pre>
230
+ </assertResponse>
231
+ </step>
232
+
233
+ <step type='http'>
234
+ <code class='hidden'>DELETE /imposters/5555 HTTP/1.1
235
+ Host: localhost:<%= port %>
236
+ Accept: application/json</code>
237
+ </step>
238
+
239
+ <step type='http'>
240
+ <code class='hidden'>DELETE /imposters/4545 HTTP/1.1
241
+ Host: localhost:<%= port %>
242
+ Accept: application/json</code>
243
+ </step>
244
+ </testScenario>
245
+
246
+ <%- include('../../_footer') -%>
@@ -0,0 +1,142 @@
1
+ <%
2
+ title = 'smtp'
3
+ description = 'The SMTP protocol support provided by mountebank'
4
+ %>
5
+
6
+ <%- include('../../_header') -%>
7
+
8
+ <h1>smtp</h1>
9
+
10
+ <p>At the moment, the smtp imposters only support <a href='/docs/api/mocks'>mock verification</a>.
11
+ Stubbing support will come as soon as someone describes it as being worth the time to develop.
12
+ mountebank expects stub responses will be acceptance or rejection of the message.</p>
13
+
14
+ <h2>Imposter Creation Parameters</h2>
15
+
16
+ <table>
17
+ <tr>
18
+ <th>Parameter</th>
19
+ <th>Options</th>
20
+ <th>Required?</th>
21
+ <th>Default</th>
22
+ <th>Description</th>
23
+ </tr>
24
+ <tr>
25
+ <td><code>protocol</code></td>
26
+ <td><code>smtp</code></td>
27
+ <td>Yes</td>
28
+ <td>N/A</td>
29
+ <td>&nbsp;</td>
30
+ </tr>
31
+ <tr>
32
+ <td><code>port</code></td>
33
+ <td>Any valid port number</td>
34
+ <td>No</td>
35
+ <td>A randomly assigned port. mountebank will return the actual value
36
+ in the <code>POST</code> response.</td>
37
+ <td>The port to run the imposter on.</td>
38
+ </tr>
39
+ <tr>
40
+ <td><code>name</code></td>
41
+ <td>Any string</td>
42
+ <td>No</td>
43
+ <td>empty string</td>
44
+ <td>Included in the logs, useful when multiple imposters are set up.</td>
45
+ </tr>
46
+ <tr>
47
+ <td><code>recordRequests</code></td>
48
+ <td><code>true</code> or <code>false</code></td>
49
+ <td>No</td>
50
+ <td>false</td>
51
+ <td>Adds <a href='/docs/api/mocks'>mock verification</a> support by remembering the requests
52
+ made to this imposter. Note that this represents a memory leak for any long running
53
+ <code>mb</code> process, as requests are never forgotten.</td>
54
+ </tr>
55
+ </table>
56
+
57
+ <h2>SMTP Requests</h2>
58
+
59
+ <table>
60
+ <tr>
61
+ <th>Field</th>
62
+ <th>Description</th>
63
+ <th>Type</th>
64
+ </tr>
65
+ <tr>
66
+ <td><code>requestFrom</code></td>
67
+ <td>The client socket, primarily used for logging and debugging. mountebank
68
+ currently is unable to get the client port, but may fix that in the near future.</td>
69
+ <td>string</td>
70
+ </tr>
71
+ <tr>
72
+ <td><code>envelopeFrom</code></td>
73
+ <td>The from address sent in the <code>MAIL</code> command, used as the return
74
+ address for bounces. Many client SMTP APIs do not expose this field, and keep it the
75
+ same as the <code>from</code> field.</td>
76
+ <td>string</td>
77
+ </tr>
78
+ <tr>
79
+ <td><code>envelopeTo</code></td>
80
+ <td>The address sent using the <code>RCPT</code> command. Many client SMTP APIs
81
+ hide this field, deriving it from the <code>to</code>, <code>cc</code>, and
82
+ <code>bcc</code> fields.</td>
83
+ <td>string</td>
84
+ </tr>
85
+ <tr>
86
+ <td><code>from</code></td>
87
+ <td>The sender of the message (sent in the <code>DATA</code> command).</td>
88
+ <td>string</td>
89
+ </tr>
90
+ <tr>
91
+ <td><code>to</code></td>
92
+ <td>The recipients of the message (sent in the <code>DATA</code> command).</td>
93
+ <td>array</td>
94
+ </tr>
95
+ <tr>
96
+ <td><code>cc</code></td>
97
+ <td>The CC recipients of the message</td>
98
+ <td>array</td>
99
+ </tr>
100
+ <tr>
101
+ <td><code>bcc</code></td>
102
+ <td>The BCC recipients of the message</td>
103
+ <td>array</td>
104
+ </tr>
105
+ <tr>
106
+ <td><code>subject</code></td>
107
+ <td>The subject of the message</td>
108
+ <td>array</td>
109
+ </tr>
110
+ <tr>
111
+ <td><code>priority</code></td>
112
+ <td>The priority of the message</td>
113
+ <td>string</td>
114
+ </tr>
115
+ <tr>
116
+ <td><code>references</code></td>
117
+ <td>The references of the message</td>
118
+ <td>array</td>
119
+ </tr>
120
+ <tr>
121
+ <td><code>inReplyTo</code></td>
122
+ <td>The in reply to of the message</td>
123
+ <td>array</td>
124
+ </tr>
125
+ <tr>
126
+ <td><code>text</code></td>
127
+ <td>The text-only message</td>
128
+ <td>string</td>
129
+ </tr>
130
+ <tr>
131
+ <td><code>html</code></td>
132
+ <td>The html message</td>
133
+ <td>string</td>
134
+ </tr>
135
+ <tr>
136
+ <td><code>attachments</code></td>
137
+ <td>The message attachments</td>
138
+ <td>array</td>
139
+ </tr>
140
+ </table>
141
+
142
+ <%- include('../../_footer') -%>