Skip to content

Commit

Permalink
test: merge tls-ext-key-usage into tls-securepair-client
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Apr 11, 2012
1 parent df361bb commit 5482c8f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 193 deletions.
189 changes: 0 additions & 189 deletions test/simple/test-tls-ext-key-usage.js

This file was deleted.

26 changes: 22 additions & 4 deletions test/simple/test-tls-securepair-client.js
Expand Up @@ -34,7 +34,7 @@ var tls = require('tls');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;

maybe(test);
maybe(test1);

// There is a bug with 'openssl s_server' which makes it not flush certain
// important events to stdout when done over a pipe. Therefore we skip this
Expand All @@ -50,7 +50,23 @@ function maybe(cb) {
});
}

function test() {
// simple/test-tls-securepair-client
function test1() {
test('agent.key', 'agent.crt', null, test2);
}

// simple/test-tls-ext-key-usage
function test2() {
function check(pair) {
// "TLS Web Client Authentication"
assert.equal(pair.cleartext.getPeerCertificate().ext_key_usage.length, 1);
assert.equal(pair.cleartext.getPeerCertificate().ext_key_usage[0],
'1.3.6.1.5.5.7.3.2');
}
test('keys/agent4-key.pem', 'keys/agent4-cert.pem', check);
}

function test(keyfn, certfn, check, next) {
// FIXME: Avoid the common PORT as this test currently hits a C-level
// assertion error with node_g. The program aborts without HUPing
// the openssl s_server thus causing many tests to fail with
Expand All @@ -59,10 +75,10 @@ function test() {

var connections = 0;

var keyfn = join(common.fixturesDir, 'agent.key');
keyfn = join(common.fixturesDir, keyfn);
var key = fs.readFileSync(keyfn).toString();

var certfn = join(common.fixturesDir, 'agent.crt');
certfn = join(common.fixturesDir, certfn);
var cert = fs.readFileSync(certfn).toString();

var server = spawn('openssl', ['s_server',
Expand Down Expand Up @@ -117,6 +133,7 @@ function test() {
server.on('exit', function(code) {
serverExitCode = code;
clearTimeout(timeout);
if (next) next();
});


Expand Down Expand Up @@ -146,6 +163,7 @@ function test() {
pair.cleartext.getPeerCertificate());
console.log('client pair.cleartext.getCipher(): %j',
pair.cleartext.getCipher());
if (check) check(pair);
setTimeout(function() {
pair.cleartext.write('hello\r\n', function() {
gotWriteCallback = true;
Expand Down

0 comments on commit 5482c8f

Please sign in to comment.