Add more tests for setHeaders

This commit is contained in:
Rob Wu
2015-08-23 10:58:58 +02:00
parent 015627b3f4
commit a2f0c05b24

View File

@@ -496,6 +496,50 @@ describe('setHeaders', function() {
'x-powered-by': 'CORS Anywhere'
}, done);
});
it('GET /example.com should replace header', function(done) {
request(cors_anywhere)
.get('/example.com/echoheaders')
.set('x-powered-by', 'should be replaced')
.expect('Access-Control-Allow-Origin', '*')
.expectJSON({
host: 'example.com',
'x-powered-by': 'CORS Anywhere'
}, done);
});
});
describe('setHeaders + removeHeaders', function() {
before(function() {
// setHeaders takes precedence over removeHeaders
cors_anywhere = createServer({
removeHeaders: ['x-powered-by'],
setHeaders: {'x-powered-by': 'CORS Anywhere'},
});
cors_anywhere_port = cors_anywhere.listen(0).address().port;
});
after(stopServer);
it('GET /example.com', function(done) {
request(cors_anywhere)
.get('/example.com/echoheaders')
.expect('Access-Control-Allow-Origin', '*')
.expectJSON({
host: 'example.com',
'x-powered-by': 'CORS Anywhere'
}, done);
});
it('GET /example.com should replace header', function(done) {
request(cors_anywhere)
.get('/example.com/echoheaders')
.set('x-powered-by', 'should be replaced')
.expect('Access-Control-Allow-Origin', '*')
.expectJSON({
host: 'example.com',
'x-powered-by': 'CORS Anywhere'
}, done);
});
});
describe('httpProxyOptions.xfwd=false', function() {