Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: emit auto-auth errors #907

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,7 @@ function makeAuthenticatedRequestFactory(config) {
}

function onAuthenticated(err, authenticatedReqOpts) {
// google-auth-library returns a "Could not load..." error if it can't get
// an access token. However, it's possible an API request doesn't need to
// be authenticated, e.g. when downloading a file from a public bucket. We
// consider this error a warning, and allow the request to go through
// without authentication, relying on the upstream API to return an error
// the user would find more helpful, should one occur.
if (err && err.message.indexOf('Could not load') === -1) {
if (err) {
if (stream) {
stream.destroy(err);
} else {
Expand Down
20 changes: 0 additions & 20 deletions test/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,26 +535,6 @@ describe('common/util', function() {
};
});

it('should not care about "Could not load" errors', function(done) {
var error = new Error('Could not load');

utilOverrides.decorateRequest = function() {};

authClient.authorizeRequest = function(rOpts, callback) {
setImmediate(function() {
callback(error);
});
};

var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory();
makeAuthenticatedRequest({}, {
onAuthenticated: function(err) {
assert.strictEqual(err, null);
done();
}
});
});

it('should invoke the callback with error', function(done) {
var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory();
makeAuthenticatedRequest({}, function(err) {
Expand Down