Skip to content

Use the correct function when validating google auth tokens #5018

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

Merged
merged 2 commits into from
Aug 31, 2018
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
12 changes: 6 additions & 6 deletions spec/AuthenticationAdapters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,35 +430,35 @@ describe('google auth adapter', () => {
const httpsRequest = require('../lib/Adapters/Auth/httpsRequest');

it('should use id_token for validation is passed', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ sub: 'userId' });
});
await google.validateAuthData({ id: 'userId', id_token: 'the_token' }, {});
});

it('should use id_token for validation is passed and responds with user_id', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ user_id: 'userId' });
});
await google.validateAuthData({ id: 'userId', id_token: 'the_token' }, {});
});

it('should use access_token for validation is passed and responds with user_id', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ user_id: 'userId' });
});
await google.validateAuthData({ id: 'userId', access_token: 'the_token' }, {});
});

it('should use access_token for validation is passed with sub', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ sub: 'userId' });
});
await google.validateAuthData({ id: 'userId', id_token: 'the_token' }, {});
});

it('should fail when the id_token is invalid', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ sub: 'badId' });
});
try {
Expand All @@ -470,7 +470,7 @@ describe('google auth adapter', () => {
});

it('should fail when the access_token is invalid', async () => {
spyOn(httpsRequest, 'request').and.callFake(() => {
spyOn(httpsRequest, 'get').and.callFake(() => {
return Promise.resolve({ sub: 'badId' });
});
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Auth/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function validateAppId() {

// A promisey wrapper for api requests
function googleRequest(path) {
return httpsRequest.request("https://www.googleapis.com/oauth2/v3/" + path);
return httpsRequest.get("https://www.googleapis.com/oauth2/v3/" + path);
}

module.exports = {
Expand Down