test: add tls clientcertengine tests
This commit is contained in:
parent
de917f8e81
commit
829d8f1cd0
15
test/parallel/test-tls-clientcertengine-invalid-arg-type.js
Normal file
15
test/parallel/test-tls-clientcertengine-invalid-arg-type.js
Normal file
@ -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
test/parallel/test-tls-clientcertengine-unsupported.js
Normal file
28
test/parallel/test-tls-clientcertengine-unsupported.js
Normal file
@ -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
test/parallel/test-tls-server-setoptions-clientcertengine.js
Normal file
15
test/parallel/test-tls-server-setoptions-clientcertengine.js
Normal file
@ -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');
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user