-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: migrate argument type-checking errors
* Throw ERR_INVALID_ARG_TYPE from public APIs * Assert argument types in bindings instead of throwing errors PR-URL: #18125 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
f75bc2c
commit 9ffebea
Showing
4 changed files
with
60 additions
and
19 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
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
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
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,30 @@ | ||
'use strict'; | ||
|
||
// This tests the errors thrown from TLSSocket.prototype.setServername | ||
|
||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const { connect } = require('tls'); | ||
const makeDuplexPair = require('../common/duplexpair'); | ||
const { clientSide } = makeDuplexPair(); | ||
|
||
const ca = fixtures.readKey('ca1-cert.pem'); | ||
|
||
const client = connect({ | ||
socket: clientSide, | ||
ca, | ||
host: 'agent1' // Hostname from certificate | ||
}); | ||
|
||
[undefined, null, 1, true, {}].forEach((value) => { | ||
common.expectsError(() => { | ||
client.setServername(value); | ||
}, { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
message: 'The "name" argument must be of type string' | ||
}); | ||
}); |