Skip to content

Commit

Permalink
Unit Test for "x-forwarded-host" Header (#313)
Browse files Browse the repository at this point in the history
Beta 6 release did not update the host values in siren responses to
match the value provided by "x-forwarded-host" header. This PR adds
a unit test to verify correct host values.
  • Loading branch information
wooliet authored and Matthew Dobson committed May 19, 2016
1 parent bcd2bc8 commit 350c81f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/test_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ describe('Zetta Api', function() {
peerRegistry = new PeerRegistry();
});

it('updates href hosts using x-forwarded-host header', function(done) {
var app = zetta({ registry: reg, peerRegistry: peerRegistry })
.silent()
.name('local')
._run(function(err) {
if (err) {
return done(err);
}

request(getHttpServer(app))
.get('/')
.set('x-forwarded-host', 'google.com')
.expect(getBody(function(res, body) {
var self = body.links.filter(function(link) { return link.rel.indexOf('self') >= 0; })[0];
assert.equal(self.href, 'http://google.com/');
}))
.end(done);
});
})

it('allow for x-forwarded-host header to be disabled', function(done) {
var app = zetta({ registry: reg, peerRegistry: peerRegistry, useXForwardedHostHeader: false })
Expand Down

0 comments on commit 350c81f

Please sign in to comment.