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

Minor tweaks in [github] auth code #1862

Merged
merged 8 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions lib/token-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ class TokenPool {
this.fifoQueue.forEach(visit);
this.priorityQueue.forEach(visit);
}

allValidTokenIds() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple code, but adding a small test to our existing suite wouldn't hurt! 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

const result = [];
this.forEach(({ id }) => result.push(id));
return result;
}
}

module.exports = {
Expand Down
9 changes: 2 additions & 7 deletions lib/token-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,9 @@ class PoolingTokenProvider {
}

// Return an array of token strings.
toNative () {
const result = [];
toNative() {
return this.tokenPool.allValidTokenIds();

this.tokenPool.forEach(token => {
result.push(token.id);
});

return result;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/token-provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const assert = require('assert');
const { PoolingTokenProvider } = require('./token-provider');
const isValidGithubToken = require('./github-auth/is-valid-token')
const isValidGithubToken = require('../services/github/auth/is-valid-token')

describe('The token provider', function () {
describe('toNative', function () {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3406,10 +3406,10 @@ cache(function(data, match, sendBadge, request) {
var allReleases = match[2];
var format = match[3];
let apiUrl = `/repos/${userRepo}/releases`;
var badgeData = getBadgeData('release', data);
if (allReleases === undefined) {
apiUrl = apiUrl + '/latest';
}
var badgeData = getBadgeData('release', data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure how this change is relevant to this pull request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I came across it because it’s in the middle of a github badge affected by #1861.

if (badgeData.template === 'social') {
badgeData.logo = getLogo('github', data);
}
Expand Down