tests: fix redirect tests for change in 302 status message
Before adoption: this commit came in with the history the project adopted, so no landing records it.
closes #2690
authored by Brendan Ashworth · committed by Douglas Christopher Wilson · parent ef7ad68 · Browse files · 1 file·+15 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+15 added−21 removed
- tests:+15 added−21 removed
Provenance
- Commit
2f8ac67- Tree
7fe32fe- Author
Brendan Ashworth <brendan.ashworth@me.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
ef7ad68
1 file changed+15 added−21 removed
modified:test/res.redirect.js+15 added-21 removed
122334567874 unmodified lines838485868687888990878889909192935 unmodified lines9910010110210410510610710310410510610710810921 unmodified lines1311321331341371381391401411421351361371381391401415 unmodified lines14714814915015615715815915115215315415515615735 unmodified lines
var http = require('http');var express = require('../') , request = require('supertest');var express = require('..');var request = require('supertest');
describe('res', function(){ describe('.redirect(url)', function(){ it('should default to a 302 redirect', function(done){74 unmodified lines
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){ var app = express();5 unmodified lines request(app) .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="<lame>"><lame></a></p>'); done(); }) .expect('Content-Type', /html/) .expect('Location', '<lame>') .expect(302, '<p>' + http.STATUS_CODES[302] + '. Redirecting to <a href="<lame>"><lame></a></p>', done); })
it('should include the redirect type', function(done){ var app = express();21 unmodified lines
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){ var app = express();5 unmodified lines request(app) .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){ var app = express();35 unmodified lines