diff options
author | murgatroid99 <mlumish@google.com> | 2015-05-14 10:04:48 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-05-14 10:04:48 -0700 |
commit | 2c5fa16f14b02efe1dda5840aa6122c1def6028e (patch) | |
tree | 66f1e187e22535ea688b84301848ae750775324c /src/node | |
parent | e02c1482716466ccc5fa2dab8a632dee1020e5d1 (diff) |
Fixed client auth implementation and tests
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/interop/interop_client.js | 2 | ||||
-rw-r--r-- | src/node/src/client.js | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index 8059c1a003..402843162e 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -271,7 +271,7 @@ function cancelAfterFirstResponse(client, done) { * @param {function} done Callback to call when the test is completed. Included * primarily for use with mocha */ -function authTest(expected_user, client, scope, done) { +function authTest(expected_user, scope, client, done) { (new GoogleAuth()).getApplicationDefault(function(err, credential) { assert.ifError(err); if (credential.createScopedRequired() && scope) { diff --git a/src/node/src/client.js b/src/node/src/client.js index 707a2d99d8..46d476b9f4 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -223,7 +223,7 @@ function makeUnaryRequestFunction(method, serialize, deserialize) { emitter.cancel = function cancel() { call.cancel(); }; - this.updateMetadata(metadata, function(error, metadata) { + this.updateMetadata(this.auth_uri, metadata, function(error, metadata) { if (error) { call.cancel(); callback(error); @@ -289,7 +289,7 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) { metadata = {}; } var stream = new ClientWritableStream(call, serialize); - this.updateMetadata(metadata, function(error, metadata) { + this.updateMetadata(this.auth_uri, metadata, function(error, metadata) { if (error) { call.cancel(); callback(error); @@ -360,7 +360,7 @@ function makeServerStreamRequestFunction(method, serialize, deserialize) { metadata = {}; } var stream = new ClientReadableStream(call, deserialize); - this.updateMetadata(metadata, function(error, metadata) { + this.updateMetadata(this.auth_uri, metadata, function(error, metadata) { if (error) { call.cancel(); stream.emit('error', error); @@ -427,7 +427,7 @@ function makeBidiStreamRequestFunction(method, serialize, deserialize) { metadata = {}; } var stream = new ClientDuplexStream(call, serialize, deserialize); - this.updateMetadata(metadata, function(error, metadata) { + this.updateMetadata(this.auth_uri, metadata, function(error, metadata) { if (error) { call.cancel(); stream.emit('error', error); @@ -503,10 +503,11 @@ function makeClientConstructor(methods, serviceName) { callback(null, metadata); }; } + this.server_address = address.replace(/\/$/, ''); this.channel = new grpc.Channel(address, options); - this.updateMetadata = _.partial(updateMetadata, - this.server_address + '/' + serviceName); + this.auth_uri = this.server_address + '/' + serviceName; + this.updateMetadata = updateMetadata; } _.each(methods, function(attrs, name) { |