diff --git a/package-lock.json b/package-lock.json index 0fa0ce2ceb..5376d8e58a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44629,7 +44629,7 @@ "minimist": "^1.2.7", "mmmagic": "^0.5.3", "moment": "^2.29.4", - "mongodb": "5.9.2", + "mongodb-legacy": "5.0.0", "mongoose": "^7.8.0", "multer": "overleaf/multer#e1df247fbf8e7590520d20ae3601eaef9f3d2e9e", "nocache": "^2.1.0", @@ -45844,6 +45844,17 @@ } } }, + "services/web/node_modules/mongodb-legacy": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mongodb-legacy/-/mongodb-legacy-5.0.0.tgz", + "integrity": "sha512-q2G+MRwde6114bCAF/EZLmMXSsebIKMHmzsfOJq6M/Tj4gr3wLT50+rJsJNkiR0e0kjFx3dllWjqwRR1n11Zsw==", + "dependencies": { + "mongodb": "^5.0.0" + }, + "engines": { + "node": ">=14.20.1" + } + }, "services/web/node_modules/mongoose": { "version": "7.8.0", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.8.0.tgz", @@ -53393,7 +53404,7 @@ "mocha-each": "^2.0.1", "mock-fs": "^5.1.2", "moment": "^2.29.4", - "mongodb": "5.9.2", + "mongodb-legacy": "5.0.0", "mongoose": "^7.8.0", "multer": "overleaf/multer#e1df247fbf8e7590520d20ae3601eaef9f3d2e9e", "nocache": "^2.1.0", @@ -54199,6 +54210,14 @@ "socks": "^2.7.1" } }, + "mongodb-legacy": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mongodb-legacy/-/mongodb-legacy-5.0.0.tgz", + "integrity": "sha512-q2G+MRwde6114bCAF/EZLmMXSsebIKMHmzsfOJq6M/Tj4gr3wLT50+rJsJNkiR0e0kjFx3dllWjqwRR1n11Zsw==", + "requires": { + "mongodb": "^5.0.0" + } + }, "mongoose": { "version": "7.8.0", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.8.0.tgz", diff --git a/services/web/app/src/Features/Authorization/AuthorizationManager.js b/services/web/app/src/Features/Authorization/AuthorizationManager.js index f4789668ee..28de66047f 100644 --- a/services/web/app/src/Features/Authorization/AuthorizationManager.js +++ b/services/web/app/src/Features/Authorization/AuthorizationManager.js @@ -1,5 +1,5 @@ const { callbackify } = require('util') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter') const CollaboratorsHandler = require('../Collaborators/CollaboratorsHandler') const ProjectGetter = require('../Project/ProjectGetter') diff --git a/services/web/app/src/Features/Authorization/AuthorizationMiddleware.js b/services/web/app/src/Features/Authorization/AuthorizationMiddleware.js index 36f75741b2..6b2d2ab920 100644 --- a/services/web/app/src/Features/Authorization/AuthorizationMiddleware.js +++ b/services/web/app/src/Features/Authorization/AuthorizationMiddleware.js @@ -1,6 +1,6 @@ const AuthorizationManager = require('./AuthorizationManager') const logger = require('@overleaf/logger') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../Errors/Errors') const HttpErrorHandler = require('../Errors/HttpErrorHandler') const AuthenticationController = require('../Authentication/AuthenticationController') diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsController.js b/services/web/app/src/Features/Collaborators/CollaboratorsController.js index 9b1a017b1e..22ab26bb53 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsController.js +++ b/services/web/app/src/Features/Collaborators/CollaboratorsController.js @@ -1,6 +1,6 @@ const OError = require('@overleaf/o-error') const HttpErrorHandler = require('../../Features/Errors/HttpErrorHandler') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const CollaboratorsHandler = require('./CollaboratorsHandler') const CollaboratorsGetter = require('./CollaboratorsGetter') const OwnershipTransferHandler = require('./OwnershipTransferHandler') diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsGetter.js b/services/web/app/src/Features/Collaborators/CollaboratorsGetter.js index 8d053b028d..5d729437a2 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsGetter.js +++ b/services/web/app/src/Features/Collaborators/CollaboratorsGetter.js @@ -1,6 +1,6 @@ const { callbackify } = require('util') const pLimit = require('p-limit') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const OError = require('@overleaf/o-error') const { Project } = require('../../models/Project') const UserGetter = require('../User/UserGetter') diff --git a/services/web/app/src/Features/Helpers/Mongo.js b/services/web/app/src/Features/Helpers/Mongo.js index f2121ac009..3ec083a1f5 100644 --- a/services/web/app/src/Features/Helpers/Mongo.js +++ b/services/web/app/src/Features/Helpers/Mongo.js @@ -1,5 +1,5 @@ const OError = require('@overleaf/o-error') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { ObjectId: MongooseObjectId } = require('mongoose').mongo function _getObjectIdInstance(id) { diff --git a/services/web/app/src/Features/History/HistoryRangesSupportMigration.js b/services/web/app/src/Features/History/HistoryRangesSupportMigration.js index cce6f18ffd..210c3cfe4b 100644 --- a/services/web/app/src/Features/History/HistoryRangesSupportMigration.js +++ b/services/web/app/src/Features/History/HistoryRangesSupportMigration.js @@ -1,7 +1,7 @@ // @ts-check const { callbackify } = require('util') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const OError = require('@overleaf/o-error') const logger = require('@overleaf/logger') const HistoryManager = require('../History/HistoryManager') diff --git a/services/web/app/src/Features/InactiveData/InactiveProjectManager.js b/services/web/app/src/Features/InactiveData/InactiveProjectManager.js index d7b1372f7b..fec9405a44 100644 --- a/services/web/app/src/Features/InactiveData/InactiveProjectManager.js +++ b/services/web/app/src/Features/InactiveData/InactiveProjectManager.js @@ -4,7 +4,7 @@ const DocstoreManager = require('../Docstore/DocstoreManager') const ProjectGetter = require('../Project/ProjectGetter') const ProjectUpdateHandler = require('../Project/ProjectUpdateHandler') const { Project } = require('../../models/Project') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { READ_PREFERENCE_SECONDARY } = require('../../infrastructure/mongodb') const { callbackifyAll } = require('@overleaf/promise-utils') diff --git a/services/web/app/src/Features/Institutions/InstitutionsManager.js b/services/web/app/src/Features/Institutions/InstitutionsManager.js index f458121296..b6d554dd78 100644 --- a/services/web/app/src/Features/Institutions/InstitutionsManager.js +++ b/services/web/app/src/Features/Institutions/InstitutionsManager.js @@ -2,7 +2,7 @@ const { callbackifyAll, promiseMapWithLimit, } = require('@overleaf/promise-utils') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Settings = require('@overleaf/settings') const logger = require('@overleaf/logger') const { fetchJson } = require('@overleaf/fetch-utils') diff --git a/services/web/app/src/Features/Project/FolderStructureBuilder.js b/services/web/app/src/Features/Project/FolderStructureBuilder.js index ddf6f4bb48..d091c71a0d 100644 --- a/services/web/app/src/Features/Project/FolderStructureBuilder.js +++ b/services/web/app/src/Features/Project/FolderStructureBuilder.js @@ -1,6 +1,6 @@ const Path = require('path') const OError = require('@overleaf/o-error') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') module.exports = { buildFolderStructure } diff --git a/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js b/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js index 82944d4c47..59547e7b40 100644 --- a/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js +++ b/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { Project } = require('../../models/Project') const { callbackifyAll } = require('@overleaf/promise-utils') diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 84287cd84a..356af8b637 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -5,7 +5,7 @@ const { setTimeout } = require('timers/promises') const pProps = require('p-props') const logger = require('@overleaf/logger') const { expressify } = require('@overleaf/promise-utils') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const ProjectDeleter = require('./ProjectDeleter') const ProjectDuplicator = require('./ProjectDuplicator') const ProjectCreationHandler = require('./ProjectCreationHandler') diff --git a/services/web/app/src/Features/Project/ProjectCreationHandler.js b/services/web/app/src/Features/Project/ProjectCreationHandler.js index 0f8bdcf904..3829caaafa 100644 --- a/services/web/app/src/Features/Project/ProjectCreationHandler.js +++ b/services/web/app/src/Features/Project/ProjectCreationHandler.js @@ -1,7 +1,7 @@ const OError = require('@overleaf/o-error') const metrics = require('@overleaf/metrics') const Settings = require('@overleaf/settings') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Features = require('../../infrastructure/Features') const { Project } = require('../../models/Project') const { Folder } = require('../../models/Folder') diff --git a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js index 73f7d57ada..dcf1bd0471 100644 --- a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js +++ b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js @@ -2,7 +2,7 @@ const { callbackify } = require('util') const { callbackifyMultiResult } = require('@overleaf/promise-utils') const logger = require('@overleaf/logger') const path = require('path') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Settings = require('@overleaf/settings') const OError = require('@overleaf/o-error') const CooldownManager = require('../Cooldown/CooldownManager') diff --git a/services/web/app/src/Features/Project/ProjectHelper.js b/services/web/app/src/Features/Project/ProjectHelper.js index 1c91e6c12a..404d079c83 100644 --- a/services/web/app/src/Features/Project/ProjectHelper.js +++ b/services/web/app/src/Features/Project/ProjectHelper.js @@ -1,5 +1,5 @@ // ts-check -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const _ = require('lodash') const { promisify } = require('util') const Settings = require('@overleaf/settings') diff --git a/services/web/app/src/Features/SplitTests/SplitTestSessionHandler.js b/services/web/app/src/Features/SplitTests/SplitTestSessionHandler.js index 1b9bf5597f..52d13527cf 100644 --- a/services/web/app/src/Features/SplitTests/SplitTestSessionHandler.js +++ b/services/web/app/src/Features/SplitTests/SplitTestSessionHandler.js @@ -1,6 +1,6 @@ const { callbackify } = require('util') const _ = require('lodash') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const logger = require('@overleaf/logger') const Metrics = require('@overleaf/metrics') const SessionManager = require('../Authentication/SessionManager') diff --git a/services/web/app/src/Features/Subscription/RecurlyEventHandler.js b/services/web/app/src/Features/Subscription/RecurlyEventHandler.js index d933bffc1c..30b780221e 100644 --- a/services/web/app/src/Features/Subscription/RecurlyEventHandler.js +++ b/services/web/app/src/Features/Subscription/RecurlyEventHandler.js @@ -1,6 +1,6 @@ const AnalyticsManager = require('../Analytics/AnalyticsManager') const SubscriptionEmailHandler = require('./SubscriptionEmailHandler') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const INVOICE_SUBSCRIPTION_LIMIT = 10 diff --git a/services/web/app/src/Features/Subscription/TeamInvitesHandler.js b/services/web/app/src/Features/Subscription/TeamInvitesHandler.js index da93ff2b7f..45a0495353 100644 --- a/services/web/app/src/Features/Subscription/TeamInvitesHandler.js +++ b/services/web/app/src/Features/Subscription/TeamInvitesHandler.js @@ -3,7 +3,7 @@ const crypto = require('crypto') const settings = require('@overleaf/settings') const Modules = require('../../infrastructure/Modules') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { Subscription } = require('../../models/Subscription') const { SSOConfig } = require('../../models/SSOConfig') diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js index 565ec41b8b..cd581ff4fc 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const _ = require('lodash') const { callbackify } = require('util') const logger = require('@overleaf/logger') diff --git a/services/web/app/src/Features/TokenAccess/TokenAccessHandler.js b/services/web/app/src/Features/TokenAccess/TokenAccessHandler.js index f5f5ef9728..f81168d3f8 100644 --- a/services/web/app/src/Features/TokenAccess/TokenAccessHandler.js +++ b/services/web/app/src/Features/TokenAccess/TokenAccessHandler.js @@ -1,7 +1,7 @@ const { Project } = require('../../models/Project') const PublicAccessLevels = require('../Authorization/PublicAccessLevels') const PrivilegeLevels = require('../Authorization/PrivilegeLevels') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Metrics = require('@overleaf/metrics') const Settings = require('@overleaf/settings') const logger = require('@overleaf/logger') diff --git a/services/web/app/src/Features/User/SAMLIdentityManager.js b/services/web/app/src/Features/User/SAMLIdentityManager.js index ab71950087..fbc7f50dab 100644 --- a/services/web/app/src/Features/User/SAMLIdentityManager.js +++ b/services/web/app/src/Features/User/SAMLIdentityManager.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const EmailHandler = require('../Email/EmailHandler') const Errors = require('../Errors/Errors') const InstitutionsAPI = require('../Institutions/InstitutionsAPI') diff --git a/services/web/app/src/Features/User/UserInfoController.js b/services/web/app/src/Features/User/UserInfoController.js index a821733a91..4eeea4f5e9 100644 --- a/services/web/app/src/Features/User/UserInfoController.js +++ b/services/web/app/src/Features/User/UserInfoController.js @@ -1,6 +1,6 @@ const UserGetter = require('./UserGetter') const SessionManager = require('../Authentication/SessionManager') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') function getLoggedInUsersPersonalInfo(req, res, next) { const userId = SessionManager.getLoggedInUserId(req.session) diff --git a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js index 9f2c0342ad..0632f6e50e 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { promisifyAll, callbackify } = require('@overleaf/promise-utils') const EntityModels = { Institution: require('../../models/Institution').Institution, diff --git a/services/web/app/src/infrastructure/Validation.js b/services/web/app/src/infrastructure/Validation.js index 7c68a9daa7..eafb82cda4 100644 --- a/services/web/app/src/infrastructure/Validation.js +++ b/services/web/app/src/infrastructure/Validation.js @@ -1,5 +1,5 @@ const { Joi: CelebrateJoi, celebrate, errors } = require('celebrate') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const objectIdValidator = { type: 'objectId', diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.js index b5997be2db..195844f914 100644 --- a/services/web/app/src/infrastructure/mongodb.js +++ b/services/web/app/src/infrastructure/mongodb.js @@ -1,4 +1,4 @@ -const mongodb = require('mongodb') +const mongodb = require('mongodb-legacy') const OError = require('@overleaf/o-error') const Settings = require('@overleaf/settings') const Mongoose = require('./Mongoose') diff --git a/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js b/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js index 603494b749..b14183843a 100644 --- a/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js +++ b/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js @@ -1,4 +1,4 @@ -const { ObjectId, ReadPreference } = require('mongodb') +const { ObjectId, ReadPreference } = require('mongodb-legacy') const BATCH_SIZE = parseInt(process.env.BATCH_SIZE || '1000', 10) const MIN_ID = process.env.MIN_ID diff --git a/services/web/modules/history-v1/test/acceptance/src/LabelsTests.js b/services/web/modules/history-v1/test/acceptance/src/LabelsTests.js index 7d01bf796a..ec62ff1e70 100644 --- a/services/web/modules/history-v1/test/acceptance/src/LabelsTests.js +++ b/services/web/modules/history-v1/test/acceptance/src/LabelsTests.js @@ -12,7 +12,7 @@ */ const _ = require('lodash') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const User = require('../../../../../test/acceptance/src/helpers/User') const MockProjectHistoryApiClass = require('../../../../../test/acceptance/src/mocks/MockProjectHistoryApi') diff --git a/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js b/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js index e1e1e5573b..5254c7becb 100644 --- a/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js +++ b/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Path = require('path') const fs = require('fs') const Settings = require('@overleaf/settings') diff --git a/services/web/modules/server-ce-scripts/scripts/check-mongodb.js b/services/web/modules/server-ce-scripts/scripts/check-mongodb.js index 5b8fda183d..3dd9f33b61 100644 --- a/services/web/modules/server-ce-scripts/scripts/check-mongodb.js +++ b/services/web/modules/server-ce-scripts/scripts/check-mongodb.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { waitForDb, db } = require('../../../app/src/infrastructure/mongodb') const { getMongoClient } = require('../../../app/src/infrastructure/Mongoose') diff --git a/services/web/package.json b/services/web/package.json index 1ead0a01a7..368dfece6c 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -137,7 +137,7 @@ "minimist": "^1.2.7", "mmmagic": "^0.5.3", "moment": "^2.29.4", - "mongodb": "5.9.2", + "mongodb-legacy": "5.0.0", "mongoose": "^7.8.0", "multer": "overleaf/multer#e1df247fbf8e7590520d20ae3601eaef9f3d2e9e", "nocache": "^2.1.0", diff --git a/services/web/scripts/analytics/sync_group_subscription_memberships.js b/services/web/scripts/analytics/sync_group_subscription_memberships.js index 691a3ec451..69ce0f1d25 100644 --- a/services/web/scripts/analytics/sync_group_subscription_memberships.js +++ b/services/web/scripts/analytics/sync_group_subscription_memberships.js @@ -7,7 +7,7 @@ const { } = require('../../app/src/models/DeletedSubscription') const minimist = require('minimist') const _ = require('lodash') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') let FETCH_LIMIT, COMMIT, VERBOSE diff --git a/services/web/scripts/back_fill_dummy_doc_meta.js b/services/web/scripts/back_fill_dummy_doc_meta.js index 9aad52107c..6ee9b2d737 100644 --- a/services/web/scripts/back_fill_dummy_doc_meta.js +++ b/services/web/scripts/back_fill_dummy_doc_meta.js @@ -1,5 +1,5 @@ const { promisify } = require('util') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb, diff --git a/services/web/scripts/delete_dangling_file_refs.js b/services/web/scripts/delete_dangling_file_refs.js index ffad97a8b5..bb9ce12776 100644 --- a/services/web/scripts/delete_dangling_file_refs.js +++ b/services/web/scripts/delete_dangling_file_refs.js @@ -3,7 +3,7 @@ */ const minimist = require('minimist') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb } = require('../app/src/infrastructure/mongodb') const Errors = require('../app/src/Features/Errors/Errors') diff --git a/services/web/scripts/delete_orphaned_chat_threads.js b/services/web/scripts/delete_orphaned_chat_threads.js index d68417faf0..82f9984849 100644 --- a/services/web/scripts/delete_orphaned_chat_threads.js +++ b/services/web/scripts/delete_orphaned_chat_threads.js @@ -13,7 +13,7 @@ process.env.BATCH_SIZE = BATCH_SIZE process.env.MONGO_SOCKET_TIMEOUT = parseInt(process.env.MONGO_SOCKET_TIMEOUT, 10) || 600000 -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { promiseMapWithLimit } = require('@overleaf/promise-utils') const { batchedUpdate } = require('./helpers/batchedUpdate') const ChatApiHandler = require('../app/src/Features/Chat/ChatApiHandler') diff --git a/services/web/scripts/delete_orphaned_docs_online_check.js b/services/web/scripts/delete_orphaned_docs_online_check.js index a94ff1cce5..d5cffe673c 100644 --- a/services/web/scripts/delete_orphaned_docs_online_check.js +++ b/services/web/scripts/delete_orphaned_docs_online_check.js @@ -1,6 +1,6 @@ const DocstoreManager = require('../app/src/Features/Docstore/DocstoreManager') const { promisify } = require('util') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb, diff --git a/services/web/scripts/delete_subscriptions.js b/services/web/scripts/delete_subscriptions.js index 93f5842130..3baa79e63d 100644 --- a/services/web/scripts/delete_subscriptions.js +++ b/services/web/scripts/delete_subscriptions.js @@ -3,7 +3,7 @@ const SubscriptionUpdater = require('../app/src/Features/Subscription/Subscripti const minimist = require('minimist') const { waitForDb } = require('../app/src/infrastructure/mongodb') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const run = async () => { for (const id of ids) { diff --git a/services/web/scripts/fix_malformed_filetree.js b/services/web/scripts/fix_malformed_filetree.js index c4c5d15966..c8d2a669ec 100644 --- a/services/web/scripts/fix_malformed_filetree.js +++ b/services/web/scripts/fix_malformed_filetree.js @@ -5,7 +5,7 @@ * This is the output format of each line in the find_malformed_filetrees.js * script. */ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb } = require('../app/src/infrastructure/mongodb') const ProjectLocator = require('../app/src/Features/Project/ProjectLocator') diff --git a/services/web/scripts/force_doc_flush.js b/services/web/scripts/force_doc_flush.js index ed39265758..fa5127acd5 100644 --- a/services/web/scripts/force_doc_flush.js +++ b/services/web/scripts/force_doc_flush.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb } = require('../app/src/infrastructure/mongodb') const DocumentUpdaterHandler = require('../app/src/Features/DocumentUpdater/DocumentUpdaterHandler') diff --git a/services/web/scripts/helpers/batchedUpdate.js b/services/web/scripts/helpers/batchedUpdate.js index 8d0cc40f80..0bfa2b3c5c 100644 --- a/services/web/scripts/helpers/batchedUpdate.js +++ b/services/web/scripts/helpers/batchedUpdate.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { db, waitForDb, diff --git a/services/web/scripts/oauth/register_client.js b/services/web/scripts/oauth/register_client.js index cf21a2ef68..87fa7c0116 100644 --- a/services/web/scripts/oauth/register_client.js +++ b/services/web/scripts/oauth/register_client.js @@ -1,5 +1,5 @@ const minimist = require('minimist') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { waitForDb, db } = require('../../app/src/infrastructure/mongodb') const { hashSecret, diff --git a/services/web/scripts/remove_deleted_users_from_token_access_refs.js b/services/web/scripts/remove_deleted_users_from_token_access_refs.js index 1acfd6c073..4b04912d46 100644 --- a/services/web/scripts/remove_deleted_users_from_token_access_refs.js +++ b/services/web/scripts/remove_deleted_users_from_token_access_refs.js @@ -1,6 +1,6 @@ const { db, waitForDb } = require('../app/src/infrastructure/mongodb') const { batchedUpdate } = require('./helpers/batchedUpdate') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const minimist = require('minimist') const CollaboratorsHandler = require('../app/src/Features/Collaborators/CollaboratorsHandler') const { diff --git a/services/web/scripts/set_tex_live_image.js b/services/web/scripts/set_tex_live_image.js index e51dbee6f4..9ec0f7893a 100644 --- a/services/web/scripts/set_tex_live_image.js +++ b/services/web/scripts/set_tex_live_image.js @@ -1,5 +1,5 @@ const Settings = require('@overleaf/settings') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { Project } = require('../app/src/models/Project') async function main() { diff --git a/services/web/test/acceptance/bootstrap.js b/services/web/test/acceptance/bootstrap.js index e65200eafe..03d956ef24 100644 --- a/services/web/test/acceptance/bootstrap.js +++ b/services/web/test/acceptance/bootstrap.js @@ -8,4 +8,4 @@ chai.use(require('chai-exclude')) chai.config.truncateThreshold = 0 // ensure every ObjectId has the id string as a property for correct comparisons -require('mongodb').ObjectId.cacheHexString = true +require('mongodb-legacy').ObjectId.cacheHexString = true diff --git a/services/web/test/acceptance/src/AuthenticationTests.js b/services/web/test/acceptance/src/AuthenticationTests.js index f1523f01cb..4015b44fa2 100644 --- a/services/web/test/acceptance/src/AuthenticationTests.js +++ b/services/web/test/acceptance/src/AuthenticationTests.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Settings = require('@overleaf/settings') const User = require('./helpers/User').promises diff --git a/services/web/test/acceptance/src/ConvertArchivedState.js b/services/web/test/acceptance/src/ConvertArchivedState.js index 79b662c6a8..23c61913d0 100644 --- a/services/web/test/acceptance/src/ConvertArchivedState.js +++ b/services/web/test/acceptance/src/ConvertArchivedState.js @@ -1,6 +1,6 @@ const { expect } = require('chai') const { exec } = require('child_process') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const User = require('./helpers/User').promises diff --git a/services/web/test/acceptance/src/DocUpdateTests.js b/services/web/test/acceptance/src/DocUpdateTests.js index a3841209b6..62a6e48088 100644 --- a/services/web/test/acceptance/src/DocUpdateTests.js +++ b/services/web/test/acceptance/src/DocUpdateTests.js @@ -2,7 +2,7 @@ const User = require('./helpers/User') const request = require('./helpers/request') const { expect } = require('chai') const settings = require('@overleaf/settings') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('DocUpdate', function () { beforeEach(function (done) { diff --git a/services/web/test/acceptance/src/MongoHelper.js b/services/web/test/acceptance/src/MongoHelper.js index f9ce1665dd..8085e3b8f3 100644 --- a/services/web/test/acceptance/src/MongoHelper.js +++ b/services/web/test/acceptance/src/MongoHelper.js @@ -1,6 +1,6 @@ const { expect } = require('chai') -const { ObjectId: NativeObjectId } = require('mongodb') +const { ObjectId: NativeObjectId } = require('mongodb-legacy') const { ObjectId: MongooseObjectId } = require('mongoose').mongo const { User: UserModel } = require('../../../app/src/models/User') diff --git a/services/web/test/acceptance/src/ProjectCRUDTests.js b/services/web/test/acceptance/src/ProjectCRUDTests.js index d250ef2f98..caa8b12b01 100644 --- a/services/web/test/acceptance/src/ProjectCRUDTests.js +++ b/services/web/test/acceptance/src/ProjectCRUDTests.js @@ -1,7 +1,7 @@ const { expect } = require('chai') const User = require('./helpers/User').promises const { Project } = require('../../../app/src/models/Project') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const cheerio = require('cheerio') const { Subscription } = require('../../../app/src/models/Subscription') const Features = require('../../../app/src/infrastructure/Features') diff --git a/services/web/test/acceptance/src/ProjectStructureTests.js b/services/web/test/acceptance/src/ProjectStructureTests.js index b0c682e32c..e30fae0b48 100644 --- a/services/web/test/acceptance/src/ProjectStructureTests.js +++ b/services/web/test/acceptance/src/ProjectStructureTests.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Path = require('path') const fs = require('fs') diff --git a/services/web/test/acceptance/src/helpers/Institution.js b/services/web/test/acceptance/src/helpers/Institution.js index 18ae896f0b..3f15193769 100644 --- a/services/web/test/acceptance/src/helpers/Institution.js +++ b/services/web/test/acceptance/src/helpers/Institution.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const InstitutionModel = require('../../../../app/src/models/Institution').Institution diff --git a/services/web/test/acceptance/src/helpers/Publisher.js b/services/web/test/acceptance/src/helpers/Publisher.js index 12e94662d7..43a29ff29e 100644 --- a/services/web/test/acceptance/src/helpers/Publisher.js +++ b/services/web/test/acceptance/src/helpers/Publisher.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const PublisherModel = require('../../../../app/src/models/Publisher').Publisher const { callbackifyClass } = require('@overleaf/promise-utils') diff --git a/services/web/test/acceptance/src/helpers/RecurlySubscription.js b/services/web/test/acceptance/src/helpers/RecurlySubscription.js index 99aa208273..c7878ffc0f 100644 --- a/services/web/test/acceptance/src/helpers/RecurlySubscription.js +++ b/services/web/test/acceptance/src/helpers/RecurlySubscription.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Subscription = require('./Subscription') const MockRecurlyApiClass = require('../mocks/MockRecurlyApi') const RecurlyWrapper = require('../../../../app/src/Features/Subscription/RecurlyWrapper') diff --git a/services/web/test/acceptance/src/helpers/UserHelper.js b/services/web/test/acceptance/src/helpers/UserHelper.js index 661b27758e..a561e02f47 100644 --- a/services/web/test/acceptance/src/helpers/UserHelper.js +++ b/services/web/test/acceptance/src/helpers/UserHelper.js @@ -8,7 +8,7 @@ const UserUpdater = require('../../../../app/src/Features/User/UserUpdater') const moment = require('moment') const fetch = require('node-fetch') const { db } = require('../../../../app/src/infrastructure/mongodb') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { UserAuditLogEntry, } = require('../../../../app/src/models/UserAuditLogEntry') diff --git a/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.js b/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.js index 8c0ba5c444..900ecb56d5 100644 --- a/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.js +++ b/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.js @@ -1,6 +1,6 @@ const AbstractMockApi = require('./AbstractMockApi') const _ = require('lodash') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { plainTextResponse, } = require('../../../../app/src/infrastructure/Response') diff --git a/services/web/test/unit/bootstrap.js b/services/web/test/unit/bootstrap.js index e0488c6b06..1e636166a7 100644 --- a/services/web/test/unit/bootstrap.js +++ b/services/web/test/unit/bootstrap.js @@ -23,7 +23,7 @@ chai.config.truncateThreshold = 0 require('sinon-mongoose') // ensure every ObjectId has the id string as a property for correct comparisons -require('mongodb').ObjectId.cacheHexString = true +require('mongodb-legacy').ObjectId.cacheHexString = true /* * Global stubs diff --git a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js index c21486dad2..5b027b292b 100644 --- a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js +++ b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js @@ -4,7 +4,7 @@ const sinon = require('sinon') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') const { assert } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = path.join( __dirname, diff --git a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js index 31d3b7dfea..681bfa763b 100644 --- a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js +++ b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js @@ -6,7 +6,7 @@ const SandboxedModule = require('sandboxed-module') const tk = require('timekeeper') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const AuthenticationErrors = require('../../../../app/src/Features/Authentication/AuthenticationErrors') describe('AuthenticationController', function () { diff --git a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js index 72fc14b98b..b2a3a6a22e 100644 --- a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js +++ b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const AuthenticationErrors = require('../../../../app/src/Features/Authentication/AuthenticationErrors') const tk = require('timekeeper') diff --git a/services/web/test/unit/src/Authentication/SessionManagerTests.js b/services/web/test/unit/src/Authentication/SessionManagerTests.js index 08ede266f1..a64b2c44f4 100644 --- a/services/web/test/unit/src/Authentication/SessionManagerTests.js +++ b/services/web/test/unit/src/Authentication/SessionManagerTests.js @@ -4,7 +4,7 @@ const modulePath = '../../../../app/src/Features/Authentication/SessionManager.js' const SandboxedModule = require('sandboxed-module') const tk = require('timekeeper') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('SessionManager', function () { beforeEach(function () { diff --git a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js index 5731f495f6..baa48001ea 100644 --- a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js +++ b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js @@ -6,7 +6,7 @@ const SandboxedModule = require('sandboxed-module') const Errors = require('../../../../app/src/Features/Errors/Errors') const PrivilegeLevels = require('../../../../app/src/Features/Authorization/PrivilegeLevels') const PublicAccessLevels = require('../../../../app/src/Features/Authorization/PublicAccessLevels') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('AuthorizationManager', function () { beforeEach(function () { @@ -48,7 +48,7 @@ describe('AuthorizationManager', function () { this.AuthorizationManager = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter, '../Collaborators/CollaboratorsHandler': this.CollaboratorsHandler, '../Project/ProjectGetter': this.ProjectGetter, diff --git a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js index 16d0bd1059..6ae930048c 100644 --- a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js +++ b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const MODULE_PATH = @@ -39,6 +39,7 @@ describe('AuthorizationMiddleware', function () { requires: { './AuthorizationManager': this.AuthorizationManager, '../Errors/HttpErrorHandler': this.HttpErrorHandler, + 'mongodb-legacy': { ObjectId }, '../Authentication/AuthenticationController': this.AuthenticationController, '../Authentication/SessionManager': this.SessionManager, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js index 25c9d38400..c5c423f20f 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') @@ -79,7 +79,7 @@ describe('CollaboratorsController', function () { this.CollaboratorsController = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, './CollaboratorsHandler': this.CollaboratorsHandler, './CollaboratorsGetter': this.CollaboratorsGetter, './OwnershipTransferHandler': this.OwnershipTransferHandler, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js index ab00c03ce9..47f78c7666 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js @@ -2,7 +2,7 @@ const Path = require('path') const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { Project } = require('../helpers/models/Project') const Errors = require('../../../../app/src/Features/Errors/Errors') @@ -53,7 +53,7 @@ describe('CollaboratorsGetter', function () { } this.CollaboratorsGetter = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '../User/UserGetter': this.UserGetter, '../../models/Project': { Project }, '../Project/ProjectGetter': this.ProjectGetter, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js index 0992a3ef3e..96ed8e52e2 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js @@ -5,7 +5,7 @@ const sinon = require('sinon') const { expect } = require('chai') const Errors = require('../../../../app/src/Features/Errors/Errors') const { Project } = require('../helpers/models/Project') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = path.join( __dirname, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js index c862c25fb6..87ec84929c 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js @@ -3,7 +3,7 @@ const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const _ = require('lodash') diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js index 7f6f554f22..5c3ac49503 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Crypto = require('crypto') const MODULE_PATH = diff --git a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js index 112aa564ca..e61805565a 100644 --- a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js @@ -3,7 +3,7 @@ const sinon = require('sinon') const { expect } = require('chai') const PrivilegeLevels = require('../../../../app/src/Features/Authorization/PrivilegeLevels') const Errors = require('../../../../app/src/Features/Errors/Errors') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Collaborators/OwnershipTransferHandler' diff --git a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js index 6b1d516547..bdfe6ab9db 100644 --- a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js +++ b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const SandboxedModule = require('sandboxed-module') const path = require('path') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = path.join( __dirname, '../../../../app/src/Features/DocumentUpdater/DocumentUpdaterHandler' diff --git a/services/web/test/unit/src/Editor/EditorControllerTests.js b/services/web/test/unit/src/Editor/EditorControllerTests.js index 4b453386bc..360ab077e1 100644 --- a/services/web/test/unit/src/Editor/EditorControllerTests.js +++ b/services/web/test/unit/src/Editor/EditorControllerTests.js @@ -21,7 +21,7 @@ const modulePath = require('path').join( ) const MockClient = require('../helpers/MockClient') const assert = require('assert') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('EditorController', function () { beforeEach(function () { diff --git a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js index b80c7dd6a8..f07a0bd48b 100644 --- a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js +++ b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') diff --git a/services/web/test/unit/src/History/HistoryManagerTests.js b/services/web/test/unit/src/History/HistoryManagerTests.js index 5b04e51063..e424b14e1d 100644 --- a/services/web/test/unit/src/History/HistoryManagerTests.js +++ b/services/web/test/unit/src/History/HistoryManagerTests.js @@ -1,7 +1,7 @@ const { expect } = require('chai') const sinon = require('sinon') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/History/HistoryManager' diff --git a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js index 470e9eb2ed..32d402a7eb 100644 --- a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js +++ b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js @@ -5,7 +5,7 @@ const modulePath = path.join( __dirname, '../../../../app/src/Features/InactiveData/InactiveProjectManager' ) -const { ObjectId, ReadPreference } = require('mongodb') +const { ObjectId, ReadPreference } = require('mongodb-legacy') const { expect } = require('chai') describe('InactiveProjectManager', function () { @@ -26,7 +26,7 @@ describe('InactiveProjectManager', function () { this.ProjectGetter = { promises: { getProject: sinon.stub() } } this.InactiveProjectManager = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.settings, '../Docstore/DocstoreManager': this.DocstoreManager, '../Project/ProjectUpdateHandler': this.ProjectUpdateHandler, diff --git a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js index db11b84e28..4811962eba 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = path.join( __dirname, '../../../../app/src/Features/Institutions/InstitutionsManager' @@ -136,7 +136,7 @@ describe('InstitutionsManager', function () { '../Subscription/SubscriptionLocator': this.SubscriptionLocator, '../../models/Institution': this.InstitutionModel, '../../models/Subscription': SubscriptionModel, - mongodb: this.Mongo, + 'mongodb-legacy': this.Mongo, '@overleaf/settings': { features: { professional: { 'test-feature': true } }, }, diff --git a/services/web/test/unit/src/Project/FolderStructureBuilderTests.js b/services/web/test/unit/src/Project/FolderStructureBuilderTests.js index fc09bfb056..0763ec74dc 100644 --- a/services/web/test/unit/src/Project/FolderStructureBuilderTests.js +++ b/services/web/test/unit/src/Project/FolderStructureBuilderTests.js @@ -1,6 +1,6 @@ const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const sinon = require('sinon') const MODULE_PATH = @@ -8,7 +8,9 @@ const MODULE_PATH = describe('FolderStructureBuilder', function () { beforeEach(function () { - this.FolderStructureBuilder = SandboxedModule.require(MODULE_PATH, {}) + this.FolderStructureBuilder = SandboxedModule.require(MODULE_PATH, { + requires: { 'mongodb-legacy': { ObjectId } }, + }) }) describe('buildFolderStructure', function () { diff --git a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js index e4f827bc3b..d2de69ec91 100644 --- a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js +++ b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Path = require('path') const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') @@ -19,7 +19,7 @@ describe('ProjectCollabratecDetailsHandler', function () { modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '../../models/Project': { Project: this.ProjectModel }, }, } diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index adfa4c1165..c210da3b42 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = path.join( __dirname, @@ -203,7 +203,7 @@ describe('ProjectController', function () { this.ProjectController = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.settings, '@overleaf/metrics': this.Metrics, '../SplitTests/SplitTestHandler': this.SplitTestHandler, diff --git a/services/web/test/unit/src/Project/ProjectDeleterTests.js b/services/web/test/unit/src/Project/ProjectDeleterTests.js index e0d07d93b9..e5dc2ea2d6 100644 --- a/services/web/test/unit/src/Project/ProjectDeleterTests.js +++ b/services/web/test/unit/src/Project/ProjectDeleterTests.js @@ -6,7 +6,7 @@ const tk = require('timekeeper') const moment = require('moment') const { Project } = require('../helpers/models/Project') const { DeletedProject } = require('../helpers/models/DeletedProject') -const { ObjectId, ReadPreference } = require('mongodb') +const { ObjectId, ReadPreference } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') describe('ProjectDeleter', function () { diff --git a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js index 7a429e75f8..51cdddd9eb 100644 --- a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js @@ -1,7 +1,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const ProjectHelper = require('../../../../app/src/Features/Project/ProjectHelper') diff --git a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js index 446d95047f..44c3914062 100644 --- a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js +++ b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js @@ -1,7 +1,7 @@ const { expect } = require('chai') const sinon = require('sinon') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Project/ProjectDuplicator.js' diff --git a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js index 1464ed3463..53b459ff05 100644 --- a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const sinon = require('sinon') const tk = require('timekeeper') const Errors = require('../../../../app/src/Features/Errors/Errors') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const SandboxedModule = require('sandboxed-module') const { DeletedFile } = require('../helpers/models/DeletedFile') const { Project } = require('../helpers/models/Project') @@ -191,7 +191,7 @@ describe('ProjectEntityMongoUpdateHandler', function () { this.subject = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.Settings, '../Cooldown/CooldownManager': this.CooldownManager, '../../models/Folder': { Folder: this.FolderModel }, diff --git a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js index d00ca2a1e4..400ade10a4 100644 --- a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const sinon = require('sinon') const Errors = require('../../../../app/src/Features/Errors/Errors') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Project/ProjectEntityUpdateHandler' diff --git a/services/web/test/unit/src/Project/ProjectGetterTests.js b/services/web/test/unit/src/Project/ProjectGetterTests.js index c2e3512ed9..1aecd4ab11 100644 --- a/services/web/test/unit/src/Project/ProjectGetterTests.js +++ b/services/web/test/unit/src/Project/ProjectGetterTests.js @@ -2,7 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Project/ProjectGetter.js' const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('ProjectGetter', function () { beforeEach(function () { diff --git a/services/web/test/unit/src/Project/ProjectHelperTests.js b/services/web/test/unit/src/Project/ProjectHelperTests.js index e08c7865e7..7dc2343313 100644 --- a/services/web/test/unit/src/Project/ProjectHelperTests.js +++ b/services/web/test/unit/src/Project/ProjectHelperTests.js @@ -1,6 +1,6 @@ const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Project/ProjectHelper.js' @@ -37,7 +37,7 @@ describe('ProjectHelper', function () { this.ProjectHelper = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.Settings, }, }) diff --git a/services/web/test/unit/src/Project/ProjectListControllerTests.js b/services/web/test/unit/src/Project/ProjectListControllerTests.js index 51aef2552e..0813200877 100644 --- a/services/web/test/unit/src/Project/ProjectListControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectListControllerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const MODULE_PATH = path.join( @@ -141,7 +141,7 @@ describe('ProjectListController', function () { this.ProjectListController = SandboxedModule.require(MODULE_PATH, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.settings, '@overleaf/metrics': this.Metrics, '../SplitTests/SplitTestHandler': this.SplitTestHandler, diff --git a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js index 75edc62c10..12d4c70a20 100644 --- a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js @@ -17,7 +17,7 @@ const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Project/ProjectOptionsHandler.js' const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('ProjectOptionsHandler', function () { const projectId = '4eecaffcbffa66588e000008' diff --git a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js index ab35f7c5bc..1e37ee1380 100644 --- a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js +++ b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js @@ -12,7 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Project/ProjectRootDocManager.js' diff --git a/services/web/test/unit/src/SplitTests/SplitTestHandlerTests.js b/services/web/test/unit/src/SplitTests/SplitTestHandlerTests.js index 7a46ffabfd..5fed9b0271 100644 --- a/services/web/test/unit/src/SplitTests/SplitTestHandlerTests.js +++ b/services/web/test/unit/src/SplitTests/SplitTestHandlerTests.js @@ -1,7 +1,7 @@ const Path = require('path') const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { assert, expect } = require('chai') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') diff --git a/services/web/test/unit/src/SplitTests/SplitTestSessionHandlerTests.js b/services/web/test/unit/src/SplitTests/SplitTestSessionHandlerTests.js index ac1159a78d..026cddefae 100644 --- a/services/web/test/unit/src/SplitTests/SplitTestSessionHandlerTests.js +++ b/services/web/test/unit/src/SplitTests/SplitTestSessionHandlerTests.js @@ -2,6 +2,7 @@ const Path = require('path') const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = Path.join( __dirname, @@ -59,6 +60,7 @@ describe('SplitTestSessionHandler', function () { './SplitTestCache': this.SplitTestCache, './SplitTestUserGetter': this.SplitTestUserGetter, '@overleaf/metrics': this.Metrics, + 'mongodb-legacy': { ObjectId }, }, }) }) diff --git a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js index 3c97b30bf9..2f891f9cca 100644 --- a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js @@ -1,7 +1,7 @@ const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Subscription/FeaturesUpdater' diff --git a/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js b/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js index c88ae46745..55d7cab65d 100644 --- a/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js +++ b/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js @@ -1,4 +1,5 @@ const SandboxedModule = require('sandboxed-module') +const { ObjectId } = require('mongodb-legacy') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/RecurlyEventHandler' @@ -27,6 +28,7 @@ describe('RecurlyEventHandler', function () { this.RecurlyEventHandler = SandboxedModule.require(modulePath, { requires: { + 'mongodb-legacy': { ObjectId }, './SubscriptionEmailHandler': (this.SubscriptionEmailHandler = { sendTrialOnboardingEmail: sinon.stub(), }), diff --git a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js index 834d0a5d21..d478ad8afe 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js @@ -3,7 +3,7 @@ const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionUpdater' const { assert, expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('SubscriptionUpdater', function () { beforeEach(function () { diff --git a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js index cbd2a6fe0a..f726bdb9cb 100644 --- a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js +++ b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js @@ -4,7 +4,7 @@ const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Subscription/TeamInvitesHandler' -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') describe('TeamInvitesHandler', function () { @@ -111,7 +111,7 @@ describe('TeamInvitesHandler', function () { this.TeamInvitesHandler = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, crypto: this.crypto, '@overleaf/settings': { siteUrl: 'http://example.com' }, '../../models/TeamInvite': { TeamInvite: (this.TeamInvite = {}) }, diff --git a/services/web/test/unit/src/Tags/TagsHandlerTests.js b/services/web/test/unit/src/Tags/TagsHandlerTests.js index aa9e4bb363..f30a649681 100644 --- a/services/web/test/unit/src/Tags/TagsHandlerTests.js +++ b/services/web/test/unit/src/Tags/TagsHandlerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') const sinon = require('sinon') const { Tag } = require('../helpers/models/Tag') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Tags/TagsHandler.js' diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js index 848f24f0ff..65db57e32e 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js index dd9e24d080..50f8b18ec9 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js @@ -1,7 +1,7 @@ const { expect } = require('chai') const sinon = require('sinon') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { Project } = require('../helpers/models/Project') const MODULE_PATH = diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js index a305e9095c..bf2d376158 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js @@ -1,7 +1,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../../app/src/Features/Errors/Errors') const MODULE_PATH = diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js index 70c48d8255..d394399157 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') @@ -72,7 +72,7 @@ describe('TpdsUpdateSender', function () { } this.TpdsUpdateSender = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '@overleaf/settings': this.settings, '@overleaf/fetch-utils': this.FetchUtils, '../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter, diff --git a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js index 3591775dad..1426d48110 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') const { Writable } = require('stream') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/ThirdPartyDataStore/UpdateMerger.js' diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js index 4dcc439b4d..9749cd14a1 100644 --- a/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js +++ b/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js @@ -1,7 +1,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') const PrivilegeLevels = require('../../../../app/src/Features/Authorization/PrivilegeLevels') diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js index b6c0128043..1fffb4c3fb 100644 --- a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js +++ b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js @@ -6,7 +6,7 @@ const modulePath = path.join( '../../../../app/src/Features/TokenAccess/TokenAccessHandler' ) const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('TokenAccessHandler', function () { beforeEach(function () { @@ -21,7 +21,7 @@ describe('TokenAccessHandler', function () { this.req = {} this.TokenAccessHandler = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '../../models/Project': { Project: (this.Project = {}) }, '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }), '@overleaf/settings': (this.settings = {}), diff --git a/services/web/test/unit/src/Tutorial/TutorialHandlerTests.js b/services/web/test/unit/src/Tutorial/TutorialHandlerTests.js index ad22fb413d..88a0d0cc2c 100644 --- a/services/web/test/unit/src/Tutorial/TutorialHandlerTests.js +++ b/services/web/test/unit/src/Tutorial/TutorialHandlerTests.js @@ -1,7 +1,7 @@ const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Tutorial/TutorialHandler' diff --git a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js index d42388bf04..ba219f3c68 100644 --- a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js +++ b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js @@ -2,7 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const mockFs = require('mock-fs') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Settings = require('@overleaf/settings') const MODULE_PATH = diff --git a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js index a2f9e522a5..493f242c9c 100644 --- a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js +++ b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js @@ -2,7 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const timekeeper = require('timekeeper') const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const MODULE_PATH = '../../../../app/src/Features/Uploads/ProjectUploadManager.js' diff --git a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js index 8b00392901..5668da363c 100644 --- a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js +++ b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') @@ -43,6 +43,7 @@ describe('SAMLIdentityManager', function () { } this.SAMLIdentityManager = SandboxedModule.require(modulePath, { requires: { + 'mongodb-legacy': { ObjectId }, '../Email/EmailHandler': (this.EmailHandler = { sendEmail: sinon.stub().yields(), }), diff --git a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js index 9c92e148ce..3bad884520 100644 --- a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js +++ b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js @@ -1,6 +1,6 @@ const sinon = require('sinon') const { expect } = require('chai') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const SandboxedModule = require('sandboxed-module') const { UserAuditLogEntry } = require('../helpers/models/UserAuditLogEntry') diff --git a/services/web/test/unit/src/User/UserGetterTests.js b/services/web/test/unit/src/User/UserGetterTests.js index 36304b38a3..1f6a7bb2e7 100644 --- a/services/web/test/unit/src/User/UserGetterTests.js +++ b/services/web/test/unit/src/User/UserGetterTests.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const SandboxedModule = require('sandboxed-module') const assert = require('assert') const moment = require('moment') diff --git a/services/web/test/unit/src/User/UserInfoControllerTests.js b/services/web/test/unit/src/User/UserInfoControllerTests.js index 89e1f65242..022dbd2d7f 100644 --- a/services/web/test/unit/src/User/UserInfoControllerTests.js +++ b/services/web/test/unit/src/User/UserInfoControllerTests.js @@ -4,7 +4,7 @@ const modulePath = '../../../../app/src/Features/User/UserInfoController.js' const SandboxedModule = require('sandboxed-module') const MockResponse = require('../helpers/MockResponse') const MockRequest = require('../helpers/MockRequest') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('UserInfoController', function () { beforeEach(function () { @@ -14,7 +14,7 @@ describe('UserInfoController', function () { this.UserInfoController = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, './UserGetter': this.UserGetter, './UserUpdater': this.UserUpdater, './UserDeleter': this.UserDeleter, diff --git a/services/web/test/unit/src/User/UserUpdaterTests.js b/services/web/test/unit/src/User/UserUpdaterTests.js index 79eacdee27..f609530e33 100644 --- a/services/web/test/unit/src/User/UserUpdaterTests.js +++ b/services/web/test/unit/src/User/UserUpdaterTests.js @@ -2,7 +2,7 @@ const { setTimeout } = require('timers/promises') const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const tk = require('timekeeper') const { expect } = require('chai') const { normalizeQuery } = require('../../../../app/src/Features/Helpers/Mongo') diff --git a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js index b29fb76fd7..f7b665aecd 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js @@ -1,7 +1,7 @@ const { expect } = require('chai') const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = '../../../../app/src/Features/UserMembership/UserMembershipHandler' const SandboxedModule = require('sandboxed-module') @@ -77,7 +77,7 @@ describe('UserMembershipHandler', function () { } this.UserMembershipHandler = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, './UserMembershipErrors': { UserIsManagerError, UserNotFoundError, diff --git a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js index bf1500ec44..a8ce9d158f 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js @@ -14,7 +14,7 @@ const { expect } = require('chai') const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith const assertNotCalled = sinon.assert.notCalled -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = '../../../../app/src/Features/UserMembership/UserMembershipViewModel' const SandboxedModule = require('sandboxed-module') @@ -28,7 +28,7 @@ describe('UserMembershipViewModel', function () { this.UserGetter = { getUser: sinon.stub() } this.UserMembershipViewModel = SandboxedModule.require(modulePath, { requires: { - mongodb: { ObjectId }, + 'mongodb-legacy': { ObjectId }, '../Helpers/Mongo': { isObjectIdInstance, normalizeQuery }, '../User/UserGetter': this.UserGetter, }, diff --git a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js index f0c11c7044..f0e8f42c67 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js @@ -12,7 +12,7 @@ */ const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const modulePath = '../../../../app/src/Features/UserMembership/UserMembershipsHandler' const SandboxedModule = require('sandboxed-module') diff --git a/services/web/test/unit/src/infrastructure/MongodbTests.js b/services/web/test/unit/src/infrastructure/MongodbTests.js index 9c87c6ce8a..65cab5f7b6 100644 --- a/services/web/test/unit/src/infrastructure/MongodbTests.js +++ b/services/web/test/unit/src/infrastructure/MongodbTests.js @@ -1,4 +1,4 @@ -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { expect } = require('chai') const sinon = require('sinon') diff --git a/services/web/test/unit/src/infrastructure/ValidationTests.js b/services/web/test/unit/src/infrastructure/ValidationTests.js index 1b7d8955f6..e01dff8df8 100644 --- a/services/web/test/unit/src/infrastructure/ValidationTests.js +++ b/services/web/test/unit/src/infrastructure/ValidationTests.js @@ -1,5 +1,5 @@ const { Joi } = require('../../../../app/src/infrastructure/Validation') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { expect } = require('chai') const { ValidationError } = require('joi')