From f368e5010260259a21cce9c6665dd71439cf6c25 Mon Sep 17 00:00:00 2001 From: Ian Haken Date: Wed, 20 Jun 2018 14:59:26 -0700 Subject: [PATCH] Regenerate project files and add test covering checkServerIdentity callback. --- .../grpc-native-core/test/credentials_test.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/grpc-native-core/test/credentials_test.js b/packages/grpc-native-core/test/credentials_test.js index 58dddb50..b3f922fa 100644 --- a/packages/grpc-native-core/test/credentials_test.js +++ b/packages/grpc-native-core/test/credentials_test.js @@ -260,6 +260,36 @@ describe('client credentials', function() { done(); }); }); + it('Verify callback receives correct arguments', function(done) { + var callback_host, callback_cert; + var client_ssl_creds = grpc.credentials.createSsl(ca_data, null, null, { + "checkServerIdentity": function(host, cert) { + callback_host = host; + callback_cert = cert; + } + }); + var client = new Client('localhost:' + port, client_ssl_creds, + client_options); + client.unary({}, function(err, data) { + assert.ifError(err); + assert.equal(callback_host, 'foo.test.google.fr'); + assert.equal(callback_cert, pem_data); + done(); + }); + }); + it('Verify callback exception causes connection failure', function(done) { + var client_ssl_creds = grpc.credentials.createSsl(ca_data, null, null, { + "checkServerIdentity": function(host, cert) { + throw "Verification callback exception"; + } + }); + var client = new Client('localhost:' + port, client_ssl_creds, + client_options); + client.unary({}, function(err, data) { + assert.ok(err, "Should have raised an error"); + done(); + }); + }); it('Should update metadata with SSL creds', function(done) { var metadataUpdater = function(service_url, callback) { var metadata = new grpc.Metadata();