Skip to content

Commit 121245f

Browse files
TrottMylesBorins
authored andcommitted
test: add tls clientcertengine tests
1 parent 7d49bd0 commit 121245f

3 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const tls = require('tls');
9+
10+
{
11+
assert.throws(
12+
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
13+
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE',
14+
message: / Received type number$/ }));
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
// Monkey-patch SecureContext
8+
const binding = process.binding('crypto');
9+
const NativeSecureContext = binding.SecureContext;
10+
11+
binding.SecureContext = function() {
12+
const rv = new NativeSecureContext();
13+
rv.setClientCertEngine = undefined;
14+
return rv;
15+
};
16+
17+
const assert = require('assert');
18+
const tls = require('tls');
19+
20+
{
21+
assert.throws(
22+
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
23+
common.expectsError({
24+
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
25+
message: 'Custom engines not supported by this OpenSSL'
26+
})
27+
);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const tls = require('tls');
9+
10+
{
11+
const server = tls.createServer();
12+
assert.strictEqual(server.clientCertEngine, undefined);
13+
server.setOptions({ clientCertEngine: 'Cannonmouth' });
14+
assert.strictEqual(server.clientCertEngine, 'Cannonmouth');
15+
}

0 commit comments

Comments
 (0)