In non-buffer tests, change usage of the Buffer constructor to one of the recommended alternatives. Backport-PR-URL: https://github.com/nodejs/node/pull/14339 PR-URL: https://github.com/nodejs/node/pull/13649 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Brian White <mscdex@mscdex.net>
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
|
|
assert.throws(() => tls.createSecureContext({ciphers: 1}),
|
|
/TypeError: Ciphers must be a string/);
|
|
|
|
assert.throws(() => tls.createServer({ciphers: 1}),
|
|
/TypeError: Ciphers must be a string/);
|
|
|
|
assert.throws(() => tls.createSecureContext({key: 'dummykey', passphrase: 1}),
|
|
/TypeError: Pass phrase must be a string/);
|
|
|
|
assert.throws(() => tls.createServer({key: 'dummykey', passphrase: 1}),
|
|
/TypeError: Pass phrase must be a string/);
|
|
|
|
assert.throws(() => tls.createServer({ecdhCurve: 1}),
|
|
/TypeError: ECDH curve name must be a string/);
|
|
|
|
assert.throws(() => tls.createServer({handshakeTimeout: 'abcd'}),
|
|
/TypeError: handshakeTimeout must be a number/);
|
|
|
|
assert.throws(() => tls.createServer({sessionTimeout: 'abcd'}),
|
|
/TypeError: Session timeout must be a 32-bit integer/);
|
|
|
|
assert.throws(() => tls.createServer({ticketKeys: 'abcd'}),
|
|
/TypeError: Ticket keys must be a buffer/);
|
|
|
|
assert.throws(() => tls.createServer({ticketKeys: Buffer.alloc(0)}),
|
|
/TypeError: Ticket keys length must be 48 bytes/);
|
|
|
|
assert.throws(() => tls.createSecurePair({}),
|
|
/Error: First argument must be a tls module SecureContext/);
|
|
|
|
{
|
|
const buffer = Buffer.from('abcd');
|
|
const out = {};
|
|
tls.convertALPNProtocols(buffer, out);
|
|
out.ALPNProtocols.write('efgh');
|
|
assert(buffer.equals(Buffer.from('abcd')));
|
|
assert(out.ALPNProtocols.equals(Buffer.from('efgh')));
|
|
}
|
|
|
|
{
|
|
const buffer = Buffer.from('abcd');
|
|
const out = {};
|
|
tls.convertNPNProtocols(buffer, out);
|
|
out.NPNProtocols.write('efgh');
|
|
assert(buffer.equals(Buffer.from('abcd')));
|
|
assert(out.NPNProtocols.equals(Buffer.from('efgh')));
|
|
}
|