@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,210 @@
1
+ <%
2
+ title = 'jsonpath'
3
+ description = 'Using JsonPath in mountebank predicates'
4
+ %>
5
+
6
+ <%- include('../../_header') -%>
7
+
8
+ <h1>Using JSONPath</h1>
9
+
10
+ <p>It is common for mountebank to see JSON documents in his line of business, and he suspects
11
+ the same may be true for you. With the goal of making JSON easier to work with, mountebank
12
+ accepts a <code>jsonpath</code> predicate parameter. This parameter narrows the scope of the predicate
13
+ value to a value matched by the jsonpath selector, much like the <a href='/docs/api/predicates'>
14
+ <code>except</code> parameter</a>. mountebank suggests avoiding using this parameter on fields
15
+ that are not JSON documents. He also counsels avoiding the temptation to use it with binary protocols.</p>
16
+
17
+ <p>mountebank uses the following field with jsonpath:</p>
18
+
19
+ <table>
20
+ <tr>
21
+ <th>Field</th>
22
+ <th>Required?</th>
23
+ <th>Description</th>
24
+ </tr>
25
+ <tr>
26
+ <td><code>selector</code></td>
27
+ <td>Yes</td>
28
+ <td>The JSONPath selector</td>
29
+ </tr>
30
+ </table>
31
+
32
+ <p>You can send the parameter:</p>
33
+
34
+ <pre><code>
35
+ {
36
+ "equals": {
37
+ "body": "Catcher in the Rye"
38
+ },
39
+ "jsonpath": {
40
+ "selector": "$..title"
41
+ }
42
+ }
43
+ </code></pre>
44
+
45
+ <p>The JSONPath parameter follows the same semantics as those obeyed for multi-valued keys described on the
46
+ <a href='/docs/api/predicates'>main predicates page</a>, like those observed when a querystring has
47
+ the same key multiple times. Since the JSONPath selector can potentially match multiple nodes in the JSON
48
+ document, this is an important point to make. <code>deepEquals</code> will require all the values to match
49
+ (although the order isn't important). All other predicates will match if any node value matches. The examples below
50
+ explore these semantics.</p>
51
+
52
+ <h2>Examples</h2>
53
+
54
+ <p>Let's create an HTTP imposter with multiple stubs. We'll use redundant predicates simply to
55
+ demonstrate various ways to use the <code>jsonpath</code> parameter. Where applicable, a
56
+ <code>comment</code> field is added to the JSON to explain what's going on. Like all superfluous
57
+ fields, mountebank will ignore it.</p>
58
+
59
+ <testScenario name='jsonpath'>
60
+ <step type='http'>
61
+ <pre><code>POST /imposters HTTP/1.1
62
+ Host: localhost:<%= port %>
63
+ Accept: application/json
64
+ Content-Type: application/json
65
+
66
+ {
67
+ "port": 4545,
68
+ "protocol": "http",
69
+ "stubs": [<strong class='highlight1'>{
70
+ "responses": [{ "is": { "body": "Basic jsonpath usage" } }],
71
+ "predicates": [
72
+ {
73
+ "equals": { "body": "Catcher in the Rye" },
74
+ "jsonpath": { "selector": "$..title" },
75
+ "caseSensitive": true,
76
+ "comment": "case sensitivity applies to the selector as well as the value"
77
+ },
78
+ {
79
+ "equals": { "body": "RYE" },
80
+ "jsonpath": { "selector": "$..TITLE" },
81
+ "except": "CATCHER IN THE ",
82
+ "comment": "The except regular expression is removed from the value before matching"
83
+ },
84
+ {
85
+ "matches": { "body": "^Catcher" },
86
+ "jsonpath": { "selector": "$..title" }
87
+ },
88
+ {
89
+ "exists": { "body": true },
90
+ "jsonpath": { "selector": "$..title" },
91
+ "comment": "body must exist (e.g. be empty) AND the JSONPath must match at least one node"
92
+ },
93
+ {
94
+ "exists": { "body": false },
95
+ "jsonpath": { "selector": "$..publisher" },
96
+ "comment": "body must not exist (e.g. be empty) OR the JSONPath must not match any nodes"
97
+ }
98
+ ]
99
+ }</strong>,<strong class='highlight2'>{
100
+ "responses": [{
101
+ "is": { "body": "JSONPath with attributes and the quirks of deepEquals" }
102
+ }],
103
+ "predicates": [
104
+ {
105
+ "deepEquals": { "body": "Robert Cecil Martin" },
106
+ "jsonpath": { "selector": "$.book[1].author" },
107
+ "comment": "deepEquals expects a string when there is only one match"
108
+ },
109
+ {
110
+ "deepEquals": { "body": ["J. K. Rowling", "Robert Cecil Martin", "Dr. Seuss"] },
111
+ "jsonpath": { "selector": "$.book..author" },
112
+ "comment": "Use an array for deepEquals when there are multiple matches"
113
+ }
114
+ ]
115
+ }</strong>]
116
+ }</code></pre>
117
+ </step>
118
+
119
+ <p>The first predicate uses an jsonpath selector to navigate to all <code>title</code> elements
120
+ within the JSON within the <code>body</code> field. If <code>body</code> turns out not
121
+ to be an JSON, none of them will match. The <code>caseSensitive</code> parameter applies
122
+ both to the predicate value in <code>body</code> and to the <code>selector</code> field in
123
+ <code>jsonpath</code>. The <code>exists</code> predicate behavior is identical to its behavior with
124
+ other fields, except now the jsonpath selector must also match if <code>exists</code> is <code>true</code>,
125
+ or not match if <code>exists</code> is false.<p>
126
+
127
+ <p>Note that in the example below, there are multiple nodes matching the jsonpath selector. With all
128
+ predicates except <code>deepEquals</code>, it's sufficient that <i>any</i> of them match.</p>
129
+
130
+ <step type='http'>
131
+ <pre><code>POST / HTTP/1.1
132
+ Host: localhost:4545
133
+
134
+ {
135
+ "book":[
136
+ {
137
+ "title": "Game of Thrones",
138
+ "isbn:summary": "Dragons and political intrigue",
139
+ "author": "George R.R. Martin"
140
+ },
141
+ {
142
+ <strong class='highlight1'>"title": "Catcher in the Rye"</strong>,
143
+ "isbn:summary": "It is a book",
144
+ "author": "J. D. Salinger"
145
+ },
146
+ {
147
+ "title": "Notes from the Underground",
148
+ "isbn:summary": "The world's first existentialist novel",
149
+ "author":"Fyodor Dostoyevsky"
150
+ }
151
+ ]
152
+ }</code></pre>
153
+
154
+ <assertResponse>
155
+ <pre><code>HTTP/1.1 200 OK
156
+ Connection: close
157
+ Date: <volatile>Thu, 09 Jan 2014 02:30:31 GMT</volatile>
158
+ Transfer-Encoding: chunked
159
+
160
+ <strong class='highlight1'>Basic jsonpath usage</strong></code></pre>
161
+ </assertResponse>
162
+ </step>
163
+
164
+ <p>To test the second stub, we'll use deep equals to get a specific <code>title</code>
165
+ node dependant on what book we are looking at. We can also use deep equals to get
166
+ all the corresponding nodes.</p>
167
+
168
+ <step type='http'>
169
+ <pre><code>POST / HTTP/1.1
170
+ Host: localhost:4545
171
+
172
+ {
173
+ "book":[
174
+ {
175
+ <strong class='highlight2'>"title": "Harry Potter"</strong>,
176
+ "isbn:summary": "Wizards and Magic",
177
+ "author": "J. K. Rowling"
178
+ },
179
+ {
180
+ "title": "Clean Code",
181
+ "isbn:summary": "Technological bible",
182
+ "author": "Robert Cecil Martin"
183
+ },
184
+ {
185
+ "title": "The Cat in the Hat",
186
+ "isbn:summary": "Childhood classic",
187
+ "author":"Dr. Seuss"
188
+ }
189
+ ]
190
+ }</code></pre>
191
+
192
+ <assertResponse>
193
+ <pre><code>HTTP/1.1 200 OK
194
+ Connection: close
195
+ Date: <volatile>Thu, 09 Jan 2014 02:30:31 GMT</volatile>
196
+ Transfer-Encoding: chunked
197
+
198
+ <strong class='highlight2'>JSONPath with attributes and the quirks of deepEquals</strong></code></pre>
199
+ </assertResponse>
200
+ </step>
201
+
202
+ <step type='http'>
203
+ <code class='hidden'>DELETE /imposters/4545 HTTP/1.1
204
+ Host: localhost:<%= port %>
205
+ Accept: application/json</code>
206
+ </step>
207
+
208
+ </testScenario>
209
+
210
+ <%- include('../../_footer') -%>
@@ -0,0 +1,130 @@
1
+ <%
2
+ title = 'mocks'
3
+ description = 'Using mountebank to verify network calls were made'
4
+ %>
5
+
6
+ <%- include('../../_header') -%>
7
+
8
+ <h1>Mocks</h1>
9
+
10
+ <p><a href='http://martinfowler.com/articles/mocksArentStubs.html'>Mocks</a> are a type
11
+ of test double that allow you to verify a call was made without relying on the server
12
+ response. mountebank enables mocking through the <code>requests</code> element on
13
+ an imposter. The fields saved for each request depends on the protocol, and are documented
14
+ in the protocol pages linked to from the sidebar. It is up to the client code to
15
+ implement the mock verification using the <code>requests</code> array.</p>
16
+
17
+ <p class='warning-icon'>Note, you must configure the imposter to record requests by setting the
18
+ <code>recordRequests</code> field to true to enable mock
19
+ verification. Mocking requires mountebank to remember information about each request to each imposter.
20
+ For long-running instances of mountebank, it is recommended that you run <code>mb</code> with the
21
+ <code>--datadir</code> command line option so that all requests are persisted to disk. Otherwise,
22
+ mountebank will save them to memory, which will create a significant performance constraint
23
+ when there are a large number of requests saved. You can also manually clear an imposter's saved
24
+ requests - see the <a href='/docs/api/overview'>overview page</a> for details.</p>
25
+
26
+ <h2>Example</h2>
27
+
28
+ <p>The <a href='/docs/protocols/smtp'>SMTP</a> protocol is one where mocking is very valuable,
29
+ since most applications don't rely on complex SMTP responses, but it is useful to verify
30
+ that the application sent an SMTP request without actually sending an email.</p>
31
+
32
+ <p>First let's create an imposter:</p>
33
+
34
+ <testScenario name='example'>
35
+ <step type='http'>
36
+ <pre><code>POST /imposters HTTP/1.1
37
+ Host: localhost:<%= port %>
38
+ Accept: application/json
39
+ Content-Type: application/json
40
+
41
+ {
42
+ "port": 4545,
43
+ "protocol": "smtp",
44
+ "recordRequests": true
45
+ }</code></pre>
46
+ </step>
47
+
48
+ <p>Now make the following SMTP request in your application:</p>
49
+
50
+ <step type='smtp' port='4545'>
51
+ <pre><code>From: "Customer Service" &lt;customer-service@company.com&gt;
52
+ To: "Customer" &lt;customer@domain.com&gt;
53
+ Subject: Thank you for your order
54
+
55
+ Hello Customer,
56
+ Thank you for your order from company.com. Your order will
57
+ be shipped shortly.
58
+
59
+ Your friendly customer service department.</code></pre>
60
+ </step>
61
+
62
+ <p>You can verify the call by making either a <code>GET</code> or
63
+ <code>DELETE</code> call to the imposter:</p>
64
+
65
+ <step type='http'>
66
+ <pre><code>GET /imposters/4545 HTTP/1.1
67
+ Host: localhost:<%= port %>
68
+ Accept: application/json</code></pre>
69
+
70
+ <assertResponse>
71
+ <pre><code>HTTP/1.1 200 OK
72
+ Vary: Accept
73
+ Content-Type: application/json; charset=utf-8
74
+ Content-Length: 1116
75
+ Date: <volatile>Thu, 09 Jan 2014 02:30:31 GMT</volatile>
76
+ Connection: keep-alive
77
+
78
+ {
79
+ "protocol": "smtp",
80
+ "port": 4545,
81
+ "numberOfRequests": 1,
82
+ "recordRequests": true,
83
+ <strong class='highlight1'>"requests": [
84
+ {
85
+ "requestFrom": "<volatile>127.0.0.1</volatile>",
86
+ "ip": "<volatile>127.0.0.1</volatile>",
87
+ "envelopeFrom": "customer-service@company.com",
88
+ "envelopeTo": ["customer@domain.com"],
89
+ "from": {
90
+ "address": "customer-service@company.com",
91
+ "name": "Customer Service"
92
+ },
93
+ "to": [
94
+ {
95
+ "address": "customer@domain.com",
96
+ "name": "Customer"
97
+ }
98
+ ],
99
+ "cc": [],
100
+ "bcc": [],
101
+ "subject": "Thank you for your order",
102
+ "priority": "normal",
103
+ "references": [],
104
+ "inReplyTo": [],
105
+ "text": "Hello Customer,\nThank you for your order from company.com. Your order will\nbe shipped shortly.\n\nYour friendly customer service department.",
106
+ "html": "",
107
+ "attachments": [],
108
+ "timestamp": "<volatile>2015-01-09T02:30:31.850Z</volatile>"
109
+ }
110
+ ]</strong>,
111
+ "stubs": [],
112
+ "_links": {
113
+ "self": { "href": "http://localhost:<%= port %>/imposters/4545" },
114
+ "stubs": { "href": "http://localhost:<%= port %>/imposters/4545/stubs" }
115
+ }
116
+ }</code></pre>
117
+ </assertResponse>
118
+ </step>
119
+
120
+ <p>Now you can use the <code>requests</code> element in your test code to validate
121
+ the application sent the correct information.</p>
122
+
123
+ <step type='http'>
124
+ <code class='hidden'>DELETE /imposters/4545 HTTP/1.1
125
+ Host: localhost:<%= port %>
126
+ Accept: application/json</code>
127
+ </step>
128
+ </testScenario>
129
+
130
+ <%- include('../../_footer') -%>