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_redirects.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var assert = require('assert');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var mikealRequest = require('request');
|
|
6
|
-
var nock = require('../');
|
|
7
|
-
|
|
8
|
-
test("follows redirects", function(t) {
|
|
9
|
-
|
|
10
|
-
nock('http://redirecter.com')
|
|
11
|
-
.get('/YourAccount')
|
|
12
|
-
.reply(302, undefined, {
|
|
13
|
-
'Location': 'http://redirecter.com/Login'
|
|
14
|
-
})
|
|
15
|
-
.get('/Login')
|
|
16
|
-
.reply(200, 'Here is the login page');
|
|
17
|
-
|
|
18
|
-
mikealRequest('http://redirecter.com/YourAccount', function(err, res, body) {
|
|
19
|
-
if (err) {
|
|
20
|
-
throw err;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
assert.equal(res.statusCode, 200);
|
|
24
|
-
assert.equal(body, 'Here is the login page');
|
|
25
|
-
t.end();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var rp = require('request-promise');
|
|
6
|
-
|
|
7
|
-
test("IPV6 URL in request-promise get gets mocked", function(t) {
|
|
8
|
-
var payload = 'somedata'
|
|
9
|
-
var target = 'http://[2607:f0d0:1002:51::4]:8080';
|
|
10
|
-
|
|
11
|
-
var scope = nock(target)
|
|
12
|
-
.post('/update')
|
|
13
|
-
.reply(200, payload);
|
|
14
|
-
|
|
15
|
-
rp({
|
|
16
|
-
uri: target + '/update',
|
|
17
|
-
method: 'POST',
|
|
18
|
-
body: payload
|
|
19
|
-
}).then(function(res) {
|
|
20
|
-
t.equal(res.toString(), payload, "response should match");
|
|
21
|
-
t.end();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
package/tests/test_s3.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../');
|
|
4
|
-
var AWS = require('aws-sdk');
|
|
5
|
-
var test = require('tap').test;
|
|
6
|
-
|
|
7
|
-
test('works with s3, body < 1024 ^ 2', function (t) {
|
|
8
|
-
var REGION = 'us-east-1';
|
|
9
|
-
|
|
10
|
-
AWS.config.update({
|
|
11
|
-
region: REGION,
|
|
12
|
-
sslEnabled: true,
|
|
13
|
-
accessKeyId: 'ACCESSKEYID',
|
|
14
|
-
secretAccessKey: 'SECRETACCESSKEY'
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
var bucket = new AWS.S3({
|
|
18
|
-
apiVersion: '2006-03-01',
|
|
19
|
-
params: {
|
|
20
|
-
Bucket: 'bucket'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
nock('https://bucket.s3.amazonaws.com').put('/key').reply(200);
|
|
25
|
-
|
|
26
|
-
bucket.putObject({
|
|
27
|
-
Key: 'key',
|
|
28
|
-
Body: new Buffer(1024 * 1024 - 1), // works
|
|
29
|
-
// Body: new Buffer(1024 * 1024), // doesn't work
|
|
30
|
-
ContentType: 'binary/octet-stream'
|
|
31
|
-
},
|
|
32
|
-
function (err, resp) {
|
|
33
|
-
if (err) throw err;
|
|
34
|
-
t.deepEqual(resp, {});
|
|
35
|
-
t.end();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('works with s3, body = 10 * 1024 ^ 2', function (t) {
|
|
40
|
-
var REGION = 'us-east-1';
|
|
41
|
-
|
|
42
|
-
AWS.config.update({
|
|
43
|
-
region: REGION,
|
|
44
|
-
sslEnabled: true,
|
|
45
|
-
accessKeyId: 'ACCESSKEYID',
|
|
46
|
-
secretAccessKey: 'SECRETACCESSKEY'
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
var bucket = new AWS.S3({
|
|
50
|
-
apiVersion: '2006-03-01',
|
|
51
|
-
params: {
|
|
52
|
-
Bucket: 'bucket'
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
nock('https://bucket.s3.amazonaws.com').put('/key').reply(200);
|
|
57
|
-
|
|
58
|
-
bucket.putObject({
|
|
59
|
-
Key: 'key',
|
|
60
|
-
Body: new Buffer(10 * 1024 * 1024), // doesn't work
|
|
61
|
-
ContentType: 'binary/octet-stream'
|
|
62
|
-
},
|
|
63
|
-
function (err, resp) {
|
|
64
|
-
if (err) throw err;
|
|
65
|
-
t.deepEqual(resp, {});
|
|
66
|
-
t.end();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('works with s3, body = 16 * 1024 ^ 2', function (t) {
|
|
71
|
-
var REGION = 'us-east-1';
|
|
72
|
-
|
|
73
|
-
AWS.config.update({
|
|
74
|
-
region: REGION,
|
|
75
|
-
sslEnabled: true,
|
|
76
|
-
accessKeyId: 'ACCESSKEYID',
|
|
77
|
-
secretAccessKey: 'SECRETACCESSKEY'
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
var bucket = new AWS.S3({
|
|
81
|
-
apiVersion: '2006-03-01',
|
|
82
|
-
params: {
|
|
83
|
-
Bucket: 'bucket'
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
nock('https://bucket.s3.amazonaws.com').put('/key').reply(200);
|
|
88
|
-
|
|
89
|
-
bucket.putObject({
|
|
90
|
-
Key: 'key',
|
|
91
|
-
Body: new Buffer(16 * 1024 * 1024), // doesn't work
|
|
92
|
-
ContentType: 'binary/octet-stream'
|
|
93
|
-
},
|
|
94
|
-
function (err, resp) {
|
|
95
|
-
if (err) throw err;
|
|
96
|
-
t.deepEqual(resp, {});
|
|
97
|
-
t.end();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var nock = require('../');
|
|
2
|
-
var test = require('tap').test;
|
|
3
|
-
|
|
4
|
-
test('scope exposes interceptors', function(t) {
|
|
5
|
-
nock.load(__dirname + '/fixtures/goodRequest.json').forEach(function (scope) {
|
|
6
|
-
scope.interceptors.forEach(function(interceptor) {
|
|
7
|
-
interceptor.delayConnection(100);
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
t.end();
|
|
11
|
-
});
|
package/tests/test_timeout.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nock = require('../.');
|
|
4
|
-
var test = require('tap').test;
|
|
5
|
-
var request = require('request');
|
|
6
|
-
|
|
7
|
-
test('something', function (t) {
|
|
8
|
-
nock('http://google.com')
|
|
9
|
-
.get('/')
|
|
10
|
-
.delay(1000)
|
|
11
|
-
.reply(200, {});
|
|
12
|
-
|
|
13
|
-
request({
|
|
14
|
-
url: 'http://google.com',
|
|
15
|
-
timeout: 10
|
|
16
|
-
}, function (err, response) {
|
|
17
|
-
t.ok(err);
|
|
18
|
-
t.equal(err.code, 'ETIMEDOUT')
|
|
19
|
-
t.end();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -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('url encoding', function (t) {
|
|
9
|
-
|
|
10
|
-
nock('http://encodingsareus.com').get('/key?a=[1]').reply(200);
|
|
11
|
-
|
|
12
|
-
mikealRequest('http://encodingsareus.com/key?a=[1]', function(err, res) {
|
|
13
|
-
if (err) throw err;
|
|
14
|
-
assert.equal(res.statusCode, 200);
|
|
15
|
-
t.end();
|
|
16
|
-
})
|
|
17
|
-
});
|