refactor: Dry handleAuthData for safer code maintenance in the future (#9025)
This commit is contained in:
@@ -487,6 +487,33 @@ describe('Auth Adapter features', () => {
|
||||
expect(baseAdapter2.validateAuthData).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should not perform authData validation twice when data mutated', async () => {
|
||||
spyOn(baseAdapter, 'validateAuthData').and.resolveTo({});
|
||||
await reconfigureServer({
|
||||
auth: { baseAdapter },
|
||||
allowExpiredAuthDataToken: false,
|
||||
});
|
||||
|
||||
const user = new Parse.User();
|
||||
|
||||
await user.save({
|
||||
authData: {
|
||||
baseAdapter: { id: 'baseAdapter', token: "sometoken1" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(baseAdapter.validateAuthData).toHaveBeenCalledTimes(1);
|
||||
|
||||
const user2 = new Parse.User();
|
||||
await user2.save({
|
||||
authData: {
|
||||
baseAdapter: { id: 'baseAdapter', token: "sometoken2" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(baseAdapter.validateAuthData).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should require additional provider if configured', async () => {
|
||||
await reconfigureServer({
|
||||
auth: { baseAdapter, additionalAdapter },
|
||||
@@ -937,7 +964,7 @@ describe('Auth Adapter features', () => {
|
||||
allowExpiredAuthDataToken: false,
|
||||
});
|
||||
logger = require('../lib/logger').logger;
|
||||
spyOn(logger, 'error').and.callFake(() => {});
|
||||
spyOn(logger, 'error').and.callFake(() => { });
|
||||
user = new Parse.User();
|
||||
await user.save({ authData: { modernAdapter: { id: 'modernAdapter' } } });
|
||||
const user2 = new Parse.User();
|
||||
|
||||
Reference in New Issue
Block a user