nock 9.0.9 → 9.0.13
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.
- package/.npmignore +2 -0
- package/.travis.yml +1 -1
- package/CHANGELOG.md +9 -4
- package/lib/intercept.js +5 -0
- package/lib/match_body.js +1 -1
- package/package.json +6 -2
- package/.nyc_output/0cfc9aa0c50eae765941a555f8482a68.json +0 -1
- package/.nyc_output/0ecdf591be62cb4571ebf9c4df59da37.json +0 -1
- package/.nyc_output/1df5c7adcf4885ae588bf8be3e508036.json +0 -1
- package/.nyc_output/2db2fc1c81ebebec5066673d7751e720.json +0 -1
- package/.nyc_output/2f9ccd224c0ce9793bb47cb95818e613.json +0 -1
- package/.nyc_output/302922273ee8b73467d3d8f160d41764.json +0 -1
- package/.nyc_output/402abf6bfd9ba80ba17d063c7aff8c5c.json +0 -1
- package/.nyc_output/4192a6afdd7ca9d506a9007e60f313c6.json +0 -1
- package/.nyc_output/4db6e0367725f3697aff401f14e83d8e.json +0 -1
- package/.nyc_output/51727eb8342f2b80aad8f5cf58247bb8.json +0 -1
- package/.nyc_output/53edcbd3a01e01726702fd59ad18528c.json +0 -1
- package/.nyc_output/58b1c38b2f1be3dcecbca9bab068a18f.json +0 -1
- package/.nyc_output/5c23da3e51b1f6cb82b2337ac4b79674.json +0 -1
- package/.nyc_output/6e39c409325db21e0a6645f24d62ea78.json +0 -1
- package/.nyc_output/71230f985baca9b3c3a5c96f7db17ce3.json +0 -1
- package/.nyc_output/75853f8bad86af123b6ab837115f9154.json +0 -1
- package/.nyc_output/79b9684388f3f8d578c0960b2cc38567.json +0 -1
- package/.nyc_output/83796d88fa4f05b5616674d83b9ea40a.json +0 -1
- package/.nyc_output/9d996c278cdb585d083b6f2cd90514a7.json +0 -1
- package/.nyc_output/a5f208db2341f743b5cd29d3fb47f97c.json +0 -1
- package/.nyc_output/ae6685d46041b4ede6cc2c43ca0e6021.json +0 -1
- package/.nyc_output/b0199893e52a27aa0d6c7ffdc52ae9d1.json +0 -1
- package/.nyc_output/d5d71e5d97fce722c611ef2e65170947.json +0 -1
- package/.nyc_output/d91d008aa4d6431aa91127a791303d24.json +0 -1
- package/.nyc_output/deceb761e61a0f642f51a304fae33d8a.json +0 -1
- package/.nyc_output/dfceb102965a150e5812732c638882ef.json +0 -1
- package/.nyc_output/e0656fe48b57b517e2c979a8a1578639.json +0 -1
- package/.nyc_output/e59e4c5a4d398d7ff45be9f48a01a932.json +0 -1
- package/.nyc_output/fecdd97de458efb187320ed600a1253c.json +0 -1
- package/tests/browserify-public/.gitkeep +0 -0
- package/tests/browserify-public/browserify-bundle.js +0 -43055
- package/tests/browserify-public/index.html +0 -2
- package/tests/fixtures/browserify-script.js +0 -19
- package/tests/fixtures/goodRequest.json +0 -26
- package/tests/fixtures/wrongUri.json +0 -50
- package/tests/test_abort.js +0 -59
- package/tests/test_aws_dynamo.js +0 -39
- package/tests/test_back.js +0 -341
- package/tests/test_back_2.js +0 -75
- package/tests/test_basic_auth.js +0 -79
- package/tests/test_body_match.js +0 -68
- package/tests/test_browserify.js +0 -54
- package/tests/test_common.js +0 -242
- package/tests/test_complex_querystring.js +0 -158
- package/tests/test_content_encoding.js +0 -26
- package/tests/test_data.js +0 -28
- package/tests/test_dynamic_mock.js +0 -92
- package/tests/test_encode_querystring.js +0 -22
- package/tests/test_events.js +0 -63
- package/tests/test_gzip_request.js +0 -74
- package/tests/test_https_allowunmocked.js +0 -25
- package/tests/test_intercept.js +0 -5009
- package/tests/test_ipv6.js +0 -55
- package/tests/test_isomorphic_fetch.js +0 -104
- package/tests/test_net_connect.js +0 -17
- package/tests/test_nock_off.js +0 -26
- package/tests/test_recorder.js +0 -896
- package/tests/test_redirects.js +0 -28
- package/tests/test_request_promise.js +0 -25
- package/tests/test_s3.js +0 -99
- package/tests/test_scope_interceptors.js +0 -11
- package/tests/test_timeout.js +0 -21
- package/tests/test_url_encoding.js +0 -17
package/tests/test_ipv6.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var http = require('http');
|
|
6
|
-
|
|
7
|
-
test("IPV6 URL in http.get get gets mocked", function(t) {
|
|
8
|
-
var dataCalled = false;
|
|
9
|
-
|
|
10
|
-
var scope = nock('http://[2607:f0d0:1002:51::4]:8080')
|
|
11
|
-
.get('/')
|
|
12
|
-
.reply(200, "Hello World!");
|
|
13
|
-
|
|
14
|
-
http.get('http://[2607:f0d0:1002:51::4]:8080/', function(res) {
|
|
15
|
-
t.equal(res.statusCode, 200, "Status code is 200");
|
|
16
|
-
res.on('end', function() {
|
|
17
|
-
t.ok(dataCalled, "data handler was called");
|
|
18
|
-
scope.done();
|
|
19
|
-
t.end();
|
|
20
|
-
});
|
|
21
|
-
res.on('data', function(data) {
|
|
22
|
-
dataCalled = true;
|
|
23
|
-
t.ok(data instanceof Buffer, "data should be buffer");
|
|
24
|
-
t.equal(data.toString(), "Hello World!", "response should match");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("IPV6 hostname in http.request get gets mocked", function(t) {
|
|
31
|
-
var dataCalled = false;
|
|
32
|
-
|
|
33
|
-
var scope = nock('http://[2607:f0d0:1002:51::5]:8080')
|
|
34
|
-
.get('/')
|
|
35
|
-
.reply(200, "Hello World!");
|
|
36
|
-
|
|
37
|
-
http.request({
|
|
38
|
-
hostname: '2607:f0d0:1002:51::5',
|
|
39
|
-
path: '/',
|
|
40
|
-
method: 'GET',
|
|
41
|
-
port: 8080,
|
|
42
|
-
}, function(res) {
|
|
43
|
-
t.equal(res.statusCode, 200, "Status code is 200");
|
|
44
|
-
res.on('end', function() {
|
|
45
|
-
t.ok(dataCalled, "data handler was called");
|
|
46
|
-
scope.done();
|
|
47
|
-
t.end();
|
|
48
|
-
});
|
|
49
|
-
res.on('data', function(data) {
|
|
50
|
-
dataCalled = true;
|
|
51
|
-
t.ok(data instanceof Buffer, "data should be buffer");
|
|
52
|
-
t.equal(data.toString(), "Hello World!", "response should match");
|
|
53
|
-
});
|
|
54
|
-
}).end();
|
|
55
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var fetch = require('isomorphic-fetch');
|
|
6
|
-
|
|
7
|
-
test("basic match works", function(t) {
|
|
8
|
-
var scope = nock('http://isomorphicfetchland.com').
|
|
9
|
-
get('/path').
|
|
10
|
-
reply(200, 'somedata');
|
|
11
|
-
|
|
12
|
-
fetch('http://isomorphicfetchland.com/path').
|
|
13
|
-
then(function(res) {
|
|
14
|
-
return res.text();
|
|
15
|
-
}).
|
|
16
|
-
then(function(text) {
|
|
17
|
-
scope.done();
|
|
18
|
-
t.equal(text, 'somedata', "response should match");
|
|
19
|
-
t.end();
|
|
20
|
-
}).
|
|
21
|
-
catch(function(err) {
|
|
22
|
-
throw err;
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("string-based reqheaders match works", function(t) {
|
|
27
|
-
var scope = nock('http://isomorphicfetchland.com', {
|
|
28
|
-
reqheaders: {
|
|
29
|
-
'header': 'header value',
|
|
30
|
-
}
|
|
31
|
-
}).
|
|
32
|
-
get('/path2').
|
|
33
|
-
reply(200, 'somemoardata');
|
|
34
|
-
|
|
35
|
-
return fetch('http://isomorphicfetchland.com/path2', {
|
|
36
|
-
headers: {
|
|
37
|
-
'header': 'header value',
|
|
38
|
-
}
|
|
39
|
-
}).
|
|
40
|
-
then(function(res) {
|
|
41
|
-
return res.text();
|
|
42
|
-
}).
|
|
43
|
-
then(function(text) {
|
|
44
|
-
scope.done();
|
|
45
|
-
t.equal(text, 'somemoardata', "response should match");
|
|
46
|
-
t.end();
|
|
47
|
-
}).
|
|
48
|
-
catch(function(err) {
|
|
49
|
-
throw err;
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test("basicAuth match works", function (t) {
|
|
54
|
-
var scope = nock('http://isomorphicfetchland.com').
|
|
55
|
-
get('/path2').
|
|
56
|
-
basicAuth({
|
|
57
|
-
user: 'username',
|
|
58
|
-
pass: 'password'
|
|
59
|
-
}).
|
|
60
|
-
reply(200, 'somemoardata');
|
|
61
|
-
|
|
62
|
-
return fetch('http://isomorphicfetchland.com/path2', {
|
|
63
|
-
headers: {
|
|
64
|
-
'Authorization': 'Basic ' + new Buffer('username:password').toString('base64'),
|
|
65
|
-
}
|
|
66
|
-
}).
|
|
67
|
-
then(function (res) {
|
|
68
|
-
return res.text();
|
|
69
|
-
}).
|
|
70
|
-
then(function (text) {
|
|
71
|
-
scope.done();
|
|
72
|
-
t.equal(text, 'somemoardata', "response should match");
|
|
73
|
-
t.end();
|
|
74
|
-
}).
|
|
75
|
-
catch(function (err) {
|
|
76
|
-
throw err;
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test("matchHeader works", function (t) {
|
|
81
|
-
var authorizationHeader = 'Basic ' + new Buffer('username:password').toString('base64');
|
|
82
|
-
|
|
83
|
-
var scope = nock('http://isomorphicfetchland.com').
|
|
84
|
-
get('/path2').
|
|
85
|
-
matchHeader('authorization', authorizationHeader).
|
|
86
|
-
reply(200, 'somemoardata');
|
|
87
|
-
|
|
88
|
-
return fetch('http://isomorphicfetchland.com/path2', {
|
|
89
|
-
headers: {
|
|
90
|
-
'Authorization': authorizationHeader,
|
|
91
|
-
}
|
|
92
|
-
}).
|
|
93
|
-
then(function (res) {
|
|
94
|
-
return res.text();
|
|
95
|
-
}).
|
|
96
|
-
then(function (text) {
|
|
97
|
-
scope.done();
|
|
98
|
-
t.equal(text, 'somemoardata', "response should match");
|
|
99
|
-
t.end();
|
|
100
|
-
}).
|
|
101
|
-
catch(function (err) {
|
|
102
|
-
throw err;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var mikealRequest = require('request');
|
|
6
|
-
var assert = require('assert');
|
|
7
|
-
|
|
8
|
-
test('disable net connect is default', function (t) {
|
|
9
|
-
nock.disableNetConnect();
|
|
10
|
-
nock('http://somethingelsecompletelyunrelated.com').get('/').reply(200);
|
|
11
|
-
|
|
12
|
-
mikealRequest('https://google.com/', function(err, res) {
|
|
13
|
-
assert(err);
|
|
14
|
-
assert.equal(err.message, 'Nock: Not allow net connect for "google.com:443/"');
|
|
15
|
-
t.end();
|
|
16
|
-
})
|
|
17
|
-
});
|
package/tests/test_nock_off.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var test = require('tap').test;
|
|
4
|
-
var mikealRequest = require('request');
|
|
5
|
-
|
|
6
|
-
test('NOCK_OFF=true works for https', {skip: process.env.AIRPLANE}, function(t) {
|
|
7
|
-
var original = process.env.NOCK_OFF;
|
|
8
|
-
process.env.NOCK_OFF = 'true';
|
|
9
|
-
var nock = require('../');
|
|
10
|
-
var scope = nock('https://www.google.com')
|
|
11
|
-
.get('/')
|
|
12
|
-
.reply(200, {foo: 'bar'});
|
|
13
|
-
|
|
14
|
-
var options = {
|
|
15
|
-
method: 'GET',
|
|
16
|
-
uri: 'https://www.google.com'
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
mikealRequest(options, function(err, resp, body) {
|
|
20
|
-
t.notOk(err);
|
|
21
|
-
t.notDeepEqual(body, '{"foo":"bar"}');
|
|
22
|
-
scope.done();
|
|
23
|
-
process.env.NOCK_OFF = original;
|
|
24
|
-
t.end();
|
|
25
|
-
});
|
|
26
|
-
});
|