Skip to content

Commit

Permalink
quic: check setSocket natRebinding argument, extend test
Browse files Browse the repository at this point in the history
PR-URL: #34669
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
jasnell committed Aug 17, 2020
1 parent 10d5047 commit 442968c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/internal/quic/core.js
Expand Up @@ -2445,6 +2445,8 @@ class QuicClientSession extends QuicSession {
throw new ERR_INVALID_STATE('QuicSocket is already destroyed');
if (socket.closing)
throw new ERR_INVALID_STATE('QuicSocket is closing');
if (typeof natRebinding !== 'boolean')
throw new ERR_INVALID_ARG_TYPE('natRebinding', 'boolean', true);

await socket[kMaybeBind]();

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-quic-simple-client-migrate.js
Expand Up @@ -69,6 +69,17 @@ const server = createQuicSocket({ server: options });
const s1 = req.socket;
const a1 = req.socket.endpoints[0].address;

await Promise.all([1, {}, 'test', false, null, undefined].map((i) => {
return assert.rejects(req.setSocket(i), {
code: 'ERR_INVALID_ARG_TYPE'
});
}));
await Promise.all([1, {}, 'test', null].map((i) => {
return assert.rejects(req.setSocket(req.socket, i), {
code: 'ERR_INVALID_ARG_TYPE'
});
}));

await req.setSocket(client2);

// Verify that it is using a different network endpoint
Expand Down

0 comments on commit 442968c

Please sign in to comment.