Support Google Play Games Service (#6147)
* Support Google Play Games Service * clean up * improve coverage * more tests
This commit is contained in:
@@ -5,6 +5,7 @@ const defaultColumns = require('../lib/Controllers/SchemaController')
|
||||
const authenticationLoader = require('../lib/Adapters/Auth');
|
||||
const path = require('path');
|
||||
const responses = {
|
||||
gpgames: { playerId: 'userId' },
|
||||
instagram: { data: { id: 'userId' } },
|
||||
janrainengage: { stat: 'ok', profile: { identifier: 'userId' } },
|
||||
janraincapture: { stat: 'ok', result: 'userId' },
|
||||
@@ -22,6 +23,7 @@ describe('AuthenticationProviders', function() {
|
||||
[
|
||||
'apple',
|
||||
'gcenter',
|
||||
'gpgames',
|
||||
'facebook',
|
||||
'facebookaccountkit',
|
||||
'github',
|
||||
@@ -648,6 +650,37 @@ describe('google auth adapter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('google play games service auth', () => {
|
||||
const gpgames = require('../lib/Adapters/Auth/gpgames');
|
||||
const httpsRequest = require('../lib/Adapters/Auth/httpsRequest');
|
||||
|
||||
it('validateAuthData should pass validation', async () => {
|
||||
spyOn(httpsRequest, 'get').and.callFake(() => {
|
||||
return Promise.resolve({ playerId: 'userId' });
|
||||
});
|
||||
await gpgames.validateAuthData({
|
||||
id: 'userId',
|
||||
access_token: 'access_token',
|
||||
});
|
||||
});
|
||||
|
||||
it('validateAuthData should throw error', async () => {
|
||||
spyOn(httpsRequest, 'get').and.callFake(() => {
|
||||
return Promise.resolve({ playerId: 'invalid' });
|
||||
});
|
||||
try {
|
||||
await gpgames.validateAuthData({
|
||||
id: 'userId',
|
||||
access_token: 'access_token',
|
||||
});
|
||||
} catch (e) {
|
||||
expect(e.message).toBe(
|
||||
'Google Play Games Services - authData is invalid for this user.'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('oauth2 auth adapter', () => {
|
||||
const oauth2 = require('../lib/Adapters/Auth/oauth2');
|
||||
const httpsRequest = require('../lib/Adapters/Auth/httpsRequest');
|
||||
|
||||
Reference in New Issue
Block a user