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:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user