|
@@ -1,3 +1,5 @@
|
|
|
|
|
+import logger from '@overleaf/logger'
|
|
|
|
|
+import sinon from 'sinon'
|
|
|
import User from './helpers/User.mjs'
|
|
import User from './helpers/User.mjs'
|
|
|
import Subscription from './helpers/Subscription.mjs'
|
|
import Subscription from './helpers/Subscription.mjs'
|
|
|
import request from './helpers/request.js'
|
|
import request from './helpers/request.js'
|
|
@@ -18,6 +20,8 @@ let MockDocstoreApi,
|
|
|
MockGitBridgeApi,
|
|
MockGitBridgeApi,
|
|
|
MockHistoryBackupDeletionApi
|
|
MockHistoryBackupDeletionApi
|
|
|
|
|
|
|
|
|
|
+let spy
|
|
|
|
|
+
|
|
|
before(function () {
|
|
before(function () {
|
|
|
MockDocstoreApi = MockDocstoreApiClass.instance()
|
|
MockDocstoreApi = MockDocstoreApiClass.instance()
|
|
|
MockFilestoreApi = MockFilestoreApiClass.instance()
|
|
MockFilestoreApi = MockFilestoreApiClass.instance()
|
|
@@ -28,6 +32,7 @@ before(function () {
|
|
|
|
|
|
|
|
describe('Deleting a user', function () {
|
|
describe('Deleting a user', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
|
|
+ spy = sinon.spy(logger, 'info')
|
|
|
async.auto(
|
|
async.auto(
|
|
|
{
|
|
{
|
|
|
user: cb => {
|
|
user: cb => {
|
|
@@ -64,6 +69,10 @@ describe('Deleting a user', function () {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ afterEach(function () {
|
|
|
|
|
+ spy.restore()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('Should remove the user from active users', function (done) {
|
|
it('Should remove the user from active users', function (done) {
|
|
|
this.user.get((error, user) => {
|
|
this.user.get((error, user) => {
|
|
|
expect(error).not.to.exist
|
|
expect(error).not.to.exist
|
|
@@ -183,6 +192,7 @@ describe('Deleting a user', function () {
|
|
|
|
|
|
|
|
describe('Deleting a project', function () {
|
|
describe('Deleting a project', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
|
|
+ spy = sinon.spy(logger, 'info')
|
|
|
this.user = new User()
|
|
this.user = new User()
|
|
|
this.projectName = 'wombat'
|
|
this.projectName = 'wombat'
|
|
|
this.user.ensureUserExists(() => {
|
|
this.user.ensureUserExists(() => {
|
|
@@ -195,6 +205,10 @@ describe('Deleting a project', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ afterEach(function () {
|
|
|
|
|
+ logger.info.restore()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('Should remove the project from active projects', function (done) {
|
|
it('Should remove the project from active projects', function (done) {
|
|
|
this.user.getProject(this.projectId, (error, project) => {
|
|
this.user.getProject(this.projectId, (error, project) => {
|
|
|
expect(error).not.to.exist
|
|
expect(error).not.to.exist
|
|
@@ -292,6 +306,28 @@ describe('Deleting a project', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('Should log a successful deletion', function (done) {
|
|
|
|
|
+ request.post(
|
|
|
|
|
+ `/internal/project/${this.projectId}/expire-deleted-project`,
|
|
|
|
|
+ {
|
|
|
|
|
+ auth: {
|
|
|
|
|
+ user: settings.apis.web.user,
|
|
|
|
|
+ pass: settings.apis.web.pass,
|
|
|
|
|
+ sendImmediately: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ (error, res) => {
|
|
|
|
|
+ expect(error).not.to.exist
|
|
|
|
|
+ expect(res.statusCode).to.equal(200)
|
|
|
|
|
+ expect(spy).to.have.been.calledWithMatch(
|
|
|
|
|
+ { projectId: this.projectId, userId: this.user._id },
|
|
|
|
|
+ 'expired deleted project successfully'
|
|
|
|
|
+ )
|
|
|
|
|
+ done()
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('Should destroy the docs', function (done) {
|
|
it('Should destroy the docs', function (done) {
|
|
|
expect(
|
|
expect(
|
|
|
MockDocstoreApi.docs[this.projectId.toString()][this.docId.toString()]
|
|
MockDocstoreApi.docs[this.projectId.toString()][this.docId.toString()]
|