Skip to content

Commit

Permalink
Merge pull request #139 from Sampaguitas/master
Browse files Browse the repository at this point in the history
test file (information leak) #137
  • Loading branch information
FGRibreau committed Feb 21, 2022
2 parents 3c0d686 + 2768f5c commit f517344
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/leak.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

var request = require('../').defaults({ json: true });;
var t = require('chai').assert;

describe('Information Leak', function () {

it('should not forward cookie headers when the request has a redirect', function (done) {

request({
url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/cookies',
headers: {
'Content-Type': 'application/json',
'cookie': 'ajs_anonymous_id=1234567890',
'authorization': 'Bearer eyJhb12345abcdef'
},
json:true
}, function (err, response, body) {
t.strictEqual(Object.keys(body).length, 0);
done();
});
});

it('should not forward authorization headers when the request has a redirect', function (done) {

request({
url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/bearer',
headers: {
'Content-Type': 'application/json',
'cookie': 'ajs_anonymous_id=1234567890',
'authorization': 'Bearer eyJhb12345abcdef'
}
}, function (err, response, body) {
t.strictEqual(body, '');
done();
});
});

});

0 comments on commit f517344

Please sign in to comment.