Skip to content

Commit

Permalink
[test] add tests for the changeOrigin cases in properly setting the h…
Browse files Browse the repository at this point in the history
…ost header
  • Loading branch information
jcrugzz committed Dec 8, 2014
1 parent 501e8c2 commit 71a06aa
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/lib-http-proxy-common-test.js
Expand Up @@ -216,7 +216,7 @@ describe('lib/http-proxy/common.js', function () {
//
// This is the proper failing test case for the common.join problem
//
it('should correctly format the a toProxy URL', function () {
it('should correctly format the toProxy URL', function () {
var outgoing = {};
var google = 'https://google.com'
common.setupOutgoing(outgoing, {
Expand All @@ -225,7 +225,33 @@ describe('lib/http-proxy/common.js', function () {
}, { url: google });

expect(outgoing.path).to.eql('/' + google);
})
});

describe('when using changeOrigin', function () {
it('should correctly set the port to the host when it is a non-standard port using url.parse', function () {
var outgoing = {};
var myEndpoint = 'https://myCouch.com:6984';
common.setupOutgoing(outgoing, {
target: url.parse(myEndpoint),
changeOrigin: true
}, { url: '/' });

expect(outgoing.headers.host).to.eql('mycouch.com:6984');
});
it('should correctly set the port to the host when it is a non-standard port when setting host and port manually (which ignores port)', function () {
var outgoing = {};
common.setupOutgoing(outgoing, {
target: {
protocol: 'https:',
host: 'mycouch.com',
port: 6984
},
changeOrigin: true
}, { url: '/' });
expect(outgoing.headers.host).to.eql('mycouch.com:6984');
})
});

});

describe('#setupSocket', function () {
Expand Down

0 comments on commit 71a06aa

Please sign in to comment.