Skip to content

Commit f517344

Browse files
authored
Merge pull request #139 from Sampaguitas/master
test file (information leak) #137
2 parents 3c0d686 + 2768f5c commit f517344

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

test/leak.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
var request = require('../').defaults({ json: true });;
4+
var t = require('chai').assert;
5+
6+
describe('Information Leak', function () {
7+
8+
it('should not forward cookie headers when the request has a redirect', function (done) {
9+
10+
request({
11+
url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/cookies',
12+
headers: {
13+
'Content-Type': 'application/json',
14+
'cookie': 'ajs_anonymous_id=1234567890',
15+
'authorization': 'Bearer eyJhb12345abcdef'
16+
},
17+
json:true
18+
}, function (err, response, body) {
19+
t.strictEqual(Object.keys(body).length, 0);
20+
done();
21+
});
22+
});
23+
24+
it('should not forward authorization headers when the request has a redirect', function (done) {
25+
26+
request({
27+
url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/bearer',
28+
headers: {
29+
'Content-Type': 'application/json',
30+
'cookie': 'ajs_anonymous_id=1234567890',
31+
'authorization': 'Bearer eyJhb12345abcdef'
32+
}
33+
}, function (err, response, body) {
34+
t.strictEqual(body, '');
35+
done();
36+
});
37+
});
38+
39+
});

0 commit comments

Comments
 (0)