Skip to content

Commit

Permalink
test: add regression test for nodejs#4127
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Dec 6, 2015
1 parent 564a88b commit 4e9d541
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test/fixtures/keys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ agent1-cert.pem: agent1-csr.pem ca1-cert.pem ca1-key.pem
-CAcreateserial \
-out agent1-cert.pem

agent1-pfx.pem: agent1-cert.pem
openssl pkcs12 -export -in agent1-cert.pem -inkey agent1-key.pem -certfile ca1-cert.pem -out agent1-pfx.pem -password pass:sample

agent1-verify: agent1-cert.pem ca1-cert.pem
openssl verify -CAfile ca1-cert.pem agent1-cert.pem

Expand Down
Binary file added test/fixtures/keys/agent1-pfx.pem
Binary file not shown.
31 changes: 26 additions & 5 deletions test/parallel/test-tls-ocsp-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ var constants = require('constants');
var fs = require('fs');
var join = require('path').join;

test({ response: false }, function() {
test({ response: 'hello world' }, function() {
test({ ocsp: false });
});
});
var pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));

var tests = [
{ response: false },
{ response: 'hello world' },
{ ocsp: false },
{ pfx: pfx, passphrase: 'sample', response: 'hello pfx' }
];

function test(testOptions, cb) {

Expand All @@ -47,6 +50,13 @@ function test(testOptions, cb) {
var ocspResponse;
var session;

if (testOptions.pfx) {
delete options.key;
delete options.cert;
options.pfx = testOptions.pfx;
options.passphrase = testOptions.passphrase;
}

var server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
// We're ok with getting ECONNRESET in this test, but it's
Expand All @@ -60,6 +70,7 @@ function test(testOptions, cb) {
});
server.on('OCSPRequest', function(cert, issuer, callback) {
++ocspCount;
console.log(cert, issuer);
assert.ok(Buffer.isBuffer(cert));
assert.ok(Buffer.isBuffer(issuer));

Expand Down Expand Up @@ -106,3 +117,13 @@ function test(testOptions, cb) {
assert.equal(ocspCount, 1);
});
}

function runTests(i) {
if (i === tests.length) return;

test(tests[i], common.mustCall(function() {
runTests(i + 1);
}));
}

runTests(0);

0 comments on commit 4e9d541

Please sign in to comment.