Skip to content
Snippets Groups Projects
Commit 2106cd3e authored by kpayson64's avatar kpayson64 Committed by GitHub
Browse files

Merge pull request #7614 from murgatroid99/node_credentials_error_code_fix

Fix error handling authentication errors with non-numeric error codes
parents 8ebb2a95 2db3d992
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,8 @@ var Metadata = require('./metadata.js');
var common = require('./common.js');
var _ = require('lodash');
/**
* Create an SSL Credentials object. If using a client-side certificate, both
* the second and third arguments must be passed.
......@@ -99,7 +101,7 @@ exports.createFromMetadataGenerator = function(metadata_generator) {
var message = '';
if (error) {
message = error.message;
if (error.hasOwnProperty('code')) {
if (error.hasOwnProperty('code') && _.isFinite(error.code)) {
code = error.code;
} else {
code = grpc.status.UNAUTHENTICATED;
......
......@@ -71,7 +71,10 @@ var fakeSuccessfulGoogleCredentials = {
var fakeFailingGoogleCredentials = {
getRequestMetadata: function(service_url, callback) {
setTimeout(function() {
callback(new Error('Authentication failure'));
// Google credentials currently adds string error codes to auth errors
var error = new Error('Authentication failure');
error.code = 'ENOENT';
callback(error);
}, 0);
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment