Skip to content

Instantly share code, notes, and snippets.

@papandreou
Created April 13, 2016 07:53
Show Gist options
  • Save papandreou/e8fbd50782e8c5d0b22f5fcf1ba1cc37 to your computer and use it in GitHub Desktop.
Save papandreou/e8fbd50782e8c5d0b22f5fcf1ba1cc37 to your computer and use it in GitHub Desktop.
unexpected-mitm@master (1553297) npm test output
[unexpected-mitm]$ npm test
> [email protected] test /home/andreas/work/unexpected-mitm
> mocha --compilers md:unexpected-markdown test/*.js `find documentation -name '*.md'` && npm run lint
unexpectedMitm
✓ should mock out a simple request
✓ should mock out a request with a binary body
✓ should mock out an erroring response
✓ should mock out an application/json response
✓ should mock out an application/json response with invalid JSON
✓ should preserve the original serialization of JSON provided as a string
✓ should not break when the assertion being delegated to throws synchronously
✓ should support mocking out the status code
✓ should work fine without any assertions on the request
✓ should error if the request body provided for verification was a stream
✓ should produce a JSON response if the response body is given as an object
✓ should produce a JSON response if the response body is given as an array
✓ should produce an error if the request conditions are not satisfied
✓ should produce an error if a mocked request is not exercised
✓ should produce an error if a mocked request is not exercised and the second mock has a stream
✓ should produce an error if a mocked request is not exercised with an expected request stream
✓ should produce an error if a mocked request is not exercised and there are non-trivial assertions on it (38ms)
✓ should produce an error if a mocked request is not exercised and there are failing async expects (44ms)
✓ should produce an error if the test issues more requests than have been mocked
✓ should not mangle the requestDescriptions array
✓ should output the error if the assertion being delegated to fails
✓ should not overwrite an explicitly defined Host header in the expected request properties
✓ should interpret a response body provided as a non-Buffer object as JSON even though the message has a non-JSON Content-Type
✓ should resolve with the compared exchanges
with async expects on the request
✓ should succeed
✓ should fail with a diff (57ms)
when mocking out an https request and asserting that the request is https
when https is specified as part of the request url
✓ should succeed
✓ should fail
when "encrypted" is specified as a standalone property
✓ should succeed
✓ should fail
using a fully-qualified request url
✓ should assert on the host name of the issued request
✓ should fail
with a response body provided as a stream
✓ should support providing such a response
✓ should decode the stream as a string
✓ should decode the stream as JSON
that emits an error
✓ should propagate the error to the mocked-out HTTP response
✓ should support a stream that emits some data, then errors out
✓ should recover from the error and replay the next request
with the expected request body given as an object (shorthand for JSON)
✓ should succeed the match
✓ should fail with a diff
with response function
✓ should allow returning a response in callback
✓ should allow returning a response with a body Buffer
✓ should allow returning a response with a body Array
✓ should allow returning a response with a body object
✓ should allow the use of pipe() internally
✓ should report if the response function returns an error
✓ should allow consuming the request body (129ms)
with documentation response function
✓ should remark "to be expected" for GET /thatOneExpectedThing
✓ should remark "how very unexpected" for GET /somethingOtherThing
wíth a client certificate
when asserting on ca/cert/key
✓ should succeed
✓ should fail with a meaningful error message
in recording mode against a local HTTP server
✓ should record
✓ should record an error
✓ should record a socket disconnect
in injecting mode against a local HTTP server
✓ should record and inject (294ms)
✓ should correctly handle buffer injections (289ms)
✓ should correctly handle multiple injections (311ms)
in recording mode against a local HTTPS server
with a client certificate
✓ should record a client certificate
with-http-mocked-out
✓ example #1 (documentation/assertions/any/with-http-mocked-out.md:8:1) should succeed (89ms)
✓ example #2 (documentation/assertions/any/with-http-mocked-out.md:27:1) should succeed
✓ example #3 (documentation/assertions/any/with-http-mocked-out.md:60:1) should succeed
✓ example #4 (documentation/assertions/any/with-http-mocked-out.md:107:1) should succeed
with-http-recorded
✓ example #1 (documentation/assertions/any/with-http-recorded.md:7:1) should succeed
✓ example #2 (documentation/assertions/any/with-http-recorded.md:31:1) should succeed
myApp
✓ should report that it does not currently rain
myApp
✓ should report that it does not currently rain
with documentation response function
✓ should remark "to be expected" for GET /thatOneExpectedThing
✓ should remark "how very unexpected" for GET /somethingOtherThing
requests to a popular web search service
✓ should have a Content-Type (156ms)
requests to a popular web search service
✓ should have a Content-Type (133ms)
requests to a popular web search service
unexpected-mitm: Could not find the right place to inject the recorded exchanges into /home/andreas/work/unexpected-mitm/documentation/assertions/any/with-http-recorded.md (around line 67): {
request: { url: 'GET /', headers: { Host: 'www.google.co.uk' }, host: 'www.google.co.uk', port: 443 },
response: {
headers: {
Expires: '-1', 'Cache-Control': 'private, max-age=0', 'Content-Type': 'text/html; charset=ISO-8859-1',
P3P: 'CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."', Server: 'gws',
'X-XSS-Protection': '1; mode=block', 'X-Frame-Options': 'SAMEORIGIN',
'Set-Cookie': [
'NID=78=H1PSf3I0zW1mvKbeMnbIX7YiqUA70I4QpyGPCa8S4tBRNRrDu8qH3d03aEXvmZ6wBELJTL7D9t-0uQzgUOoqyN2Us_nOe9rePzOuFVgFqZBSrhiwsYb1F5NKCPXHlg9-; expires=Thu, 13-Oct-2016 07:51:54 GMT; path=/; domain=.google.co.uk; HttpOnly'
],
'Alternate-Protocol': '443:quic', 'Alt-Svc': 'quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"', 'Accept-Ranges': 'none',
Vary: 'Accept-Encoding'
},
body: Buffer([0x3C, 0x21, 0x64, 0x6F, 0x63, 0x74, 0x79, 0x70, 0x65, 0x20, 0x68, 0x74, 0x6D, 0x6C, 0x3E, 0x3C /* 53951 more */ ])
}
}
✓ should return something (132ms)
71 passing (2s)
> [email protected] lint /home/andreas/work/unexpected-mitm
> eslint .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment