Auth module refactoring in order to be reusable (#4940)
* Auth module refactoring in order to be reusable * Ensure cache controller is properly forwarded from helpers * Nits
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
describe('Auth', () => {
|
||||
const Auth = require('../lib/Auth.js').Auth;
|
||||
|
||||
const { Auth, getAuthForSessionToken } = require('../lib/Auth.js');
|
||||
const Config = require('../lib/Config');
|
||||
describe('getUserRoles', () => {
|
||||
let auth;
|
||||
let config;
|
||||
@@ -90,4 +90,33 @@ describe('Auth', () => {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should load auth without a config', async () => {
|
||||
const user = new Parse.User();
|
||||
await user.signUp({
|
||||
username: 'hello',
|
||||
password: 'password'
|
||||
});
|
||||
expect(user.getSessionToken()).not.toBeUndefined();
|
||||
const userAuth = await getAuthForSessionToken({
|
||||
sessionToken: user.getSessionToken()
|
||||
});
|
||||
expect(userAuth.user instanceof Parse.User).toBe(true);
|
||||
expect(userAuth.user.id).toBe(user.id);
|
||||
});
|
||||
|
||||
it('should load auth with a config', async () => {
|
||||
const user = new Parse.User();
|
||||
await user.signUp({
|
||||
username: 'hello',
|
||||
password: 'password'
|
||||
});
|
||||
expect(user.getSessionToken()).not.toBeUndefined();
|
||||
const userAuth = await getAuthForSessionToken({
|
||||
sessionToken: user.getSessionToken(),
|
||||
config: Config.get('test'),
|
||||
});
|
||||
expect(userAuth.user instanceof Parse.User).toBe(true);
|
||||
expect(userAuth.user.id).toBe(user.id);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user