mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
31 lines
910 B
JavaScript
31 lines
910 B
JavaScript
|
const models = require('../../../core/server/models');
|
||
|
const should = require('should');
|
||
|
|
||
|
describe('Regression: models/single-use-token', function () {
|
||
|
before(function () {
|
||
|
models.init();
|
||
|
});
|
||
|
|
||
|
describe('findOne', function () {
|
||
|
it('Does not allow the same token to be read twice', async function () {
|
||
|
const insertedToken = await models.SingleUseToken.add({
|
||
|
data: 'some_data'
|
||
|
}, {});
|
||
|
|
||
|
const tokenFirstRead = await models.SingleUseToken.findOne({
|
||
|
token: insertedToken.get('token')
|
||
|
});
|
||
|
|
||
|
should.exist(tokenFirstRead);
|
||
|
should.equal(tokenFirstRead.id, insertedToken.id);
|
||
|
|
||
|
const tokenSecondRead = await models.SingleUseToken.findOne({
|
||
|
token: insertedToken.get('token')
|
||
|
});
|
||
|
|
||
|
should.not.exist(tokenSecondRead);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|