Skip to content

Commit

Permalink
test: check options to create{Server,SecureContext}
Browse files Browse the repository at this point in the history
Introduce a new test to validate the options being passed to
`createServer` and `createSecureContext`.

PR-URL: #3100
  • Loading branch information
thefourtheye committed Mar 25, 2016
1 parent 001e88f commit d9dabd2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/parallel/test-tls-basic-validations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'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: new Buffer(0)}),
/TypeError: Ticket keys length must be 48 bytes/);

assert.throws(() => tls.createSecurePair({}),
/Error: First argument must be a tls module SecureContext/);

0 comments on commit d9dabd2

Please sign in to comment.