summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkoichik <koichik@improvement.jp>2011-10-15 19:27:21 +0900
committerkoichik <koichik@improvement.jp>2011-10-15 19:27:21 +0900
commit68cc173c6d2cde4f1869b24ec3bc690ef34da7ad (patch)
treef8c9ded7ee6dbf2555842f92c8782e6987026257 /test
parent0b92fa0e9326a395e3b5368091e2008be2ba8ae3 (diff)
downloadnode-new-68cc173c6d2cde4f1869b24ec3bc690ef34da7ad.tar.gz
tls: The TLS API is inconsistent with the TCP API
Add 'secureConnect' event to tls.CleartextStream. Fixes #1467.
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-tls-connect-simple.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/simple/test-tls-connect-simple.js b/test/simple/test-tls-connect-simple.js
new file mode 100644
index 0000000000..538efd6931
--- /dev/null
+++ b/test/simple/test-tls-connect-simple.js
@@ -0,0 +1,57 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var assert = require('assert');
+var tls = require('tls');
+var fs = require('fs');
+
+var clientConnected = 0;
+var serverConnected = 0;
+
+var options = {
+ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
+ cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
+};
+
+var server = tls.Server(options, function(socket) {
+ if (++serverConnected === 2) {
+ server.close();
+ }
+});
+
+server.listen(common.PORT, function() {
+ var client1 = tls.connect(common.PORT, function() {
+ ++clientConnected;
+ client1.end();
+ });
+
+ var client2 = tls.connect(common.PORT);
+ client2.on('secureConnect', function() {
+ ++clientConnected;
+ client2.end();
+ });
+});
+
+process.on('exit', function() {
+ assert.equal(clientConnected, 2);
+ assert.equal(serverConnected, 2);
+});