From: Lalit Kapoor Date: Wed, 11 Dec 2013 03:10:10 +0000 (-0600) Subject: test: use s_client instead of curl X-Git-Tag: v0.11.10~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d5489667cb073ec9d82ef292ecd0749de494238;p=platform%2Fupstream%2Fnodejs.git test: use s_client instead of curl fixes #6647 --- diff --git a/test/simple/test-https-foafssl.js b/test/simple/test-https-foafssl.js index 2336e5c..c464855 100644 --- a/test/simple/test-https-foafssl.js +++ b/test/simple/test-https-foafssl.js @@ -29,8 +29,7 @@ var assert = require('assert'); var join = require('path').join; var fs = require('fs'); -var exec = require('child_process').exec; - +var spawn = require('child_process').spawn; var https = require('https'); var options = { @@ -40,6 +39,7 @@ var options = { }; var reqCount = 0; +var CRLF = '\r\n'; var body = 'hello world\n'; var cert; var subjectaltname; @@ -60,19 +60,27 @@ var server = https.createServer(options, function(req, res) { res.end(body); }); - server.listen(common.PORT, function() { - var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/'; - cmd += ' --cert ' + join(common.fixturesDir, 'foafssl.crt'); - cmd += ' --key ' + join(common.fixturesDir, 'foafssl.key'); - console.error('executing %j', cmd); - exec(cmd, function(err, stdout, stderr) { - if (err) throw err; - common.error(common.inspect(stdout)); - assert.equal(body, stdout); + var args = ['s_client', + '-quiet', + '-connect', '127.0.0.1:' + common.PORT, + '-cert', join(common.fixturesDir, 'foafssl.crt'), + '-key', join(common.fixturesDir, 'foafssl.key')]; + + var client = spawn(common.opensslCli, args); + + client.stdout.on('data', function(data) { + var message = data.toString(); + var contents = message.split(CRLF + CRLF).pop(); + assert.equal(body, contents); server.close(); }); + client.stdin.write('GET /\n\n'); + + client.on('error', function(error) { + throw error; + }); }); process.on('exit', function() {