Use an empty object as default value of options for Google Sign in (#6844)

* Use an empty object as default value of options for Google Sign in

* add test case

* Update test case to specifically  for google auth
This commit is contained in:
Kevin Kuang
2020-10-14 23:17:10 -04:00
committed by GitHub
parent dc502d17ef
commit 9d836ee87b
2 changed files with 24 additions and 1 deletions

View File

@@ -531,4 +531,27 @@ describe('server', () => {
})
.catch(done.fail);
});
it('should not fail when Google signin is introduced without the optional clientId', done => {
const jwt = require('jsonwebtoken');
reconfigureServer({
auth: { google: {} }
})
.then(() => {
const fakeClaim = {
iss: 'https://accounts.google.com',
aud: 'secret',
exp: Date.now(),
sub: 'the_user_id',
};
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
spyOn(jwt, 'decode').and.callFake(() => fakeDecodedToken);
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
const user = new Parse.User();
user.linkWith('google', { authData: { id: 'the_user_id', id_token: 'the_token' }})
.then(done);
})
.catch(done.fail);
});
});

View File

@@ -113,7 +113,7 @@ async function verifyIdToken({ id_token: token, id }, { clientId }) {
}
// Returns a promise that fulfills if this user id is valid.
function validateAuthData(authData, options) {
function validateAuthData(authData, options = {}) {
return verifyIdToken(authData, options);
}