fix: live query role cache does not clear when a user is added to a role (#8026)
This commit is contained in:
@@ -836,6 +836,50 @@ describe('ParseLiveQuery', function () {
|
||||
}
|
||||
});
|
||||
|
||||
it('LiveQuery should work with changing role', async () => {
|
||||
await reconfigureServer({
|
||||
liveQuery: {
|
||||
classNames: ['Chat'],
|
||||
},
|
||||
startLiveQueryServer: true,
|
||||
});
|
||||
const user = new Parse.User();
|
||||
user.setUsername('username');
|
||||
user.setPassword('password');
|
||||
await user.signUp();
|
||||
|
||||
const role = new Parse.Role('Test', new Parse.ACL(user));
|
||||
await role.save();
|
||||
|
||||
const chatQuery = new Parse.Query('Chat');
|
||||
const subscription = await chatQuery.subscribe();
|
||||
subscription.on('create', () => {
|
||||
fail('should not call create as user is not part of role.');
|
||||
});
|
||||
|
||||
const object = new Parse.Object('Chat');
|
||||
const acl = new Parse.ACL();
|
||||
acl.setRoleReadAccess(role, true);
|
||||
object.setACL(acl);
|
||||
object.set({ foo: 'bar' });
|
||||
await object.save(null, { useMasterKey: true });
|
||||
role.getUsers().add(user);
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await role.save();
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
object.set('foo', 'yolo');
|
||||
await Promise.all([
|
||||
new Promise(resolve => {
|
||||
subscription.on('update', obj => {
|
||||
expect(obj.get('foo')).toBe('yolo');
|
||||
expect(obj.getACL().toJSON()).toEqual({ 'role:Test': { read: true } });
|
||||
resolve();
|
||||
});
|
||||
}),
|
||||
object.save(null, { useMasterKey: true }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('liveQuery on Session class', async done => {
|
||||
await reconfigureServer({
|
||||
liveQuery: { classNames: [Parse.Session] },
|
||||
|
||||
Reference in New Issue
Block a user