Skip to content

Commit

Permalink
test: add tls clientcertengine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Nov 11, 2017
1 parent de917f8 commit 829d8f1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/parallel/test-tls-clientcertengine-invalid-arg-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const tls = require('tls');

{
assert.throws(
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE',
message: / Received type number$/ }));
}
28 changes: 28 additions & 0 deletions test/parallel/test-tls-clientcertengine-unsupported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

// Monkey-patch SecureContext
const binding = process.binding('crypto');
const NativeSecureContext = binding.SecureContext;

binding.SecureContext = function() {
const rv = new NativeSecureContext();
rv.setClientCertEngine = undefined;
return rv;
};

const assert = require('assert');
const tls = require('tls');

{
assert.throws(
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
common.expectsError({
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
message: 'Custom engines not supported by this OpenSSL'
})
);
}
15 changes: 15 additions & 0 deletions test/parallel/test-tls-server-setoptions-clientcertengine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const tls = require('tls');

{
const server = tls.createServer();
assert.strictEqual(server.clientCertEngine, undefined);
server.setOptions({ clientCertEngine: 'Cannonmouth' });
assert.strictEqual(server.clientCertEngine, 'Cannonmouth');
}

1 comment on commit 829d8f1

@targos
Copy link
Member

@targos targos commented on 829d8f1 Apr 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR-URL: #14903

Please sign in to comment.