Skip to content

Commit d9dabd2

Browse files
committed
test: check options to create{Server,SecureContext}
Introduce a new test to validate the options being passed to `createServer` and `createSecureContext`. PR-URL: #3100
1 parent 001e88f commit d9dabd2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const tls = require('tls');
6+
7+
assert.throws(() => tls.createSecureContext({ciphers: 1}),
8+
/TypeError: Ciphers must be a string/);
9+
10+
assert.throws(() => tls.createServer({ciphers: 1}),
11+
/TypeError: Ciphers must be a string/);
12+
13+
assert.throws(() => tls.createSecureContext({key: 'dummykey', passphrase: 1}),
14+
/TypeError: Pass phrase must be a string/);
15+
16+
assert.throws(() => tls.createServer({key: 'dummykey', passphrase: 1}),
17+
/TypeError: Pass phrase must be a string/);
18+
19+
assert.throws(() => tls.createServer({ecdhCurve: 1}),
20+
/TypeError: ECDH curve name must be a string/);
21+
22+
assert.throws(() => tls.createServer({handshakeTimeout: 'abcd'}),
23+
/TypeError: handshakeTimeout must be a number/);
24+
25+
assert.throws(() => tls.createServer({sessionTimeout: 'abcd'}),
26+
/TypeError: Session timeout must be a 32-bit integer/);
27+
28+
assert.throws(() => tls.createServer({ticketKeys: 'abcd'}),
29+
/TypeError: Ticket keys must be a buffer/);
30+
31+
assert.throws(() => tls.createServer({ticketKeys: new Buffer(0)}),
32+
/TypeError: Ticket keys length must be 48 bytes/);
33+
34+
assert.throws(() => tls.createSecurePair({}),
35+
/Error: First argument must be a tls module SecureContext/);

0 commit comments

Comments
 (0)