Browse Source

test tls: make tests use new `tls.connect` API

Refs #1983.
v0.7.4-release
Maciej Małecki 13 years ago
committed by koichik
parent
commit
39484f49ef
  1. 2
      test/simple/test-tls-client-abort.js
  2. 4
      test/simple/test-tls-client-resume.js
  3. 3
      test/simple/test-tls-client-verify.js
  4. 4
      test/simple/test-tls-connect-simple.js
  5. 2
      test/simple/test-tls-connect.js
  6. 9
      test/simple/test-tls-npn-server-client.js
  7. 6
      test/simple/test-tls-passphrase.js
  8. 2
      test/simple/test-tls-pause-close.js
  9. 2
      test/simple/test-tls-pause.js
  10. 2
      test/simple/test-tls-peer-certificate.js
  11. 2
      test/simple/test-tls-remote.js
  12. 2
      test/simple/test-tls-request-timeout.js
  13. 2
      test/simple/test-tls-set-encoding.js
  14. 8
      test/simple/test-tls-sni-server-client.js

2
test/simple/test-tls-client-abort.js

@ -33,7 +33,7 @@ var path = require('path');
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
var conn = tls.connect(common.PORT, {cert: cert, key: key}, function() {
var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
assert.ok(false); // callback should never be executed
});
conn.on('error', function() {

4
test/simple/test-tls-client-resume.js

@ -50,7 +50,7 @@ var server = tls.Server(options, function(socket) {
server.listen(common.PORT, function() {
var session1 = null;
var client1 = tls.connect(common.PORT, function() {
var client1 = tls.connect({port: common.PORT}, function() {
console.log('connect1');
assert.ok(!client1.isSessionReused(), 'Session *should not* be reused.');
session1 = client1.getSession();
@ -59,7 +59,7 @@ server.listen(common.PORT, function() {
client1.on('close', function() {
console.log('close1');
var client2 = tls.connect(common.PORT, {'session': session1}, function() {
var client2 = tls.connect({'session': session1, port: common.PORT}, function() {
console.log('connect2');
assert.ok(client2.isSessionReused(), 'Session *should* be reused.');
});

3
test/simple/test-tls-client-verify.js

@ -100,7 +100,7 @@ function testServers(index, servers, clientOptions, cb) {
var b = '';
console.error('connecting...');
var client = tls.connect(common.PORT, clientOptions, function() {
var client = tls.connect(clientOptions, function() {
console.error('expected: ' + ok + ' authed: ' + client.authorized);
@ -128,6 +128,7 @@ function runTest(testIndex) {
if (!tcase) return;
var clientOptions = {
port: common.PORT,
ca: tcase.ca.map(loadPEM),
key: loadPEM(tcase.key),
cert: loadPEM(tcase.cert)

4
test/simple/test-tls-connect-simple.js

@ -39,12 +39,12 @@ var server = tls.Server(options, function(socket) {
});
server.listen(common.PORT, function() {
var client1 = tls.connect(common.PORT, function() {
var client1 = tls.connect({port: common.PORT}, function() {
++clientConnected;
client1.end();
});
var client2 = tls.connect(common.PORT);
var client2 = tls.connect({port: common.PORT});
client2.on('secureConnect', function() {
++clientConnected;
client2.end();

2
test/simple/test-tls-connect.js

@ -42,7 +42,7 @@ var path = require('path');
assert.ok(errorEmitted);
});
var conn = tls.connect(common.PORT, {cert: cert, key: key}, function() {
var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
assert.ok(false); // callback should never be executed
});

9
test/simple/test-tls-npn-server-client.js

@ -45,25 +45,28 @@ var serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
var serverPort = common.PORT;
var clientsOptions = [{
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['a', 'b', 'c']
},{
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['c', 'b', 'e']
},{
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['first-priority-unsupported', 'x', 'y']
}];
var serverPort = common.PORT;
var serverResults = [],
clientsResults = [];
@ -74,7 +77,7 @@ server.listen(serverPort, startTest);
function startTest() {
function connectClient(options, callback) {
var client = tls.connect(serverPort, 'localhost', options, function() {
var client = tls.connect(options, function() {
clientsResults.push(client.npnProtocol);
client.destroy();

6
test/simple/test-tls-passphrase.js

@ -46,7 +46,8 @@ var server = tls.Server({
var connectCount = 0;
server.listen(common.PORT, function() {
var c = tls.connect(common.PORT, {
var c = tls.connect({
port: common.PORT,
key: key,
passphrase: 'passphrase',
cert: cert
@ -59,7 +60,8 @@ server.listen(common.PORT, function() {
});
assert.throws(function() {
tls.connect(common.PORT, {
tls.connect({
port: common.PORT,
key: key,
passphrase: 'invalid',
cert: cert

2
test/simple/test-tls-pause-close.js

@ -66,7 +66,7 @@ var server = tls.createServer(options, function(s) {
});
server.listen(common.PORT, function() {
var c = tls.connect(common.PORT, function() {
var c = tls.connect({port: common.PORT}, function() {
console.log('client connected');
c.socket.on('end', function() {
console.log('client socket ended');

2
test/simple/test-tls-pause.js

@ -45,7 +45,7 @@ var server = tls.Server(options, function(socket) {
server.listen(common.PORT, function() {
var resumed = false;
var client = tls.connect(common.PORT, function() {
var client = tls.connect({port: common.PORT}, function() {
client.pause();
common.debug('paused');
send();

2
test/simple/test-tls-peer-certificate.js

@ -42,7 +42,7 @@ var server = tls.createServer(options, function(cleartext) {
cleartext.end('World');
});
server.listen(common.PORT, function() {
var socket = tls.connect(common.PORT, function() {
var socket = tls.connect({port: common.PORT}, function() {
var peerCert = socket.getPeerCertificate();
common.debug(util.inspect(peerCert));
assert.equal(peerCert.subject.subjectAltName,

2
test/simple/test-tls-remote.js

@ -48,7 +48,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
assert.equal(server.address().address, '127.0.0.1');
assert.equal(server.address().port, common.PORT);
var c = tls.connect(common.PORT, '127.0.0.1', function() {
var c = tls.connect({port: common.PORT, host: '127.0.0.1'}, function() {
assert.equal(c.address().address, c.socket.address().address);
assert.equal(c.address().port, c.socket.address().port);

2
test/simple/test-tls-request-timeout.js

@ -42,7 +42,7 @@ var server = tls.Server(options, function(socket) {
});
server.listen(common.PORT, function() {
var socket = tls.connect(common.PORT);
var socket = tls.connect({port: common.PORT});
});
process.on('exit', function() {

2
test/simple/test-tls-set-encoding.js

@ -41,7 +41,7 @@ var server = tls.Server(options, function(socket) {
server.listen(common.PORT, function() {
var client = tls.connect(common.PORT);
var client = tls.connect({port: common.PORT});
var buffer = '';

8
test/simple/test-tls-sni-server-client.js

@ -57,26 +57,28 @@ var SNIContexts = {
}
};
var serverPort = common.PORT;
var clientsOptions = [{
port: serverPort,
key: loadPEM('agent1-key'),
cert: loadPEM('agent1-cert'),
ca: [loadPEM('ca1-cert')],
servername: 'a.example.com'
},{
port: serverPort,
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert'),
ca: [loadPEM('ca2-cert')],
servername: 'b.test.com'
},{
port: serverPort,
key: loadPEM('agent3-key'),
cert: loadPEM('agent3-cert'),
ca: [loadPEM('ca1-cert')],
servername: 'c.wrong.com'
}];
var serverPort = common.PORT;
var serverResults = [],
clientResults = [];
@ -91,7 +93,7 @@ server.listen(serverPort, startTest);
function startTest() {
function connectClient(options, callback) {
var client = tls.connect(serverPort, 'localhost', options, function() {
var client = tls.connect(options, function() {
clientResults.push(client.authorized);
client.destroy();

Loading…
Cancel
Save