This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quic: test client connect invalid options
PR-URL: #154 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'use strict'; | ||
|
||
// Tests QuicClientSession constructor options errors | ||
|
||
const common = require('../common'); | ||
if (!common.hasQuic) | ||
common.skip('missing quic'); | ||
|
||
const assert = require('assert'); | ||
const { createSocket } = require('quic'); | ||
|
||
const client = createSocket(); | ||
|
||
// Test invalid minDHSize options argument | ||
['test', 1n, {}, [], false].forEach((minDHSize) => { | ||
assert.throws(() => client.connect({ minDHSize }), { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
}); | ||
|
||
// Test invalid port argument option | ||
[-1, 'test', 1n, {}, [], NaN, false].forEach((port) => { | ||
assert.throws(() => client.connect({ port }), { | ||
code: 'ERR_INVALID_ARG_VALUE' | ||
}); | ||
}); | ||
|
||
// Test invalid address argument option | ||
[-1, 10, 1n, {}, []].forEach((address) => { | ||
assert.throws(() => client.connect({ address }), { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
}); | ||
|
||
// Test address can't be IP address argument option | ||
[ | ||
'0.0.0.0', | ||
'8.8.8.8', | ||
'127.0.0.1', | ||
'192.168.0.1', | ||
'::', | ||
'1::', | ||
'::1', | ||
'1::8', | ||
'1::7:8', | ||
'1:2:3:4:5:6:7:8', | ||
'1:2:3:4:5:6::8', | ||
'2001:0000:1234:0000:0000:C1C0:ABCD:0876', | ||
'3ffe:0b00:0000:0000:0001:0000:0000:000a', | ||
'a:0:0:0:0:0:0:0', | ||
'fe80::7:8%eth0', | ||
'fe80::7:8%1' | ||
].forEach((address) => { | ||
assert.throws(() => client.connect({ address }), { | ||
code: 'ERR_INVALID_ARG_VALUE' | ||
}); | ||
}); | ||
|
||
// Test invalid remoteTransportParams argument option | ||
[-1, 'test', 1n, {}, []].forEach((remoteTransportParams) => { | ||
assert.throws(() => client.connect({ remoteTransportParams }), { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
}); | ||
|
||
// Test invalid sessionTicket argument option | ||
[-1, 'test', 1n, {}, []].forEach((sessionTicket) => { | ||
assert.throws(() => client.connect({ sessionTicket }), { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
}); | ||
|
||
// Test invalid alpn argument option | ||
[-1, 10, 1n, {}, []].forEach((alpn) => { | ||
assert.throws(() => client.connect({ alpn }), { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
}); |