Skip to content

Commit

Permalink
tests: fix redirect tests for change in 302 status message
Browse files Browse the repository at this point in the history
closes #2690
  • Loading branch information
brendanashworth authored and dougwilson committed Aug 3, 2015
1 parent ef7ad68 commit 2f8ac67
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions test/res.redirect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var express = require('../')
, request = require('supertest');
var http = require('http');
var express = require('..');
var request = require('supertest');

describe('res', function(){
describe('.redirect(url)', function(){
Expand Down Expand Up @@ -83,11 +84,9 @@ describe('res', function(){
request(app)
.get('/')
.set('Accept', 'text/html')
.end(function(err, res){
res.headers.should.have.property('location', 'http://google.com');
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>');
done();
})
.expect('Content-Type', /html/)
.expect('Location', 'http://google.com')
.expect(302, '<p>' + http.STATUS_CODES[302] + '. Redirecting to <a href="http://google.com">http://google.com</a></p>', done);
})

it('should escape the url', function(done){
Expand All @@ -101,10 +100,9 @@ describe('res', function(){
.get('/')
.set('Host', 'http://example.com')
.set('Accept', 'text/html')
.end(function(err, res){
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;</a></p>');
done();
})
.expect('Content-Type', /html/)
.expect('Location', '<lame>')
.expect(302, '<p>' + http.STATUS_CODES[302] + '. Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;</a></p>', done);
})

it('should include the redirect type', function(done){
Expand Down Expand Up @@ -134,12 +132,9 @@ describe('res', function(){
request(app)
.get('/')
.set('Accept', 'text/plain, */*')
.end(function(err, res){
res.headers.should.have.property('location', 'http://google.com');
res.headers.should.have.property('content-length', '51');
res.text.should.equal('Moved Temporarily. Redirecting to http://google.com');
done();
})
.expect('Content-Type', /plain/)
.expect('Location', 'http://google.com')
.expect(302, http.STATUS_CODES[302] + '. Redirecting to http://google.com', done);
})

it('should encode the url', function(done){
Expand All @@ -153,10 +148,9 @@ describe('res', function(){
.get('/')
.set('Host', 'http://example.com')
.set('Accept', 'text/plain, */*')
.end(function(err, res){
res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E');
done();
})
.expect('Content-Type', /plain/)
.expect('Location', 'http://example.com/?param=<script>alert("hax");</script>')
.expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done);
})

it('should include the redirect type', function(done){
Expand Down

0 comments on commit 2f8ac67

Please sign in to comment.