support PhantAuth authentication (#5850)
* support PhantAuth authentication * fix spelling issues * Add test case
This commit is contained in:
committed by
Diamond Lewis
parent
d810f34cc5
commit
dfe0ff753c
@@ -13,6 +13,7 @@ const responses = {
|
||||
wechat: { errcode: 0 },
|
||||
weibo: { uid: 'userId' },
|
||||
qq: 'callback( {"openid":"userId"} );', // yes it's like that, run eval in the client :P
|
||||
phantauth: { sub: 'userId' },
|
||||
};
|
||||
|
||||
describe('AuthenticationProviders', function() {
|
||||
@@ -33,6 +34,7 @@ describe('AuthenticationProviders', function() {
|
||||
'spotify',
|
||||
'wechat',
|
||||
'weibo',
|
||||
'phantauth',
|
||||
].map(function(providerName) {
|
||||
it('Should validate structure of ' + providerName, done => {
|
||||
const provider = require('../lib/Adapters/Auth/' + providerName);
|
||||
@@ -1165,3 +1167,23 @@ describe('apple signin auth adapter', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('phant auth adapter', () => {
|
||||
const httpsRequest = require('../lib/Adapters/Auth/httpsRequest');
|
||||
|
||||
it('validateAuthData should throw for invalid auth', async () => {
|
||||
const authData = {
|
||||
id: 'fakeid',
|
||||
access_token: 'sometoken',
|
||||
};
|
||||
const { adapter } = authenticationLoader.loadAuthAdapter('phantauth', {});
|
||||
|
||||
spyOn(httpsRequest, 'get').and.callFake(() => Promise.resolve({ sub: 'invalidID' }));
|
||||
try {
|
||||
await adapter.validateAuthData(authData);
|
||||
fail();
|
||||
} catch (e) {
|
||||
expect(e.message).toBe('PhantAuth auth is invalid for this user.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user