node/test/parallel/test-tls-basic-validations.js
Rich Trott aa6fac68da test: adjust indentation for stricter linting
ESLint 4.x has stricter linting than previous versions. We are currently
using the legacy indentation rules in the test directory. This commit
changes the indentation of files to comply with the stricter 4.x linting
and enable stricter linting in the test directory.

PR-URL: https://github.com/nodejs/node/pull/14431
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2017-07-27 09:24:20 -07:00

76 lines
2.4 KiB
JavaScript

'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({ 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' }),
common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "timeout" argument must be of type 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')));
}
{
const buffer = new Uint8Array(Buffer.from('abcd'));
const out = {};
tls.convertALPNProtocols(buffer, out);
assert(out.ALPNProtocols.equals(Buffer.from('abcd')));
}
{
const buffer = new Uint8Array(Buffer.from('abcd'));
const out = {};
tls.convertNPNProtocols(buffer, out);
assert(out.NPNProtocols.equals(Buffer.from('abcd')));
}