From 098c5af5cad90fcf0091b6fa6e3159dfd3621de4 Mon Sep 17 00:00:00 2001 From: Brendan Ashworth Date: Thu, 25 Jun 2015 00:30:19 -0700 Subject: [PATCH] tests: support IANA compliant header messages This commit allows the tests to pass when the node HTTP server uses IANA compliant header messages rather than the messages the server used to use. This prevents future test breakage caused by https://github.com/nodejs/io.js/pull/1470, a pull request tracked for node 3.0.0 semver-major release. See: https://github.com/nodejs/io.js/commit/235036e7faa537469c3600850bdd533c095c392a The only pertinent status code change is the 302 code, which used to be "Moved Temporarily" but is now "Found", according to the document here: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml --- test/res.redirect.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/res.redirect.js b/test/res.redirect.js index 4044ad49ee..bf45fc5932 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -85,7 +85,7 @@ describe('res', function(){ .set('Accept', 'text/html') .end(function(err, res){ res.headers.should.have.property('location', 'http://google.com'); - res.text.should.equal('

Moved Temporarily. Redirecting to http://google.com

'); + res.text.should.match(/

(Moved Temporarily|Found). Redirecting to http:\/\/google.com<\/a><\/p>/); done(); }) }) @@ -102,7 +102,7 @@ describe('res', function(){ .set('Host', 'http://example.com') .set('Accept', 'text/html') .end(function(err, res){ - res.text.should.equal('

Moved Temporarily. Redirecting to <lame>

'); + res.text.should.match(/

(Moved Temporarily|Found). Redirecting to <lame><\/a><\/p>/); done(); }) }) @@ -136,8 +136,8 @@ describe('res', function(){ .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'); + res.headers.should.have.property('content-length'); + res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/google.com/); done(); }) }) @@ -154,7 +154,7 @@ describe('res', function(){ .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'); + res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/example.com\/\?param=%3Cscript%3Ealert\(%22hax%22\);%3C\/script%3E/); done(); }) })