Skip to content

Commit

Permalink
adding test for cookie-copying urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nfriedly committed Jul 3, 2015
1 parent 55f4f82 commit ca69101
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/cookies_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,26 @@ test('should rewrite urls that change subdomain or protocol (but not domain)', f
sourceStream.end(source);
});

test("should copy cookies and redirect in response to a __proxy_cookies_to query param", function(t) {
t.plan(2);
var instance = cookies({prefix: '/proxy/', processContentTypes: []});
var data = getData();
data.url += '?__proxy_cookies_to=https%3A%2F%2Fexample.com%2F';
data.headers['cookie'] = 'one=1; two=2; three=3';
data.clientResponse = {
redirectTo: function(path, headers) {
var expectedPath = 'https://example.com/';
var expectedHeaders = {
'set-cookie': [
'one=1; Path=/proxy/https://example.com/',
'two=2; Path=/proxy/https://example.com/',
'three=3; Path=/proxy/https://example.com/'
]
};
t.equal(path, expectedPath);
t.same(headers, expectedHeaders);
t.end();
}
};
instance.handleRequest(data);
});

0 comments on commit ca69101

Please sign in to comment.