Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius Seltenheim committed Jul 5, 2016
1 parent 4b94ecf commit 0eaa80a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/common/token-based-auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
* @module common/token-based-auth-client
*/

'use strict';

/*
* creates a simpler auth client that works only with an accessToken
*
*
* @param {string=} accessToken - The accessToken to use
*/
function tokenBasedAuthClient(accessToken) {
return {
authorizeRequest: function(reqOpts, done) {
reqOpts.headers = reqOpts.headers || {};

reqOpts.headers['Authorization'] = 'Bearer ' + accessToken;
reqOpts.headers.Authorization = 'Bearer ' + accessToken;
done(null, reqOpts);
},
getCredentials: function() {
return {
accessToken: accessToken
}
};
}
};
}
Expand Down
4 changes: 3 additions & 1 deletion lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ util.shouldRetryRequest = shouldRetryRequest;
function makeAuthenticatedRequestFactory(config) {
config = config || {};

var authClient = config.accessToken ? tokenBasedAuth(config.accessToken) : googleAuth(config);
var authClient = config.accessToken ?
tokenBasedAuth(config.accessToken) :
googleAuth(config);

/**
* The returned function that will make an authenticated request.
Expand Down
2 changes: 1 addition & 1 deletion test/common/token-based-auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('common/token-based-auth-client', function() {
describe('authorizeRequest', function() {
it('should add Authorization header to request', function(done) {
var req = {};
var expected = { headers: {Authorization: 'Bearer ' + token}}
var expected = { headers: {Authorization: 'Bearer ' + token}};

authClient.authorizeRequest(req, function(err) {
assert.deepEqual(req, expected);
Expand Down
10 changes: 8 additions & 2 deletions test/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,17 @@ describe('common/util', function() {
});

it('should return a getCredentials method', function() {
assert.equal(typeof makeAuthenticatedRequest.getCredentials, 'function');
assert.equal(
typeof makeAuthenticatedRequest.getCredentials,
'function'
);
});

it('getCredentials should return the accessToken', function() {
assert.equal(makeAuthenticatedRequest.getCredentials().accessToken, token);
assert.equal(
makeAuthenticatedRequest.getCredentials().accessToken,
token
);
});
});

Expand Down

0 comments on commit 0eaa80a

Please sign in to comment.