2024-02-27 13:26:54 +00:00
|
|
|
const {models} = require('vn-loopback/server/server');
|
2024-02-29 06:40:20 +00:00
|
|
|
describe('Share Token', () => {
|
2024-02-27 13:26:54 +00:00
|
|
|
let ctx = null;
|
|
|
|
beforeAll(async() => {
|
|
|
|
const unAuthCtx = {
|
|
|
|
req: {
|
|
|
|
headers: {},
|
|
|
|
connection: {
|
|
|
|
remoteAddress: '127.0.0.1'
|
|
|
|
},
|
|
|
|
getLocale: () => 'en'
|
|
|
|
},
|
|
|
|
args: {}
|
|
|
|
};
|
|
|
|
let login = await models.VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare');
|
|
|
|
let accessToken = await models.AccessToken.findById(login.token);
|
|
|
|
ctx = {req: {accessToken: accessToken}};
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should renew token', async() => {
|
|
|
|
const multimediaToken = await models.VnUser.shareToken(ctx);
|
|
|
|
|
|
|
|
expect(Object.keys(multimediaToken).length).toEqual(1);
|
|
|
|
expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId);
|
|
|
|
expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia');
|
|
|
|
});
|
|
|
|
});
|