diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-11-24 05:30:52 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-24 05:30:52 +0300 |
commit | a6f6532dfbfda5723958d79aef2b0e0fc9805da8 (patch) | |
tree | 719e9c78739d0e1410ed0d489c8e580e83dd5a2d /test | |
parent | a2b3c865c92fd6394f717d06160ad01f8001ae3c (diff) |
Fix test-securepair-server
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-securepair-server.js | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/test/simple/test-securepair-server.js b/test/simple/test-securepair-server.js index 5905e229a34..905576acc93 100644 --- a/test/simple/test-securepair-server.js +++ b/test/simple/test-securepair-server.js @@ -12,50 +12,51 @@ var key = fs.readFileSync(join(common.fixturesDir, "agent.key")).toString(); var cert = fs.readFileSync(join(common.fixturesDir, "agent.crt")).toString(); function log (a) { - console.log('***server*** ' + a); + console.error('***server*** ' + a); } var server = net.createServer(function (socket) { connections++; - log('connection'); + log('connection fd=' + socket.fd); var sslcontext = crypto.createCredentials({key: key, cert: cert}); sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA'); - var spair = crypto.createPair(sslcontext, true); + var pair = crypto.createPair(sslcontext, true); - spair.encrypted.pipe(socket); - socket.pipe(spair.encrypted); + assert.ok(pair.encrypted.writable); + assert.ok(pair.cleartext.writable); - var clear = spair.cleartext; + pair.encrypted.pipe(socket); + socket.pipe(pair.encrypted); log('i set it secure'); - spair.on('secure', function () { + pair.on('secure', function () { log('connected+secure!'); - clear.write(new Buffer('hello\r\n')); - log(spair.getPeerCertificate()); - log(spair.getCipher()); + pair.cleartext.write('hello\r\n'); + log(pair.getPeerCertificate()); + log(pair.getCipher()); }); - clear.on('data', function (data) { - log('read %d bytes', data.length); - clear.write(data); + pair.cleartext.on('data', function (data) { + log('read bytes ' + data.length); + pair.cleartext.write(data); }); - socket.on('end', function (err) { - log('all done: '+ err); - clear.write(new Buffer('goodbye\r\n')); - clear.end(); + socket.on('end', function () { + log('socket end'); + pair.cleartext.write('goodbye\r\n'); + pair.cleartext.end(); }); - clear.on('error', function(err) { + pair.cleartext.on('error', function(err) { log('got error: '); log(err); log(err.stack); socket.destroy(); }); - spair.encrypted.on('error', function(err) { + pair.encrypted.on('error', function(err) { log('encrypted error: '); log(err); log(err.stack); @@ -69,7 +70,11 @@ var server = net.createServer(function (socket) { socket.destroy(); }); - spair.on('error', function(err) { + socket.on('close', function(err) { + log('socket closed'); + }); + + pair.on('error', function(err) { log('secure error: '); log(err); log(err.stack); |