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 authored and MylesBorins committed Dec 11, 2017
1 parent 7d49bd0 commit 121245f
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 121245f

@gibfahn
Copy link
Member

@gibfahn gibfahn commented on 121245f Dec 19, 2017

Choose a reason for hiding this comment

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

SEMVER-MINOR

PR-URL: #14903
Reviewed-By: Daniel Bevenius [email protected]
Reviewed-By: Fedor Indutny [email protected]
Reviewed-By: Anna Henningsen [email protected]
Reviewed-By: Ben Noordhuis [email protected]

Please sign in to comment.