Merge pull request #1852 from murgatroid99/grpc-js_bind_creds_typecheck

grpc-js: Tighten server.bindAsync creds typecheck
This commit is contained in:
Michael Lumish 2021-07-19 13:15:29 -07:00 committed by GitHub
commit bd1571fa94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -237,8 +237,8 @@ export class Server {
throw new TypeError('port must be a string');
}
if (creds === null || typeof creds !== 'object') {
throw new TypeError('creds must be an object');
if (creds === null || !(creds instanceof ServerCredentials)) {
throw new TypeError('creds must be a ServerCredentials object');
}
if (typeof callback !== 'function') {

View File

@ -116,7 +116,11 @@ describe('Server', () => {
assert.throws(() => {
server.bindAsync('localhost:0', null as any, noop);
}, /creds must be an object/);
}, /creds must be a ServerCredentials object/);
assert.throws(() => {
server.bindAsync('localhost:0', grpc.credentials.createInsecure() as any, noop);
}, /creds must be a ServerCredentials object/);
assert.throws(() => {
server.bindAsync(