feat: extendSessionOnUse to automatically renew Parse Sessions (#8505)
This commit is contained in:
@@ -94,6 +94,35 @@ describe('Auth', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('can use extendSessionOnUse', async () => {
|
||||
await reconfigureServer({
|
||||
extendSessionOnUse: true,
|
||||
});
|
||||
|
||||
const user = new Parse.User();
|
||||
await user.signUp({
|
||||
username: 'hello',
|
||||
password: 'password',
|
||||
});
|
||||
const session = await new Parse.Query(Parse.Session).first();
|
||||
const updatedAt = new Date('2010');
|
||||
const expiry = new Date();
|
||||
expiry.setHours(expiry.getHours() + 1);
|
||||
|
||||
await Parse.Server.database.update(
|
||||
'_Session',
|
||||
{ objectId: session.id },
|
||||
{
|
||||
expiresAt: { __type: 'Date', iso: expiry.toISOString() },
|
||||
updatedAt: updatedAt.toISOString(),
|
||||
}
|
||||
);
|
||||
await session.fetch();
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await session.fetch();
|
||||
expect(session.get('expiresAt') > expiry).toBeTrue();
|
||||
});
|
||||
|
||||
it('should load auth without a config', async () => {
|
||||
const user = new Parse.User();
|
||||
await user.signUp({
|
||||
|
||||
@@ -367,6 +367,22 @@ describe('server', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw when extendSessionOnUse is invalid', async () => {
|
||||
await expectAsync(
|
||||
reconfigureServer({
|
||||
extendSessionOnUse: 'yolo',
|
||||
})
|
||||
).toBeRejectedWith('extendSessionOnUse must be a boolean value');
|
||||
});
|
||||
|
||||
it('should throw when revokeSessionOnPasswordReset is invalid', async () => {
|
||||
await expectAsync(
|
||||
reconfigureServer({
|
||||
revokeSessionOnPasswordReset: 'yolo',
|
||||
})
|
||||
).toBeRejectedWith('revokeSessionOnPasswordReset must be a boolean value');
|
||||
});
|
||||
|
||||
it('fails if the session length is not a number', done => {
|
||||
reconfigureServer({ sessionLength: 'test' })
|
||||
.then(done.fail)
|
||||
|
||||
Reference in New Issue
Block a user