0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-tls-snicallback-error.js
Deokjin Kim 609cd7f5bf
tls: use validateFunction for options.SNICallback
If user uses invalid type for `options.SNICallback` in
TLSSocket(), it's not internal issue of Node.js. So
validateFunction() is more proper than assert().

PR-URL: https://github.com/nodejs/node/pull/50530
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-10 13:04:07 +00:00

25 lines
558 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const net = require('net');
const tls = require('tls');
for (const SNICallback of ['fhqwhgads', 42, {}, []]) {
assert.throws(() => {
tls.createServer({ SNICallback });
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
});
assert.throws(() => {
new tls.TLSSocket(new net.Socket(), { isServer: true, SNICallback });
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
});
}