refs #554 delete: test back que falla
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-05-30 12:06:15 +02:00
parent 32badef787
commit 2b34dd19e8
1 changed files with 0 additions and 28 deletions

View File

@ -1,28 +0,0 @@
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();
});
});
});