refs #5554 feat: add back test
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
91700e096e
commit
06d1de5a63
|
@ -0,0 +1,28 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('VnUser renewToken()', () => {
|
||||||
|
describe('when credentials are correct', () => {
|
||||||
|
it('should not do anything', async() => {
|
||||||
|
const login = await models.VnUser.signIn('employee', 'nightmare');
|
||||||
|
const accessToken = await models.AccessToken.findById(login.token);
|
||||||
|
const ctx = {req: {accessToken: accessToken}};
|
||||||
|
|
||||||
|
const response = await models.VnUser.renewToken(ctx);
|
||||||
|
|
||||||
|
expect(response.data.message).toBe('Token is active');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should invalidate the current token and create a new one', async() => {
|
||||||
|
const login = await models.VnUser.signIn('employee', 'nightmare');
|
||||||
|
const accessToken = await models.AccessToken.findById(login.token);
|
||||||
|
const ctx = {req: {accessToken: accessToken}};
|
||||||
|
const sevenHoursBefore = new Date(Date.now() - (7 * 60 * 60 * 1000));
|
||||||
|
ctx.req.accessToken.created = sevenHoursBefore;
|
||||||
|
|
||||||
|
const renewToken = await models.VnUser.renewToken(ctx);
|
||||||
|
|
||||||
|
expect(renewToken.token).toBeDefined();
|
||||||
|
expect(renewToken.created).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -74,7 +74,8 @@ describe('Component vnLayout', () => {
|
||||||
created: new Date()
|
created: new Date()
|
||||||
};
|
};
|
||||||
localStorage.setItem('renewPeriod', 100);
|
localStorage.setItem('renewPeriod', 100);
|
||||||
controller.vnTokenCreated.created = new Date(Date.now() - (60 * 60 * 1000));
|
const oneHourBefore = new Date(Date.now() - (60 * 60 * 1000));
|
||||||
|
controller.vnTokenCreated.created = oneHourBefore;
|
||||||
|
|
||||||
$httpBackend.expect('POST', `VnUsers/renewToken`).respond(response);
|
$httpBackend.expect('POST', `VnUsers/renewToken`).respond(response);
|
||||||
controller.checkTokenValidity();
|
controller.checkTokenValidity();
|
||||||
|
|
Loading…
Reference in New Issue