Add config.expireInactiveSession to add support for non-expiring inactive sessions (#1536)
* Create non-expiring session when sessionLength is zero * Introduce expireInactiveSessions setting
This commit is contained in:
@@ -352,4 +352,31 @@ describe('rest create', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("can create a session with no expiration", (done) => {
|
||||
var user = {
|
||||
username: 'asdf',
|
||||
password: 'zxcv',
|
||||
foo: 'bar'
|
||||
};
|
||||
config.expireInactiveSessions = false;
|
||||
|
||||
rest.create(config, auth.nobody(config), '_User', user)
|
||||
.then((r) => {
|
||||
expect(Object.keys(r.response).length).toEqual(3);
|
||||
expect(typeof r.response.objectId).toEqual('string');
|
||||
expect(typeof r.response.createdAt).toEqual('string');
|
||||
expect(typeof r.response.sessionToken).toEqual('string');
|
||||
return rest.find(config, auth.master(config),
|
||||
'_Session', {sessionToken: r.response.sessionToken});
|
||||
})
|
||||
.then((r) => {
|
||||
expect(r.results.length).toEqual(1);
|
||||
|
||||
var session = r.results[0];
|
||||
expect(session.expiresAt).toBeUndefined();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -332,6 +332,29 @@ describe('server', () => {
|
||||
sessionLength: '0'
|
||||
})).toThrow('Session length must be a value greater than 0.');
|
||||
done();
|
||||
});
|
||||
|
||||
it('ignores the session length when expireInactiveSessions set to false', (done) => {
|
||||
expect(() => setServerConfiguration({
|
||||
serverURL: 'http://localhost:8378/1',
|
||||
appId: 'test',
|
||||
appName: 'unused',
|
||||
javascriptKey: 'test',
|
||||
masterKey: 'test',
|
||||
sessionLength: '-33',
|
||||
expireInactiveSessions: false
|
||||
})).not.toThrow();
|
||||
|
||||
expect(() => setServerConfiguration({
|
||||
serverURL: 'http://localhost:8378/1',
|
||||
appId: 'test',
|
||||
appName: 'unused',
|
||||
javascriptKey: 'test',
|
||||
masterKey: 'test',
|
||||
sessionLength: '0',
|
||||
expireInactiveSessions: false
|
||||
})).not.toThrow();
|
||||
done();
|
||||
})
|
||||
|
||||
it('fails if you try to set revokeSessionOnPasswordReset to non-boolean', done => {
|
||||
|
||||
Reference in New Issue
Block a user