Skip to content

Commit

Permalink
Merge pull request request#279 from benatkin/fix-tests-with-boundary
Browse files Browse the repository at this point in the history
fix tests with boundary by injecting boundry from header
  • Loading branch information
mikeal committed Jul 5, 2012
2 parents f8ae8d1 + 1f34700 commit 3a664fd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
14 changes: 9 additions & 5 deletions tests/server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ exports.createPostValidator = function (text) {
var r = ''; var r = '';
req.on('data', function (chunk) {r += chunk}) req.on('data', function (chunk) {r += chunk})
req.on('end', function () { req.on('end', function () {
if (r !== text) console.log(r, text); if (req.headers['content-type'] && req.headers['content-type'].indexOf('boundary=') >= 0) {
assert.equal(r, text) var boundary = req.headers['content-type'].split('boundary=')[1];
resp.writeHead(200, {'content-type':'text/plain'}) text = text.replace(/__BOUNDARY__/g, boundary);
resp.write('OK') }
resp.end() if (r !== text) console.log(r, text);
assert.equal(r, text)
resp.writeHead(200, {'content-type':'text/plain'})
resp.write('OK')
resp.end()
}) })
} }
return l; return l;
Expand Down
33 changes: 16 additions & 17 deletions tests/test-body.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,23 +50,22 @@ var tests =
, method: "PUT" , method: "PUT"
, json: {foo: 'bar'} , json: {foo: 'bar'}
} }
// , testPutMultipart : , testPutMultipart :
// { resp: server.createPostValidator( { resp: server.createPostValidator(
// '--frontier\r\n' + '--__BOUNDARY__\r\n' +
// '--15F6786B-D0A8-4AB8-B0A5-DDF721BC6192\\r\\n' 'content-type: text/html\r\n' +
// 'content-type: text/html\r\n' + '\r\n' +
// '\r\n' + '<html><body>Oh hi.</body></html>' +
// '<html><body>Oh hi.</body></html>' + '\r\n--__BOUNDARY__\r\n\r\n' +
// '\r\n--frontier\r\n\r\n' + 'Oh hi.' +
// 'Oh hi.' + '\r\n--__BOUNDARY__--'
// '\r\n--frontier--' )
// ) , method: "PUT"
// , method: "PUT" , multipart:
// , multipart: [ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
// [ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'} , {'body': 'Oh hi.'}
// , {'body': 'Oh hi.'} ]
// ] }
// }
} }


s.listen(s.port, function () { s.listen(s.port, function () {
Expand Down
6 changes: 3 additions & 3 deletions tests/test-https-strict.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ var tests =
} }
, testPutMultipart : , testPutMultipart :
{ resp: server.createPostValidator( { resp: server.createPostValidator(
'--frontier\r\n' + '--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' + 'content-type: text/html\r\n' +
'\r\n' + '\r\n' +
'<html><body>Oh hi.</body></html>' + '<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' + '\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' + 'Oh hi.' +
'\r\n--frontier--' '\r\n--__BOUNDARY__--'
) )
, method: "PUT" , method: "PUT"
, multipart: , multipart:
Expand Down
6 changes: 3 additions & 3 deletions tests/test-https.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ var tests =
} }
, testPutMultipart : , testPutMultipart :
{ resp: server.createPostValidator( { resp: server.createPostValidator(
'--frontier\r\n' + '--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' + 'content-type: text/html\r\n' +
'\r\n' + '\r\n' +
'<html><body>Oh hi.</body></html>' + '<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' + '\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' + 'Oh hi.' +
'\r\n--frontier--' '\r\n--__BOUNDARY__--'
) )
, method: "PUT" , method: "PUT"
, multipart: , multipart:
Expand Down
6 changes: 3 additions & 3 deletions tests/test-params.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ var tests =
} }
, testPutMultipart : , testPutMultipart :
{ resp: server.createPostValidator( { resp: server.createPostValidator(
'--frontier\r\n' + '--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' + 'content-type: text/html\r\n' +
'\r\n' + '\r\n' +
'<html><body>Oh hi.</body></html>' + '<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' + '\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' + 'Oh hi.' +
'\r\n--frontier--' '\r\n--__BOUNDARY__--'
) )
, method: "PUT" , method: "PUT"
, multipart: , multipart:
Expand Down
3 changes: 2 additions & 1 deletion tests/test-tunnel.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ squid.stdout.on('data', function (c) {
}) })


squid.on('exit', function (c) { squid.on('exit', function (c) {
console.error('exit '+c) console.error('squid: exit '+c)
if (c && !ready) { if (c && !ready) {
console.error('squid must be installed to run this test.') console.error('squid must be installed to run this test.')
console.error('skipping this test. please install squid and run again if you need to test tunneling.')
c = null c = null
hadError = null hadError = null
process.exit(0) process.exit(0)
Expand Down

0 comments on commit 3a664fd

Please sign in to comment.