mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 05:13:43 -05:00
Merge pull request #16186 from overleaf/mj-mongo-object-id
[web] Use constructor for ObjectId GitOrigin-RevId: 9eb8b377ea599605b72af237d1ab12f4d8287162
This commit is contained in:
parent
0ac514f81b
commit
c371732e6e
100 changed files with 423 additions and 368 deletions
|
@ -102,6 +102,26 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Backend + backend tests specific rules
|
||||||
|
"files": ["**/app/src/**/*.js", "app.js", "**/test/**/*.*", "**/scripts/*.*"],
|
||||||
|
"rules": {
|
||||||
|
// do not allow node-fetch in backend code
|
||||||
|
"no-restricted-syntax": [
|
||||||
|
"error",
|
||||||
|
// Require `new` when constructing ObjectId (For mongo + mongoose upgrade)
|
||||||
|
{
|
||||||
|
"selector": "CallExpression[callee.name='ObjectId'], CallExpression[callee.property.name='ObjectId']",
|
||||||
|
"message": "Construct ObjectId with `new ObjectId()` instead of `ObjectId()`"
|
||||||
|
},
|
||||||
|
// Require `new` when mapping a list of ids to a list of ObjectId (For mongo + mongoose upgrade)
|
||||||
|
{
|
||||||
|
"selector": "CallExpression[callee.property.name='map'] Identifier[name='ObjectId']:first-child, CallExpression[callee.property.name='map'] MemberExpression[property.name='ObjectId']:first-child",
|
||||||
|
"message": "Don't map ObjectId directly. Use `id => new ObjectId(id)` instead"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Cypress specific rules
|
// Cypress specific rules
|
||||||
"files": ["cypress/**/*.{js,jsx,ts,tsx}", "**/test/frontend/**/*.spec.{js,jsx,ts,tsx}"],
|
"files": ["cypress/**/*.{js,jsx,ts,tsx}", "**/test/frontend/**/*.spec.{js,jsx,ts,tsx}"],
|
||||||
|
|
|
@ -369,7 +369,7 @@ const AuthenticationManager = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
db.users.updateOne(
|
db.users.updateOne(
|
||||||
{ _id: ObjectId(user._id.toString()) },
|
{ _id: new ObjectId(user._id.toString()) },
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
hashedPassword: hash,
|
hashedPassword: hash,
|
||||||
|
|
|
@ -105,7 +105,7 @@ async function transferOwnership(req, res, next) {
|
||||||
toUserId,
|
toUserId,
|
||||||
{
|
{
|
||||||
allowTransferToNonCollaborators: hasAdminAccess(sessionUser),
|
allowTransferToNonCollaborators: hasAdminAccess(sessionUser),
|
||||||
sessionUserId: ObjectId(sessionUser._id),
|
sessionUserId: new ObjectId(sessionUser._id),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
|
@ -143,8 +143,8 @@ async function getShareTokens(req, res) {
|
||||||
let tokens
|
let tokens
|
||||||
if (userId) {
|
if (userId) {
|
||||||
tokens = await CollaboratorsGetter.promises.getPublicShareTokens(
|
tokens = await CollaboratorsGetter.promises.getPublicShareTokens(
|
||||||
ObjectId(userId),
|
new ObjectId(userId),
|
||||||
ObjectId(projectId)
|
new ObjectId(projectId)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// anonymous access, the token is already available in the session
|
// anonymous access, the token is already available in the session
|
||||||
|
|
|
@ -209,8 +209,8 @@ async function getAllInvitedMembers(projectId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function userIsTokenMember(userId, projectId) {
|
async function userIsTokenMember(userId, projectId) {
|
||||||
userId = ObjectId(userId.toString())
|
userId = new ObjectId(userId.toString())
|
||||||
projectId = ObjectId(projectId.toString())
|
projectId = new ObjectId(projectId.toString())
|
||||||
const project = await Project.findOne(
|
const project = await Project.findOne(
|
||||||
{
|
{
|
||||||
_id: projectId,
|
_id: projectId,
|
||||||
|
|
|
@ -4,11 +4,11 @@ const { ObjectId: MongooseObjectId } = require('mongoose').mongo
|
||||||
|
|
||||||
function _getObjectIdInstance(id) {
|
function _getObjectIdInstance(id) {
|
||||||
if (typeof id === 'string') {
|
if (typeof id === 'string') {
|
||||||
return ObjectId(id)
|
return new ObjectId(id)
|
||||||
} else if (id instanceof ObjectId) {
|
} else if (id instanceof ObjectId) {
|
||||||
return id
|
return id
|
||||||
} else if (id instanceof MongooseObjectId) {
|
} else if (id instanceof MongooseObjectId) {
|
||||||
return ObjectId(id.toString())
|
return new ObjectId(id.toString())
|
||||||
} else {
|
} else {
|
||||||
throw new OError('unexpected object id', { id })
|
throw new OError('unexpected object id', { id })
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ function normalizeQuery(query) {
|
||||||
) {
|
) {
|
||||||
return { _id: _getObjectIdInstance(query) }
|
return { _id: _getObjectIdInstance(query) }
|
||||||
} else if (typeof query._id === 'string') {
|
} else if (typeof query._id === 'string') {
|
||||||
query._id = ObjectId(query._id)
|
query._id = new ObjectId(query._id)
|
||||||
return query
|
return query
|
||||||
} else {
|
} else {
|
||||||
return query
|
return query
|
||||||
|
|
|
@ -244,8 +244,8 @@ const InstitutionsManager = {
|
||||||
if (error) {
|
if (error) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
const userIds = affiliations.map(affiliation =>
|
const userIds = affiliations.map(
|
||||||
ObjectId(affiliation.user_id)
|
affiliation => new ObjectId(affiliation.user_id)
|
||||||
)
|
)
|
||||||
Subscription.find({ admin_id: userIds })
|
Subscription.find({ admin_id: userIds })
|
||||||
.populate('admin_id', 'email')
|
.populate('admin_id', 'email')
|
||||||
|
@ -294,12 +294,12 @@ const fetchInstitutionAndAffiliations = (institutionId, callback) =>
|
||||||
)
|
)
|
||||||
|
|
||||||
function refreshFeatures(affiliation, callback) {
|
function refreshFeatures(affiliation, callback) {
|
||||||
const userId = ObjectId(affiliation.user_id)
|
const userId = new ObjectId(affiliation.user_id)
|
||||||
FeaturesUpdater.refreshFeatures(userId, 'refresh-institution-users', callback)
|
FeaturesUpdater.refreshFeatures(userId, 'refresh-institution-users', callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshFeaturesAndNotify(affiliation, callback) {
|
function refreshFeaturesAndNotify(affiliation, callback) {
|
||||||
const userId = ObjectId(affiliation.user_id)
|
const userId = new ObjectId(affiliation.user_id)
|
||||||
async.waterfall(
|
async.waterfall(
|
||||||
[
|
[
|
||||||
cb =>
|
cb =>
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FolderStructureBuilder {
|
||||||
|
|
||||||
createFolder(name) {
|
createFolder(name) {
|
||||||
return {
|
return {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name,
|
name,
|
||||||
folders: [],
|
folders: [],
|
||||||
docs: [],
|
docs: [],
|
||||||
|
|
|
@ -43,8 +43,8 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
projectId = ObjectId(projectId)
|
projectId = new ObjectId(projectId)
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error
|
const err = error
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -75,8 +75,8 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
projectId = ObjectId(projectId)
|
projectId = new ObjectId(projectId)
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error
|
const err = error
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -109,7 +109,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
projectId = ObjectId(projectId)
|
projectId = new ObjectId(projectId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
err = error
|
err = error
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -119,7 +119,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
}
|
}
|
||||||
for (const collabratecUser of Array.from(collabratecUsers)) {
|
for (const collabratecUser of Array.from(collabratecUsers)) {
|
||||||
try {
|
try {
|
||||||
collabratecUser.user_id = ObjectId(collabratecUser.user_id)
|
collabratecUser.user_id = new ObjectId(collabratecUser.user_id)
|
||||||
} catch (error1) {
|
} catch (error1) {
|
||||||
err = error1
|
err = error1
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -134,8 +134,8 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
projectId = ObjectId(projectId)
|
projectId = new ObjectId(projectId)
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error
|
const err = error
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -156,8 +156,8 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
oldUserId = ObjectId(oldUserId)
|
oldUserId = new ObjectId(oldUserId)
|
||||||
newUserId = ObjectId(newUserId)
|
newUserId = new ObjectId(newUserId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error
|
const err = error
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
|
|
@ -435,7 +435,7 @@ const ProjectController = {
|
||||||
cb(null, defaultSettingsForAnonymousUser(userId))
|
cb(null, defaultSettingsForAnonymousUser(userId))
|
||||||
} else {
|
} else {
|
||||||
User.updateOne(
|
User.updateOne(
|
||||||
{ _id: ObjectId(userId) },
|
{ _id: new ObjectId(userId) },
|
||||||
{ $set: { lastActive: new Date() } },
|
{ $set: { lastActive: new Date() } },
|
||||||
{},
|
{},
|
||||||
() => {}
|
() => {}
|
||||||
|
@ -753,7 +753,7 @@ const ProjectController = {
|
||||||
} else if (
|
} else if (
|
||||||
Settings.wsUrlV2 &&
|
Settings.wsUrlV2 &&
|
||||||
Settings.wsUrlV2Percentage > 0 &&
|
Settings.wsUrlV2Percentage > 0 &&
|
||||||
(ObjectId(projectId).getTimestamp() / 1000) % 100 <
|
(new ObjectId(projectId).getTimestamp() / 1000) % 100 <
|
||||||
Settings.wsUrlV2Percentage
|
Settings.wsUrlV2Percentage
|
||||||
) {
|
) {
|
||||||
wsUrl = Settings.wsUrlV2
|
wsUrl = Settings.wsUrlV2
|
||||||
|
|
|
@ -128,7 +128,7 @@ async function archiveProject(projectId, userId) {
|
||||||
|
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: projectId },
|
{ _id: projectId },
|
||||||
{ $set: { archived }, $pull: { trashed: ObjectId(userId) } }
|
{ $set: { archived }, $pull: { trashed: new ObjectId(userId) } }
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn({ err }, 'problem archiving project')
|
logger.warn({ err }, 'problem archiving project')
|
||||||
|
@ -172,7 +172,7 @@ async function trashProject(projectId, userId) {
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: projectId },
|
{ _id: projectId },
|
||||||
{
|
{
|
||||||
$addToSet: { trashed: ObjectId(userId) },
|
$addToSet: { trashed: new ObjectId(userId) },
|
||||||
$set: { archived },
|
$set: { archived },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -191,7 +191,7 @@ async function untrashProject(projectId, userId) {
|
||||||
|
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: projectId },
|
{ _id: projectId },
|
||||||
{ $pull: { trashed: ObjectId(userId) } }
|
{ $pull: { trashed: new ObjectId(userId) } }
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn({ err }, 'problem untrashing project')
|
logger.warn({ err }, 'problem untrashing project')
|
||||||
|
@ -280,7 +280,7 @@ async function deleteProject(projectId, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function undeleteProject(projectId, options = {}) {
|
async function undeleteProject(projectId, options = {}) {
|
||||||
projectId = ObjectId(projectId)
|
projectId = new ObjectId(projectId)
|
||||||
const deletedProject = await DeletedProject.findOne({
|
const deletedProject = await DeletedProject.findOne({
|
||||||
'deleterData.deletedProjectId': projectId,
|
'deleterData.deletedProjectId': projectId,
|
||||||
}).exec()
|
}).exec()
|
||||||
|
|
|
@ -148,8 +148,8 @@ const ProjectEntityHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ObjectID | string} projectId
|
* @param {ObjectId | string} projectId
|
||||||
* @param {ObjectID | string} docId
|
* @param {ObjectId | string} docId
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
getDocPathByProjectIdAndDocId(projectId, docId, callback) {
|
getDocPathByProjectIdAndDocId(projectId, docId, callback) {
|
||||||
|
@ -176,7 +176,7 @@ const ProjectEntityHandler = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Project} project
|
* @param {Project} project
|
||||||
* @param {ObjectID | string} docId
|
* @param {ObjectId | string} docId
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
getDocPathFromProjectByDocId(project, docId, callback) {
|
getDocPathFromProjectByDocId(project, docId, callback) {
|
||||||
|
|
|
@ -568,7 +568,7 @@ async function _putElement(project, folderId, element, type) {
|
||||||
throw new Errors.InvalidNameError('blocked element name')
|
throw new Errors.InvalidNameError('blocked element name')
|
||||||
}
|
}
|
||||||
_checkValidElementName(folder, element.name)
|
_checkValidElementName(folder, element.name)
|
||||||
element._id = ObjectId(element._id.toString())
|
element._id = new ObjectId(element._id.toString())
|
||||||
const mongoPath = `${path.mongo}.${pathSegment}`
|
const mongoPath = `${path.mongo}.${pathSegment}`
|
||||||
const newProject = await Project.findOneAndUpdate(
|
const newProject = await Project.findOneAndUpdate(
|
||||||
{ _id: project._id, [path.mongo]: { $exists: true } },
|
{ _id: project._id, [path.mongo]: { $exists: true } },
|
||||||
|
|
|
@ -37,7 +37,7 @@ function compilerFromV1Engine(engine) {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function isArchived(project, userId) {
|
function isArchived(project, userId) {
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
|
|
||||||
return (project.archived || []).some(id => id.equals(userId))
|
return (project.archived || []).some(id => id.equals(userId))
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ function isArchived(project, userId) {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function isTrashed(project, userId) {
|
function isTrashed(project, userId) {
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
|
|
||||||
return (project.trashed || []).some(id => id.equals(userId))
|
return (project.trashed || []).some(id => id.equals(userId))
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ function _allCollaborators(project) {
|
||||||
|
|
||||||
function calculateArchivedArray(project, userId, action) {
|
function calculateArchivedArray(project, userId, action) {
|
||||||
let archived = project.archived
|
let archived = project.archived
|
||||||
userId = ObjectId(userId)
|
userId = new ObjectId(userId)
|
||||||
|
|
||||||
if (archived === true) {
|
if (archived === true) {
|
||||||
archived = _allCollaborators(project)
|
archived = _allCollaborators(project)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
||||||
const SubscriptionEmailHandler = require('./SubscriptionEmailHandler')
|
const SubscriptionEmailHandler = require('./SubscriptionEmailHandler')
|
||||||
const { ObjectID } = require('mongodb')
|
const { ObjectId } = require('mongodb')
|
||||||
|
|
||||||
const INVOICE_SUBSCRIPTION_LIMIT = 10
|
const INVOICE_SUBSCRIPTION_LIMIT = 10
|
||||||
|
|
||||||
async function sendRecurlyAnalyticsEvent(event, eventData) {
|
async function sendRecurlyAnalyticsEvent(event, eventData) {
|
||||||
const userId = _getUserId(eventData)
|
const userId = _getUserId(eventData)
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectId.isValid(userId)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,16 @@ const UserAuditLogHandler = require('../User/UserAuditLogHandler')
|
||||||
*/
|
*/
|
||||||
async function updateAdmin(subscription, adminId) {
|
async function updateAdmin(subscription, adminId) {
|
||||||
const query = {
|
const query = {
|
||||||
_id: ObjectId(subscription._id),
|
_id: new ObjectId(subscription._id),
|
||||||
customAccount: true,
|
customAccount: true,
|
||||||
}
|
}
|
||||||
const update = {
|
const update = {
|
||||||
$set: { admin_id: ObjectId(adminId) },
|
$set: { admin_id: new ObjectId(adminId) },
|
||||||
}
|
}
|
||||||
if (subscription.groupPlan) {
|
if (subscription.groupPlan) {
|
||||||
update.$addToSet = { manager_ids: ObjectId(adminId) }
|
update.$addToSet = { manager_ids: new ObjectId(adminId) }
|
||||||
} else {
|
} else {
|
||||||
update.$set.manager_ids = [ObjectId(adminId)]
|
update.$set.manager_ids = [new ObjectId(adminId)]
|
||||||
}
|
}
|
||||||
await Subscription.updateOne(query, update).exec()
|
await Subscription.updateOne(query, update).exec()
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ async function getProjectUsersIds(projectId) {
|
||||||
// filter invited users to only return those with dropbox linked
|
// filter invited users to only return those with dropbox linked
|
||||||
const dropboxUsers = await UserGetter.getUsers(
|
const dropboxUsers = await UserGetter.getUsers(
|
||||||
{
|
{
|
||||||
_id: { $in: userIds.map(id => ObjectId(id)) },
|
_id: { $in: userIds.map(id => new ObjectId(id)) },
|
||||||
'dropbox.access_token.uid': { $ne: null },
|
'dropbox.access_token.uid': { $ne: null },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,8 +168,8 @@ const TokenAccessHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
addReadOnlyUserToProject(userId, projectId, callback) {
|
addReadOnlyUserToProject(userId, projectId, callback) {
|
||||||
userId = ObjectId(userId.toString())
|
userId = new ObjectId(userId.toString())
|
||||||
projectId = ObjectId(projectId.toString())
|
projectId = new ObjectId(projectId.toString())
|
||||||
Analytics.recordEventForUser(userId, 'project-joined', {
|
Analytics.recordEventForUser(userId, 'project-joined', {
|
||||||
mode: 'read-only',
|
mode: 'read-only',
|
||||||
})
|
})
|
||||||
|
@ -185,8 +185,8 @@ const TokenAccessHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
addReadAndWriteUserToProject(userId, projectId, callback) {
|
addReadAndWriteUserToProject(userId, projectId, callback) {
|
||||||
userId = ObjectId(userId.toString())
|
userId = new ObjectId(userId.toString())
|
||||||
projectId = ObjectId(projectId.toString())
|
projectId = new ObjectId(projectId.toString())
|
||||||
Analytics.recordEventForUser(userId, 'project-joined', {
|
Analytics.recordEventForUser(userId, 'project-joined', {
|
||||||
mode: 'read-write',
|
mode: 'read-write',
|
||||||
})
|
})
|
||||||
|
|
|
@ -24,7 +24,7 @@ async function _addAuditLogEntry(operation, userId, auditLog, extraInfo) {
|
||||||
|
|
||||||
async function _ensureCanAddIdentifier(userId, institutionEmail, providerId) {
|
async function _ensureCanAddIdentifier(userId, institutionEmail, providerId) {
|
||||||
const userWithProvider = await UserGetter.promises.getUser(
|
const userWithProvider = await UserGetter.promises.getUser(
|
||||||
{ _id: ObjectId(userId), 'samlIdentifiers.providerId': providerId },
|
{ _id: new ObjectId(userId), 'samlIdentifiers.providerId': providerId },
|
||||||
{ _id: 1 }
|
{ _id: 1 }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ function getPersonalInfo(req, res, next) {
|
||||||
if (/^\d+$/.test(userId)) {
|
if (/^\d+$/.test(userId)) {
|
||||||
query = { 'overleaf.id': parseInt(userId, 10) }
|
query = { 'overleaf.id': parseInt(userId, 10) }
|
||||||
} else if (/^[a-f0-9]{24}$/.test(userId)) {
|
} else if (/^[a-f0-9]{24}$/.test(userId)) {
|
||||||
query = { _id: ObjectId(userId) }
|
query = { _id: new ObjectId(userId) }
|
||||||
} else {
|
} else {
|
||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ function removeUserFromEntity(entity, attribute, userId, callback) {
|
||||||
|
|
||||||
function buildEntityQuery(entityId, entityConfig, loggedInUser) {
|
function buildEntityQuery(entityId, entityConfig, loggedInUser) {
|
||||||
if (ObjectId.isValid(entityId.toString())) {
|
if (ObjectId.isValid(entityId.toString())) {
|
||||||
entityId = ObjectId(entityId)
|
entityId = new ObjectId(entityId)
|
||||||
}
|
}
|
||||||
const query = Object.assign({}, entityConfig.baseQuery)
|
const query = Object.assign({}, entityConfig.baseQuery)
|
||||||
query[entityConfig.fields.primaryKey] = entityId
|
query[entityConfig.fields.primaryKey] = entityId
|
||||||
|
|
|
@ -3,7 +3,7 @@ const _ = require('underscore')
|
||||||
const { FolderSchema } = require('./Folder')
|
const { FolderSchema } = require('./Folder')
|
||||||
const Errors = require('../Features/Errors/Errors')
|
const Errors = require('../Features/Errors/Errors')
|
||||||
|
|
||||||
const concreteObjectId = mongoose.Types.ObjectId
|
const ConcreteObjectId = mongoose.Types.ObjectId
|
||||||
const { Schema } = mongoose
|
const { Schema } = mongoose
|
||||||
const { ObjectId } = Schema
|
const { ObjectId } = Schema
|
||||||
|
|
||||||
|
@ -119,7 +119,8 @@ ProjectSchema.statics.getProject = function (projectOrId, fields, callback) {
|
||||||
callback(null, projectOrId)
|
callback(null, projectOrId)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
concreteObjectId(projectOrId.toString())
|
// eslint-disable-next-line no-new
|
||||||
|
new ConcreteObjectId(projectOrId.toString())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return callback(new Errors.NotFoundError(e.message))
|
return callback(new Errors.NotFoundError(e.message))
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('History', function () {
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
return db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -90,7 +90,7 @@ describe('History', function () {
|
||||||
}
|
}
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{ _id: ObjectId(this.project_id) },
|
{ _id: new ObjectId(this.project_id) },
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
'overleaf.history.id': this.v1_history_id,
|
'overleaf.history.id': this.v1_history_id,
|
||||||
|
@ -202,7 +202,7 @@ describe('History', function () {
|
||||||
}
|
}
|
||||||
return db.projects.updateOne(
|
return db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$unset: {
|
$unset: {
|
||||||
|
@ -260,7 +260,7 @@ describe('History', function () {
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
return db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -324,7 +324,7 @@ describe('History', function () {
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
return db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.users.updateOne(
|
await db.users.updateOne(
|
||||||
{ _id: ObjectId(userId) },
|
{ _id: new ObjectId(userId) },
|
||||||
{ $set: { 'features.compileTimeout': compileTimeout } }
|
{ $set: { 'features.compileTimeout': compileTimeout } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ async function testTransactions() {
|
||||||
const session = mongoClient.startSession()
|
const session = mongoClient.startSession()
|
||||||
try {
|
try {
|
||||||
await session.withTransaction(async () => {
|
await session.withTransaction(async () => {
|
||||||
await db.users.findOne({ _id: ObjectId() }, { session })
|
await db.users.findOne({ _id: new ObjectId() }, { session })
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
await session.endSession()
|
await session.endSession()
|
||||||
|
|
|
@ -168,7 +168,7 @@ async function processUsers(userIds) {
|
||||||
|
|
||||||
const limit = pLimit(CONCURRENCY)
|
const limit = pLimit(CONCURRENCY)
|
||||||
const results = await Promise.allSettled(
|
const results = await Promise.allSettled(
|
||||||
userIds.map(userId => limit(() => _handleUser(ObjectId(userId))))
|
userIds.map(userId => limit(() => _handleUser(new ObjectId(userId))))
|
||||||
)
|
)
|
||||||
results.forEach((result, idx) => {
|
results.forEach((result, idx) => {
|
||||||
if (result.status !== 'fulfilled') {
|
if (result.status !== 'fulfilled') {
|
||||||
|
|
|
@ -29,7 +29,7 @@ async function main(options) {
|
||||||
_.defaults(options, {
|
_.defaults(options, {
|
||||||
dryRun: process.env.DRY_RUN === 'true',
|
dryRun: process.env.DRY_RUN === 'true',
|
||||||
cacheSize: parseInt(process.env.CACHE_SIZE, 10) || 100,
|
cacheSize: parseInt(process.env.CACHE_SIZE, 10) || 100,
|
||||||
firstProjectId: ObjectId(process.env.FIRST_PROJECT_ID),
|
firstProjectId: new ObjectId(process.env.FIRST_PROJECT_ID),
|
||||||
incrementByS: parseInt(process.env.INCREMENT_BY_S, 10) || ONE_WEEK_IN_S,
|
incrementByS: parseInt(process.env.INCREMENT_BY_S, 10) || ONE_WEEK_IN_S,
|
||||||
batchSize: parseInt(process.env.BATCH_SIZE, 10) || 1000,
|
batchSize: parseInt(process.env.BATCH_SIZE, 10) || 1000,
|
||||||
stopAtS: parseInt(process.env.STOP_AT_S, 10) || NOW_IN_S,
|
stopAtS: parseInt(process.env.STOP_AT_S, 10) || NOW_IN_S,
|
||||||
|
|
|
@ -100,7 +100,7 @@ async function countDocsSizes(docs) {
|
||||||
for (const docId of ids) {
|
for (const docId of ids) {
|
||||||
const result = await db.docs.aggregate([
|
const result = await db.docs.aggregate([
|
||||||
{
|
{
|
||||||
$match: { _id: ObjectId(docId) },
|
$match: { _id: new ObjectId(docId) },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
|
|
|
@ -48,8 +48,8 @@ rl.on('line', async line => {
|
||||||
projectId = projectId.replace(/^ObjectId\(/, '').replace(/\)$/, '')
|
projectId = projectId.replace(/^ObjectId\(/, '').replace(/\)$/, '')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docId = ObjectId(docId).toString()
|
docId = new ObjectId(docId).toString()
|
||||||
projectId = ObjectId(projectId).toString()
|
projectId = new ObjectId(projectId).toString()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Invalid id: ${docId}, ${projectId}`)
|
console.error(`Invalid id: ${docId}, ${projectId}`)
|
||||||
return
|
return
|
||||||
|
@ -114,14 +114,14 @@ async function projectIdExists(projectId) {
|
||||||
|
|
||||||
async function findProject(projectId) {
|
async function findProject(projectId) {
|
||||||
return db.projects.findOne(
|
return db.projects.findOne(
|
||||||
{ _id: ObjectId(projectId) },
|
{ _id: new ObjectId(projectId) },
|
||||||
{ projection: { _id: 1 } }
|
{ projection: { _id: 1 } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findDeletedProject(projectId) {
|
async function findDeletedProject(projectId) {
|
||||||
return db.deletedProjects.findOne(
|
return db.deletedProjects.findOne(
|
||||||
{ 'project._id': ObjectId(projectId) },
|
{ 'project._id': new ObjectId(projectId) },
|
||||||
{ projection: { _id: 1 } }
|
{ projection: { _id: 1 } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProjects() {
|
async function getProjects() {
|
||||||
const projectIds = OPTIONS.projectIds.map(id => ObjectId(id))
|
const projectIds = OPTIONS.projectIds.map(id => new ObjectId(id))
|
||||||
const projects = await db.projects
|
const projects = await db.projects
|
||||||
.find(
|
.find(
|
||||||
{ _id: { $in: projectIds } },
|
{ _id: { $in: projectIds } },
|
||||||
|
|
|
@ -38,7 +38,7 @@ async function processBatch(rooms) {
|
||||||
}
|
}
|
||||||
const projectIds = Array.from(
|
const projectIds = Array.from(
|
||||||
new Set(rooms.map(room => room.project_id.toString()))
|
new Set(rooms.map(room => room.project_id.toString()))
|
||||||
).map(ObjectId)
|
).map(id => new ObjectId(id))
|
||||||
console.log(
|
console.log(
|
||||||
`Checking projects (${projectIds.length})`,
|
`Checking projects (${projectIds.length})`,
|
||||||
JSON.stringify(projectIds)
|
JSON.stringify(projectIds)
|
||||||
|
|
|
@ -20,7 +20,7 @@ if (!process.env.BATCH_LAST_ID) {
|
||||||
console.error('Set BATCH_LAST_ID and re-run.')
|
console.error('Set BATCH_LAST_ID and re-run.')
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
const BATCH_LAST_ID = ObjectId(process.env.BATCH_LAST_ID)
|
const BATCH_LAST_ID = new ObjectId(process.env.BATCH_LAST_ID)
|
||||||
const INCREMENT_BY_S = parseInt(process.env.INCREMENT_BY_S, 10) || ONE_WEEK_IN_S
|
const INCREMENT_BY_S = parseInt(process.env.INCREMENT_BY_S, 10) || ONE_WEEK_IN_S
|
||||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 1000
|
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 1000
|
||||||
const READ_CONCURRENCY_SECONDARY =
|
const READ_CONCURRENCY_SECONDARY =
|
||||||
|
@ -66,7 +66,7 @@ async function main() {
|
||||||
if (docs.length) {
|
if (docs.length) {
|
||||||
const projectIds = Array.from(
|
const projectIds = Array.from(
|
||||||
new Set(docs.map(doc => doc.project_id.toString()))
|
new Set(docs.map(doc => doc.project_id.toString()))
|
||||||
).map(ObjectId)
|
).map(id => new ObjectId(id))
|
||||||
console.log('Checking projects', JSON.stringify(projectIds))
|
console.log('Checking projects', JSON.stringify(projectIds))
|
||||||
const { nProjectsWithOrphanedDocs, nDeletedDocs } = await processBatch(
|
const { nProjectsWithOrphanedDocs, nDeletedDocs } = await processBatch(
|
||||||
projectIds
|
projectIds
|
||||||
|
|
|
@ -59,8 +59,8 @@ async function processBatch(entries) {
|
||||||
prefixes.push(prefix)
|
prefixes.push(prefix)
|
||||||
projectIdToPrefix.set(projectId, prefixes)
|
projectIdToPrefix.set(projectId, prefixes)
|
||||||
}
|
}
|
||||||
const projectIds = Array.from(projectIdToPrefix.keys()).map(id =>
|
const projectIds = Array.from(projectIdToPrefix.keys()).map(
|
||||||
ObjectId(id)
|
id => new ObjectId(id)
|
||||||
)
|
)
|
||||||
const projectsWithOrphanedArchive = await getHardDeletedProjectIds({
|
const projectsWithOrphanedArchive = await getHardDeletedProjectIds({
|
||||||
projectIds,
|
projectIds,
|
||||||
|
|
|
@ -8,7 +8,7 @@ const { ObjectId } = require('mongodb')
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
console.log('id', id)
|
console.log('id', id)
|
||||||
const subscription = await Subscription.findOne({ _id: ObjectId(id) })
|
const subscription = await Subscription.findOne({ _id: new ObjectId(id) })
|
||||||
await SubscriptionUpdater.promises.deleteSubscription(
|
await SubscriptionUpdater.promises.deleteSubscription(
|
||||||
subscription,
|
subscription,
|
||||||
deleterData
|
deleterData
|
||||||
|
@ -33,7 +33,7 @@ const setup = () => {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleterData = { id: ObjectId(deleterId) }
|
deleterData = { id: new ObjectId(deleterId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
|
|
|
@ -45,7 +45,7 @@ function parseArgs() {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
const [projectId, mongoPath] = args
|
const [projectId, mongoPath] = args
|
||||||
return { projectId: ObjectId(projectId), mongoPath }
|
return { projectId: new ObjectId(projectId), mongoPath }
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRootFolder(path) {
|
function isRootFolder(path) {
|
||||||
|
@ -86,7 +86,7 @@ async function fixRootFolder(projectId) {
|
||||||
$set: {
|
$set: {
|
||||||
rootFolder: [
|
rootFolder: [
|
||||||
{
|
{
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'rootFolder',
|
name: 'rootFolder',
|
||||||
folders: [],
|
folders: [],
|
||||||
docs: [],
|
docs: [],
|
||||||
|
@ -127,7 +127,7 @@ async function fixArray(projectId, path) {
|
||||||
async function fixFolderId(projectId, path) {
|
async function fixFolderId(projectId, path) {
|
||||||
const result = await db.projects.updateOne(
|
const result = await db.projects.updateOne(
|
||||||
{ _id: projectId, [path]: { $exists: false } },
|
{ _id: projectId, [path]: { $exists: false } },
|
||||||
{ $set: { [path]: ObjectId() } }
|
{ $set: { [path]: new ObjectId() } }
|
||||||
)
|
)
|
||||||
return result.modifiedCount
|
return result.modifiedCount
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ async function processDoc(projectId, docId) {
|
||||||
if (opts.commit) {
|
if (opts.commit) {
|
||||||
const fileRef = await sendDocToFilestore(projectId, doc)
|
const fileRef = await sendDocToFilestore(projectId, doc)
|
||||||
await ProjectEntityMongoUpdateHandler.promises.replaceDocWithFile(
|
await ProjectEntityMongoUpdateHandler.promises.replaceDocWithFile(
|
||||||
ObjectId(projectId),
|
new ObjectId(projectId),
|
||||||
ObjectId(docId),
|
new ObjectId(docId),
|
||||||
fileRef
|
fileRef
|
||||||
)
|
)
|
||||||
await deleteDocFromMongo(projectId, doc)
|
await deleteDocFromMongo(projectId, doc)
|
||||||
|
|
|
@ -28,7 +28,7 @@ async function main() {
|
||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
console.log(`updating doc ${DOC_ID} in mongo for project ${PROJECT_ID}`)
|
console.log(`updating doc ${DOC_ID} in mongo for project ${PROJECT_ID}`)
|
||||||
const result = await db.docs.updateOne(
|
const result = await db.docs.updateOne(
|
||||||
{ _id: ObjectId(DOC_ID), project_id: ObjectId(PROJECT_ID) },
|
{ _id: new ObjectId(DOC_ID), project_id: new ObjectId(PROJECT_ID) },
|
||||||
{
|
{
|
||||||
$set: { lines, version, ranges },
|
$set: { lines, version, ranges },
|
||||||
$inc: { rev: 1 }, // maintain same behaviour as Docstore upsertIntoDocCollection
|
$inc: { rev: 1 }, // maintain same behaviour as Docstore upsertIntoDocCollection
|
||||||
|
|
|
@ -22,9 +22,9 @@ function refreshGlobalOptionsForBatchedUpdate(options = {}) {
|
||||||
BATCH_SIZE = parseInt(options.BATCH_SIZE, 10) || 1000
|
BATCH_SIZE = parseInt(options.BATCH_SIZE, 10) || 1000
|
||||||
VERBOSE_LOGGING = options.VERBOSE_LOGGING === 'true'
|
VERBOSE_LOGGING = options.VERBOSE_LOGGING === 'true'
|
||||||
if (options.BATCH_LAST_ID) {
|
if (options.BATCH_LAST_ID) {
|
||||||
BATCH_RANGE_START = ObjectId(options.BATCH_LAST_ID)
|
BATCH_RANGE_START = new ObjectId(options.BATCH_LAST_ID)
|
||||||
} else if (options.BATCH_RANGE_START) {
|
} else if (options.BATCH_RANGE_START) {
|
||||||
BATCH_RANGE_START = ObjectId(options.BATCH_RANGE_START)
|
BATCH_RANGE_START = new ObjectId(options.BATCH_RANGE_START)
|
||||||
} else {
|
} else {
|
||||||
if (BATCH_DESCENDING) {
|
if (BATCH_DESCENDING) {
|
||||||
BATCH_RANGE_START = ID_EDGE_FUTURE
|
BATCH_RANGE_START = ID_EDGE_FUTURE
|
||||||
|
@ -35,7 +35,7 @@ function refreshGlobalOptionsForBatchedUpdate(options = {}) {
|
||||||
BATCH_MAX_TIME_SPAN_IN_MS =
|
BATCH_MAX_TIME_SPAN_IN_MS =
|
||||||
parseInt(options.BATCH_MAX_TIME_SPAN_IN_MS, 10) || ONE_MONTH_IN_MS
|
parseInt(options.BATCH_MAX_TIME_SPAN_IN_MS, 10) || ONE_MONTH_IN_MS
|
||||||
if (options.BATCH_RANGE_END) {
|
if (options.BATCH_RANGE_END) {
|
||||||
BATCH_RANGE_END = ObjectId(options.BATCH_RANGE_END)
|
BATCH_RANGE_END = new ObjectId(options.BATCH_RANGE_END)
|
||||||
} else {
|
} else {
|
||||||
if (BATCH_DESCENDING) {
|
if (BATCH_DESCENDING) {
|
||||||
BATCH_RANGE_END = ID_EDGE_PAST
|
BATCH_RANGE_END = ID_EDGE_PAST
|
||||||
|
|
|
@ -3,7 +3,7 @@ const minimist = require('minimist')
|
||||||
const argv = minimist(process.argv.slice(2))
|
const argv = minimist(process.argv.slice(2))
|
||||||
const commit = argv.commit !== undefined
|
const commit = argv.commit !== undefined
|
||||||
const projectIds = argv._.map(x => {
|
const projectIds = argv._.map(x => {
|
||||||
return ObjectId(x)
|
return new ObjectId(x)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!commit) {
|
if (!commit) {
|
||||||
|
|
|
@ -44,8 +44,8 @@ async function main() {
|
||||||
|
|
||||||
await waitForDb()
|
await waitForDb()
|
||||||
|
|
||||||
const targetSubscription = await getSubscription(ObjectId(target))
|
const targetSubscription = await getSubscription(new ObjectId(target))
|
||||||
const sourceSubscription = await getSubscription(ObjectId(source))
|
const sourceSubscription = await getSubscription(new ObjectId(source))
|
||||||
|
|
||||||
if (!targetSubscription) {
|
if (!targetSubscription) {
|
||||||
throw new Error('couldnt find target (to) subscription')
|
throw new Error('couldnt find target (to) subscription')
|
||||||
|
|
|
@ -25,7 +25,7 @@ async function main(options) {
|
||||||
if (options.projectId) {
|
if (options.projectId) {
|
||||||
console.log('migrating projectId=' + options.projectId)
|
console.log('migrating projectId=' + options.projectId)
|
||||||
const project = await db.projects.findOne(
|
const project = await db.projects.findOne(
|
||||||
{ _id: ObjectId(options.projectId) },
|
{ _id: new ObjectId(options.projectId) },
|
||||||
{ _id: 1, auditLog: 1 }
|
{ _id: 1, auditLog: 1 }
|
||||||
)
|
)
|
||||||
if (!project || !project.auditLog) {
|
if (!project || !project.auditLog) {
|
||||||
|
@ -36,7 +36,7 @@ async function main(options) {
|
||||||
} else if (options.userId) {
|
} else if (options.userId) {
|
||||||
console.log('migrating userId=' + options.userId)
|
console.log('migrating userId=' + options.userId)
|
||||||
const user = await db.users.findOne(
|
const user = await db.users.findOne(
|
||||||
{ _id: ObjectId(options.userId) },
|
{ _id: new ObjectId(options.userId) },
|
||||||
{ _id: 1, auditLog: 1 }
|
{ _id: 1, auditLog: 1 }
|
||||||
)
|
)
|
||||||
if (!user || !user.auditLog) {
|
if (!user || !user.auditLog) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ async function upsertApplication(opts) {
|
||||||
defaults.redirectUris = []
|
defaults.redirectUris = []
|
||||||
}
|
}
|
||||||
if (opts.mongoId != null) {
|
if (opts.mongoId != null) {
|
||||||
defaults._id = ObjectId(opts.mongoId)
|
defaults._id = new ObjectId(opts.mongoId)
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.oauthApplications.updateOne(
|
await db.oauthApplications.updateOne(
|
||||||
|
|
|
@ -53,7 +53,7 @@ async function main() {
|
||||||
|
|
||||||
async function processDoc(docId) {
|
async function processDoc(docId) {
|
||||||
// check if the doc is in mongo.. if so ignore it
|
// check if the doc is in mongo.. if so ignore it
|
||||||
const docCount = await db.docs.find({ _id: ObjectId(docId) }).count()
|
const docCount = await db.docs.find({ _id: new ObjectId(docId) }).count()
|
||||||
if (docCount > 0) {
|
if (docCount > 0) {
|
||||||
logger.debug({ docId }, 'doc is present in mongo - no recovery needed')
|
logger.debug({ docId }, 'doc is present in mongo - no recovery needed')
|
||||||
return
|
return
|
||||||
|
@ -70,7 +70,7 @@ async function processDoc(docId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// check that the project is in mongo, if not delete the doc
|
// check that the project is in mongo, if not delete the doc
|
||||||
const project = await db.projects.findOne({ _id: ObjectId(projectId) })
|
const project = await db.projects.findOne({ _id: new ObjectId(projectId) })
|
||||||
if (!project) {
|
if (!project) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
{ docId },
|
{ docId },
|
||||||
|
|
|
@ -39,7 +39,7 @@ function parseProjectIds(projectIds) {
|
||||||
for (const projectId of projectIds) {
|
for (const projectId of projectIds) {
|
||||||
let oid
|
let oid
|
||||||
try {
|
try {
|
||||||
oid = ObjectId(projectId)
|
oid = new ObjectId(projectId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Invalid project id: ${projectId}`)
|
console.error(`Invalid project id: ${projectId}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
@ -51,7 +51,7 @@ function parseProjectIds(projectIds) {
|
||||||
|
|
||||||
async function updateImage(image, projectIds) {
|
async function updateImage(image, projectIds) {
|
||||||
const res = await Project.updateMany(
|
const res = await Project.updateMany(
|
||||||
{ _id: { $in: projectIds.map(ObjectId) } },
|
{ _id: { $in: projectIds.map(id => new ObjectId(id)) } },
|
||||||
{ $set: { imageName: `quay.io/sharelatex/${image}` } }
|
{ $set: { imageName: `quay.io/sharelatex/${image}` } }
|
||||||
).exec()
|
).exec()
|
||||||
console.log(`Found ${res.matchedCount} out of ${projectIds.length} projects`)
|
console.log(`Found ${res.matchedCount} out of ${projectIds.length} projects`)
|
||||||
|
|
|
@ -363,7 +363,7 @@ async function uploadFile(projectId) {
|
||||||
async function upload(abortSignal, deleteFile = true) {
|
async function upload(abortSignal, deleteFile = true) {
|
||||||
const size = userSize.get()
|
const size = userSize.get()
|
||||||
const buffer = Buffer.alloc(size, crypto.randomUUID())
|
const buffer = Buffer.alloc(size, crypto.randomUUID())
|
||||||
const fileId = ObjectId()
|
const fileId = new ObjectId()
|
||||||
const url = `${settings.apis.filestore.url}/project/${projectId}/file/${fileId}`
|
const url = `${settings.apis.filestore.url}/project/${projectId}/file/${fileId}`
|
||||||
const md5 = computeMD5Hash(buffer)
|
const md5 = computeMD5Hash(buffer)
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
|
|
@ -63,8 +63,8 @@ describe('Authentication', function () {
|
||||||
const auditLogEntry = auditLog[0]
|
const auditLogEntry = auditLog[0]
|
||||||
expect(auditLogEntry).to.exist
|
expect(auditLogEntry).to.exist
|
||||||
expect(auditLogEntry.timestamp).to.exist
|
expect(auditLogEntry.timestamp).to.exist
|
||||||
expect(auditLogEntry.initiatorId).to.deep.equal(ObjectId(user.id))
|
expect(auditLogEntry.initiatorId).to.deep.equal(new ObjectId(user.id))
|
||||||
expect(auditLogEntry.userId).to.deep.equal(ObjectId(user.id))
|
expect(auditLogEntry.userId).to.deep.equal(new ObjectId(user.id))
|
||||||
expect(auditLogEntry.operation).to.equal('login')
|
expect(auditLogEntry.operation).to.equal('login')
|
||||||
expect(auditLogEntry.info).to.deep.equal({
|
expect(auditLogEntry.info).to.deep.equal({
|
||||||
method: 'Password login',
|
method: 'Password login',
|
||||||
|
@ -96,8 +96,8 @@ describe('Authentication', function () {
|
||||||
const auditLogEntry = auditLog.pop()
|
const auditLogEntry = auditLog.pop()
|
||||||
expect(auditLogEntry).to.exist
|
expect(auditLogEntry).to.exist
|
||||||
expect(auditLogEntry.timestamp).to.exist
|
expect(auditLogEntry.timestamp).to.exist
|
||||||
expect(auditLogEntry.initiatorId).to.deep.equal(ObjectId(user.id))
|
expect(auditLogEntry.initiatorId).to.deep.equal(new ObjectId(user.id))
|
||||||
expect(auditLogEntry.userId).to.deep.equal(ObjectId(user.id))
|
expect(auditLogEntry.userId).to.deep.equal(new ObjectId(user.id))
|
||||||
expect(auditLogEntry.operation).to.equal('failed-password-match')
|
expect(auditLogEntry.operation).to.equal('failed-password-match')
|
||||||
expect(auditLogEntry.info).to.deep.equal({
|
expect(auditLogEntry.info).to.deep.equal({
|
||||||
method: 'Password login',
|
method: 'Password login',
|
||||||
|
|
|
@ -27,20 +27,20 @@ describe('BackFillDeletedFiles', function () {
|
||||||
user = new User()
|
user = new User()
|
||||||
await user.login()
|
await user.login()
|
||||||
|
|
||||||
projectId1 = ObjectId(await user.createProject('project1'))
|
projectId1 = new ObjectId(await user.createProject('project1'))
|
||||||
projectId2 = ObjectId(await user.createProject('project2'))
|
projectId2 = new ObjectId(await user.createProject('project2'))
|
||||||
projectId3 = ObjectId(await user.createProject('project3'))
|
projectId3 = new ObjectId(await user.createProject('project3'))
|
||||||
projectId4 = ObjectId(await user.createProject('project4'))
|
projectId4 = new ObjectId(await user.createProject('project4'))
|
||||||
projectId5 = ObjectId(await user.createProject('project5'))
|
projectId5 = new ObjectId(await user.createProject('project5'))
|
||||||
})
|
})
|
||||||
|
|
||||||
let fileId1, fileId2, fileId3, fileId4
|
let fileId1, fileId2, fileId3, fileId4
|
||||||
beforeEach('create files', function () {
|
beforeEach('create files', function () {
|
||||||
// take a short cut and just allocate file ids
|
// take a short cut and just allocate file ids
|
||||||
fileId1 = ObjectId()
|
fileId1 = new ObjectId()
|
||||||
fileId2 = ObjectId()
|
fileId2 = new ObjectId()
|
||||||
fileId3 = ObjectId()
|
fileId3 = new ObjectId()
|
||||||
fileId4 = ObjectId()
|
fileId4 = new ObjectId()
|
||||||
})
|
})
|
||||||
const otherFileDetails = {
|
const otherFileDetails = {
|
||||||
name: 'universe.jpg',
|
name: 'universe.jpg',
|
||||||
|
|
|
@ -19,17 +19,17 @@ describe('BackFillDocNameForDeletedDocs', function () {
|
||||||
user = new User()
|
user = new User()
|
||||||
await user.login()
|
await user.login()
|
||||||
|
|
||||||
projectId1 = ObjectId(await user.createProject('project1'))
|
projectId1 = new ObjectId(await user.createProject('project1'))
|
||||||
projectId2 = ObjectId(await user.createProject('project2'))
|
projectId2 = new ObjectId(await user.createProject('project2'))
|
||||||
})
|
})
|
||||||
beforeEach('create docs', async function () {
|
beforeEach('create docs', async function () {
|
||||||
docId1 = ObjectId(
|
docId1 = new ObjectId(
|
||||||
await user.createDocInProject(projectId1, null, 'doc1.tex')
|
await user.createDocInProject(projectId1, null, 'doc1.tex')
|
||||||
)
|
)
|
||||||
docId2 = ObjectId(
|
docId2 = new ObjectId(
|
||||||
await user.createDocInProject(projectId1, null, 'doc2.tex')
|
await user.createDocInProject(projectId1, null, 'doc2.tex')
|
||||||
)
|
)
|
||||||
docId3 = ObjectId(
|
docId3 = new ObjectId(
|
||||||
await user.createDocInProject(projectId2, null, 'doc3.tex')
|
await user.createDocInProject(projectId2, null, 'doc3.tex')
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,9 +5,9 @@ const logger = require('@overleaf/logger/logging-manager')
|
||||||
const { expect } = require('chai')
|
const { expect } = require('chai')
|
||||||
|
|
||||||
describe('BackFillDocRevTests', function () {
|
describe('BackFillDocRevTests', function () {
|
||||||
const docId1 = ObjectId()
|
const docId1 = new ObjectId()
|
||||||
const docId2 = ObjectId()
|
const docId2 = new ObjectId()
|
||||||
const docId3 = ObjectId()
|
const docId3 = new ObjectId()
|
||||||
|
|
||||||
beforeEach('insert docs', async function () {
|
beforeEach('insert docs', async function () {
|
||||||
await db.docs.insertMany([
|
await db.docs.insertMany([
|
||||||
|
|
|
@ -52,9 +52,9 @@ describe('ConvertArchivedState', function () {
|
||||||
})
|
})
|
||||||
projectThree = await userOne.getProject(projectThreeId)
|
projectThree = await userOne.getProject(projectThreeId)
|
||||||
projectThree.archived = [
|
projectThree.archived = [
|
||||||
ObjectId(userOne._id),
|
new ObjectId(userOne._id),
|
||||||
ObjectId(userTwo._id),
|
new ObjectId(userTwo._id),
|
||||||
ObjectId(userFour._id),
|
new ObjectId(userFour._id),
|
||||||
]
|
]
|
||||||
projectThree.collaberator_refs.push(userTwo._id)
|
projectThree.collaberator_refs.push(userTwo._id)
|
||||||
projectThree.tokenAccessReadOnly_refs.push(userFour._id)
|
projectThree.tokenAccessReadOnly_refs.push(userFour._id)
|
||||||
|
|
|
@ -432,7 +432,7 @@ describe('Deleting a project', function () {
|
||||||
|
|
||||||
it('Should remove the project data from mongo', function (done) {
|
it('Should remove the project data from mongo', function (done) {
|
||||||
db.deletedProjects.findOne(
|
db.deletedProjects.findOne(
|
||||||
{ 'deleterData.deletedProjectId': ObjectId(this.projectId) },
|
{ 'deleterData.deletedProjectId': new ObjectId(this.projectId) },
|
||||||
(error, deletedProject) => {
|
(error, deletedProject) => {
|
||||||
expect(error).not.to.exist
|
expect(error).not.to.exist
|
||||||
expect(deletedProject).to.exist
|
expect(deletedProject).to.exist
|
||||||
|
@ -454,7 +454,11 @@ describe('Deleting a project', function () {
|
||||||
expect(res.statusCode).to.equal(200)
|
expect(res.statusCode).to.equal(200)
|
||||||
|
|
||||||
db.deletedProjects.findOne(
|
db.deletedProjects.findOne(
|
||||||
{ 'deleterData.deletedProjectId': ObjectId(this.projectId) },
|
{
|
||||||
|
'deleterData.deletedProjectId': new ObjectId(
|
||||||
|
this.projectId
|
||||||
|
),
|
||||||
|
},
|
||||||
(error, deletedProject) => {
|
(error, deletedProject) => {
|
||||||
expect(error).not.to.exist
|
expect(error).not.to.exist
|
||||||
expect(deletedProject).to.exist
|
expect(deletedProject).to.exist
|
||||||
|
|
|
@ -135,7 +135,7 @@ describe('DocUpdate', function () {
|
||||||
|
|
||||||
describe('unknown doc', function () {
|
describe('unknown doc', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
writeOptions.docId = ObjectId()
|
writeOptions.docId = new ObjectId()
|
||||||
})
|
})
|
||||||
|
|
||||||
shouldBlockChanges()
|
shouldBlockChanges()
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('MongoTests', function () {
|
||||||
|
|
||||||
expect(query).to.exist
|
expect(query).to.exist
|
||||||
expect(query._id).to.be.instanceof(NativeObjectId)
|
expect(query._id).to.be.instanceof(NativeObjectId)
|
||||||
expect(query._id).to.deep.equal(NativeObjectId(userIdAsString))
|
expect(query._id).to.deep.equal(new NativeObjectId(userIdAsString))
|
||||||
|
|
||||||
const user = await db.users.findOne(query)
|
const user = await db.users.findOne(query)
|
||||||
expect(user).to.exist
|
expect(user).to.exist
|
||||||
|
@ -79,7 +79,9 @@ describe('MongoTests', function () {
|
||||||
describe('with an ObjectId from the native driver', function () {
|
describe('with an ObjectId from the native driver', function () {
|
||||||
let user
|
let user
|
||||||
beforeEach(async function getUser() {
|
beforeEach(async function getUser() {
|
||||||
user = await db.users.findOne({ _id: NativeObjectId(userIdAsString) })
|
user = await db.users.findOne({
|
||||||
|
_id: new NativeObjectId(userIdAsString),
|
||||||
|
})
|
||||||
expect(user).to.exist
|
expect(user).to.exist
|
||||||
expect(user._id).to.exist
|
expect(user._id).to.exist
|
||||||
expect(user.email).to.equal(userEmail)
|
expect(user.email).to.equal(userEmail)
|
||||||
|
|
|
@ -78,7 +78,7 @@ describe('Project CRUD', function () {
|
||||||
it('should mark the project as not archived for the user', async function () {
|
it('should mark the project as not archived for the user', async function () {
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: this.projectId },
|
{ _id: this.projectId },
|
||||||
{ $set: { archived: [ObjectId(this.user._id)] } }
|
{ $set: { archived: [new ObjectId(this.user._id)] } }
|
||||||
).exec()
|
).exec()
|
||||||
|
|
||||||
const { response } = await this.user.doRequest(
|
const { response } = await this.user.doRequest(
|
||||||
|
@ -117,7 +117,7 @@ describe('Project CRUD', function () {
|
||||||
it('should mark the project as untrashed for the user', async function () {
|
it('should mark the project as untrashed for the user', async function () {
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: this.projectId },
|
{ _id: this.projectId },
|
||||||
{ trashed: [ObjectId(this.user._id)] }
|
{ trashed: [new ObjectId(this.user._id)] }
|
||||||
).exec()
|
).exec()
|
||||||
const { response } = await this.user.doRequest(
|
const { response } = await this.user.doRequest(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
|
@ -132,7 +132,7 @@ describe('Project CRUD', function () {
|
||||||
it('does nothing if the user has already untrashed the project', async function () {
|
it('does nothing if the user has already untrashed the project', async function () {
|
||||||
await Project.updateOne(
|
await Project.updateOne(
|
||||||
{ _id: this.projectId },
|
{ _id: this.projectId },
|
||||||
{ trashed: [ObjectId(this.user._id)] }
|
{ trashed: [new ObjectId(this.user._id)] }
|
||||||
).exec()
|
).exec()
|
||||||
// Mark as untrashed the first time
|
// Mark as untrashed the first time
|
||||||
await this.user.doRequest('DELETE', `/project/${this.projectId}/trash`)
|
await this.user.doRequest('DELETE', `/project/${this.projectId}/trash`)
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Institution {
|
||||||
|
|
||||||
setManagerIds(managerIds, callback) {
|
setManagerIds(managerIds, callback) {
|
||||||
return InstitutionModel.findOneAndUpdate(
|
return InstitutionModel.findOneAndUpdate(
|
||||||
{ _id: ObjectId(this._id) },
|
{ _id: new ObjectId(this._id) },
|
||||||
{ managerIds },
|
{ managerIds },
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Publisher {
|
||||||
|
|
||||||
setManagerIds(managerIds, callback) {
|
setManagerIds(managerIds, callback) {
|
||||||
return PublisherModel.findOneAndUpdate(
|
return PublisherModel.findOneAndUpdate(
|
||||||
{ _id: ObjectId(this._id) },
|
{ _id: new ObjectId(this._id) },
|
||||||
{ managerIds },
|
{ managerIds },
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ before(function () {
|
||||||
|
|
||||||
class RecurlySubscription {
|
class RecurlySubscription {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
options.recurlySubscription_id = ObjectId().toString()
|
options.recurlySubscription_id = new ObjectId().toString()
|
||||||
this.subscription = new Subscription(options)
|
this.subscription = new Subscription(options)
|
||||||
|
|
||||||
this.uuid = options.recurlySubscription_id
|
this.uuid = options.recurlySubscription_id
|
||||||
|
|
|
@ -12,7 +12,7 @@ const Modules = require('../../../../app/src/infrastructure/Modules')
|
||||||
|
|
||||||
class Subscription {
|
class Subscription {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
this.admin_id = options.adminId || ObjectId()
|
this.admin_id = options.adminId || new ObjectId()
|
||||||
this.overleaf = options.overleaf || {}
|
this.overleaf = options.overleaf || {}
|
||||||
this.groupPlan = options.groupPlan
|
this.groupPlan = options.groupPlan
|
||||||
this.manager_ids = options.managerIds || [this.admin_id]
|
this.manager_ids = options.managerIds || [this.admin_id]
|
||||||
|
@ -48,7 +48,7 @@ class Subscription {
|
||||||
}
|
}
|
||||||
|
|
||||||
get(callback) {
|
get(callback) {
|
||||||
db.subscriptions.findOne({ _id: ObjectId(this._id) }, callback)
|
db.subscriptions.findOne({ _id: new ObjectId(this._id) }, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithGroupPolicy(callback) {
|
getWithGroupPolicy(callback) {
|
||||||
|
@ -57,7 +57,7 @@ class Subscription {
|
||||||
|
|
||||||
setManagerIds(managerIds, callback) {
|
setManagerIds(managerIds, callback) {
|
||||||
return SubscriptionModel.findOneAndUpdate(
|
return SubscriptionModel.findOneAndUpdate(
|
||||||
{ _id: ObjectId(this._id) },
|
{ _id: new ObjectId(this._id) },
|
||||||
{ manager_ids: managerIds },
|
{ manager_ids: managerIds },
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
get(callback) {
|
get(callback) {
|
||||||
db.users.findOne({ _id: ObjectId(this._id) }, callback)
|
db.users.findOne({ _id: new ObjectId(this._id) }, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuditLog(callback) {
|
getAuditLog(callback) {
|
||||||
|
@ -53,7 +53,7 @@ class User {
|
||||||
if (!user) return callback(new Error('User not found'))
|
if (!user) return callback(new Error('User not found'))
|
||||||
|
|
||||||
db.userAuditLogEntries
|
db.userAuditLogEntries
|
||||||
.find({ userId: ObjectId(this._id) })
|
.find({ userId: new ObjectId(this._id) })
|
||||||
.toArray((error, auditLog) => {
|
.toArray((error, auditLog) => {
|
||||||
if (error) return callback(error)
|
if (error) return callback(error)
|
||||||
callback(null, auditLog || [])
|
callback(null, auditLog || [])
|
||||||
|
@ -74,7 +74,7 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
mongoUpdate(updateOp, callback) {
|
mongoUpdate(updateOp, callback) {
|
||||||
db.users.updateOne({ _id: ObjectId(this._id) }, updateOp, callback)
|
db.users.updateOne({ _id: new ObjectId(this._id) }, updateOp, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
register(callback) {
|
register(callback) {
|
||||||
|
@ -347,7 +347,7 @@ class User {
|
||||||
|
|
||||||
getFeatures(callback) {
|
getFeatures(callback) {
|
||||||
db.users.findOne(
|
db.users.findOne(
|
||||||
{ _id: ObjectId(this.id) },
|
{ _id: new ObjectId(this.id) },
|
||||||
{ projection: { features: 1 } },
|
{ projection: { features: 1 } },
|
||||||
(error, user) => callback(error, user && user.features)
|
(error, user) => callback(error, user && user.features)
|
||||||
)
|
)
|
||||||
|
@ -362,11 +362,11 @@ class User {
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
const userId = user._id
|
const userId = user._id
|
||||||
db.projects.deleteMany({ owner_ref: ObjectId(userId) }, err => {
|
db.projects.deleteMany({ owner_ref: new ObjectId(userId) }, err => {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
callback(err)
|
callback(err)
|
||||||
}
|
}
|
||||||
db.users.deleteOne({ _id: ObjectId(userId) }, callback)
|
db.users.deleteOne({ _id: new ObjectId(userId) }, callback)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
getProject(projectId, callback) {
|
getProject(projectId, callback) {
|
||||||
db.projects.findOne({ _id: ObjectId(projectId.toString()) }, callback)
|
db.projects.findOne({ _id: new ObjectId(projectId.toString()) }, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveProject(project, callback) {
|
saveProject(project, callback) {
|
||||||
|
@ -498,7 +498,7 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteProjects(callback) {
|
deleteProjects(callback) {
|
||||||
db.projects.deleteMany({ owner_ref: ObjectId(this.id) }, callback)
|
db.projects.deleteMany({ owner_ref: new ObjectId(this.id) }, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
openProject(projectId, callback) {
|
openProject(projectId, callback) {
|
||||||
|
@ -721,14 +721,14 @@ class User {
|
||||||
} else if (privileges === 'readOnly') {
|
} else if (privileges === 'readOnly') {
|
||||||
updateOp = { $addToSet: { readOnly_refs: user._id } }
|
updateOp = { $addToSet: { readOnly_refs: user._id } }
|
||||||
}
|
}
|
||||||
db.projects.updateOne({ _id: ObjectId(projectId) }, updateOp, callback)
|
db.projects.updateOne({ _id: new ObjectId(projectId) }, updateOp, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
makePublic(projectId, level, callback) {
|
makePublic(projectId, level, callback) {
|
||||||
// A fudge, to get around the fact that `readOnly` and `readAndWrite` are now disallowed
|
// A fudge, to get around the fact that `readOnly` and `readAndWrite` are now disallowed
|
||||||
// via the API, but we still need to test the behaviour of projects with these values set.
|
// via the API, but we still need to test the behaviour of projects with these values set.
|
||||||
db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{ _id: ObjectId(projectId) },
|
{ _id: new ObjectId(projectId) },
|
||||||
// NOTE: Yes, there is a typo in the db schema.
|
// NOTE: Yes, there is a typo in the db schema.
|
||||||
{ $set: { publicAccesLevel: level } },
|
{ $set: { publicAccesLevel: level } },
|
||||||
callback
|
callback
|
||||||
|
|
|
@ -238,7 +238,7 @@ class UserHelper {
|
||||||
static async updateUser(userId, update) {
|
static async updateUser(userId, update) {
|
||||||
// TODO(das7pad): revert back to args pass-through after mongo upgrades
|
// TODO(das7pad): revert back to args pass-through after mongo upgrades
|
||||||
const user = await UserUpdater.promises.updateUser(
|
const user = await UserUpdater.promises.updateUser(
|
||||||
{ _id: ObjectId(userId) },
|
{ _id: new ObjectId(userId) },
|
||||||
update
|
update
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class MockDocstoreApi extends AbstractMockApi {
|
||||||
this.app.post('/project/:projectId/destroy', async (req, res) => {
|
this.app.post('/project/:projectId/destroy', async (req, res) => {
|
||||||
const { projectId } = req.params
|
const { projectId } = req.params
|
||||||
delete this.docs[projectId]
|
delete this.docs[projectId]
|
||||||
await db.docs.deleteMany({ project_id: ObjectId(projectId) })
|
await db.docs.deleteMany({ project_id: new ObjectId(projectId) })
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ const sinon = require('sinon')
|
||||||
const MockRequest = require('../helpers/MockRequest')
|
const MockRequest = require('../helpers/MockRequest')
|
||||||
const MockResponse = require('../helpers/MockResponse')
|
const MockResponse = require('../helpers/MockResponse')
|
||||||
const { assert } = require('chai')
|
const { assert } = require('chai')
|
||||||
const { ObjectID } = require('mongodb')
|
const { ObjectId } = require('mongodb')
|
||||||
|
|
||||||
const MODULE_PATH = path.join(
|
const MODULE_PATH = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
@ -85,7 +85,7 @@ describe('AnalyticsManager', function () {
|
||||||
|
|
||||||
it('analyticsId is missing', function () {
|
it('analyticsId is missing', function () {
|
||||||
this.AnalyticsManager.identifyUser(
|
this.AnalyticsManager.identifyUser(
|
||||||
new ObjectID(this.fakeUserId),
|
new ObjectId(this.fakeUserId),
|
||||||
undefined
|
undefined
|
||||||
)
|
)
|
||||||
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
||||||
|
@ -93,7 +93,7 @@ describe('AnalyticsManager', function () {
|
||||||
|
|
||||||
it('analyticsId is not a valid UUID', function () {
|
it('analyticsId is not a valid UUID', function () {
|
||||||
this.AnalyticsManager.identifyUser(
|
this.AnalyticsManager.identifyUser(
|
||||||
new ObjectID(this.fakeUserId),
|
new ObjectId(this.fakeUserId),
|
||||||
this.fakeUserId
|
this.fakeUserId
|
||||||
)
|
)
|
||||||
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
||||||
|
@ -101,8 +101,8 @@ describe('AnalyticsManager', function () {
|
||||||
|
|
||||||
it('userId and analyticsId are the same Mongo ID', function () {
|
it('userId and analyticsId are the same Mongo ID', function () {
|
||||||
this.AnalyticsManager.identifyUser(
|
this.AnalyticsManager.identifyUser(
|
||||||
new ObjectID(this.fakeUserId),
|
new ObjectId(this.fakeUserId),
|
||||||
new ObjectID(this.fakeUserId)
|
new ObjectId(this.fakeUserId)
|
||||||
)
|
)
|
||||||
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
sinon.assert.notCalled(this.Queues.createScheduledJob)
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('AuthenticationController', function () {
|
||||||
'valid-test-user': Math.random().toString(16).slice(2),
|
'valid-test-user': Math.random().toString(16).slice(2),
|
||||||
}
|
}
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
email: (this.email = 'USER@example.com'),
|
email: (this.email = 'USER@example.com'),
|
||||||
first_name: 'bob',
|
first_name: 'bob',
|
||||||
last_name: 'brown',
|
last_name: 'brown',
|
||||||
|
|
|
@ -747,7 +747,7 @@ describe('AuthenticationManager', function () {
|
||||||
|
|
||||||
describe('setUserPassword', function () {
|
describe('setUserPassword', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user_id = ObjectId()
|
this.user_id = new ObjectId()
|
||||||
this.password = 'bananagram'
|
this.password = 'bananagram'
|
||||||
this.hashedPassword = 'asdkjfa;osiuvandf'
|
this.hashedPassword = 'asdkjfa;osiuvandf'
|
||||||
this.salt = 'saltaasdfasdfasdf'
|
this.salt = 'saltaasdfasdfasdf'
|
||||||
|
@ -955,7 +955,7 @@ describe('AuthenticationManager', function () {
|
||||||
it("should update the user's password in the database", function () {
|
it("should update the user's password in the database", function () {
|
||||||
const { args } = this.db.users.updateOne.lastCall
|
const { args } = this.db.users.updateOne.lastCall
|
||||||
expect(args[0]).to.deep.equal({
|
expect(args[0]).to.deep.equal({
|
||||||
_id: ObjectId(this.user_id.toString()),
|
_id: new ObjectId(this.user_id.toString()),
|
||||||
})
|
})
|
||||||
expect(args[1]).to.deep.equal({
|
expect(args[1]).to.deep.equal({
|
||||||
$set: {
|
$set: {
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('SessionManager', function () {
|
||||||
requires: {},
|
requires: {},
|
||||||
})
|
})
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
email: (this.email = 'USER@example.com'),
|
email: (this.email = 'USER@example.com'),
|
||||||
first_name: 'bob',
|
first_name: 'bob',
|
||||||
last_name: 'brown',
|
last_name: 'brown',
|
||||||
|
|
|
@ -14,8 +14,8 @@ describe('CollaboratorsController', function () {
|
||||||
this.res = new MockResponse()
|
this.res = new MockResponse()
|
||||||
this.req = new MockRequest()
|
this.req = new MockRequest()
|
||||||
|
|
||||||
this.user = { _id: ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
this.projectId = ObjectId()
|
this.projectId = new ObjectId()
|
||||||
this.callback = sinon.stub()
|
this.callback = sinon.stub()
|
||||||
|
|
||||||
this.CollaboratorsHandler = {
|
this.CollaboratorsHandler = {
|
||||||
|
|
|
@ -14,16 +14,16 @@ const MODULE_PATH = Path.join(
|
||||||
describe('CollaboratorsGetter', function () {
|
describe('CollaboratorsGetter', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.userId = 'mock-user-id'
|
this.userId = 'mock-user-id'
|
||||||
this.ownerRef = ObjectId()
|
this.ownerRef = new ObjectId()
|
||||||
this.readOnlyRef1 = ObjectId()
|
this.readOnlyRef1 = new ObjectId()
|
||||||
this.readOnlyRef2 = ObjectId()
|
this.readOnlyRef2 = new ObjectId()
|
||||||
this.readWriteRef1 = ObjectId()
|
this.readWriteRef1 = new ObjectId()
|
||||||
this.readWriteRef2 = ObjectId()
|
this.readWriteRef2 = new ObjectId()
|
||||||
this.readOnlyTokenRef = ObjectId()
|
this.readOnlyTokenRef = new ObjectId()
|
||||||
this.readWriteTokenRef = ObjectId()
|
this.readWriteTokenRef = new ObjectId()
|
||||||
this.nonMemberRef = ObjectId()
|
this.nonMemberRef = new ObjectId()
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
owner_ref: [this.ownerRef],
|
owner_ref: [this.ownerRef],
|
||||||
readOnly_refs: [this.readOnlyRef1, this.readOnlyRef2],
|
readOnly_refs: [this.readOnlyRef1, this.readOnlyRef2],
|
||||||
collaberator_refs: [this.readWriteRef1, this.readWriteRef2],
|
collaberator_refs: [this.readWriteRef1, this.readWriteRef2],
|
||||||
|
@ -366,7 +366,7 @@ describe('CollaboratorsGetter', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getPublicShareTokens', function () {
|
describe('getPublicShareTokens', function () {
|
||||||
const userMock = ObjectId()
|
const userMock = new ObjectId()
|
||||||
|
|
||||||
it('should return null when the project is not found', async function () {
|
it('should return null when the project is not found', async function () {
|
||||||
this.ProjectMock.expects('findOne').chain('exec').resolves(undefined)
|
this.ProjectMock.expects('findOne').chain('exec').resolves(undefined)
|
||||||
|
|
|
@ -16,21 +16,21 @@ const sleep = promisify(setTimeout)
|
||||||
|
|
||||||
describe('CollaboratorsHandler', function () {
|
describe('CollaboratorsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.userId = ObjectId()
|
this.userId = new ObjectId()
|
||||||
this.addingUserId = ObjectId()
|
this.addingUserId = new ObjectId()
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
owner_ref: this.addingUserId,
|
owner_ref: this.addingUserId,
|
||||||
name: 'Foo',
|
name: 'Foo',
|
||||||
}
|
}
|
||||||
|
|
||||||
this.archivedProject = {
|
this.archivedProject = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
archived: [ObjectId(this.userId)],
|
archived: [new ObjectId(this.userId)],
|
||||||
}
|
}
|
||||||
|
|
||||||
this.oldArchivedProject = {
|
this.oldArchivedProject = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
archived: true,
|
archived: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ describe('CollaboratorsHandler', function () {
|
||||||
|
|
||||||
describe('an archived project, archived with a boolean value', function () {
|
describe('an archived project, archived with a boolean value', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const archived = [ObjectId(this.userId)]
|
const archived = [new ObjectId(this.userId)]
|
||||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||||
|
|
||||||
this.ProjectMock.expects('findOne')
|
this.ProjectMock.expects('findOne')
|
||||||
|
@ -394,14 +394,14 @@ describe('CollaboratorsHandler', function () {
|
||||||
|
|
||||||
describe('transferProjects', function () {
|
describe('transferProjects', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.fromUserId = ObjectId()
|
this.fromUserId = new ObjectId()
|
||||||
this.toUserId = ObjectId()
|
this.toUserId = new ObjectId()
|
||||||
this.projects = [
|
this.projects = [
|
||||||
{
|
{
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
this.ProjectMock.expects('find')
|
this.ProjectMock.expects('find')
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('CollaboratorsInviteController', function () {
|
||||||
email: 'current-user@example.com',
|
email: 'current-user@example.com',
|
||||||
}
|
}
|
||||||
this.invite = {
|
this.invite = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
token: this.token,
|
token: this.token,
|
||||||
sendingUserId: this.currentUser._id,
|
sendingUserId: this.currentUser._id,
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
|
@ -116,8 +116,8 @@ describe('CollaboratorsInviteController', function () {
|
||||||
describe('getAllInvites', function () {
|
describe('getAllInvites', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.fakeInvites = [
|
this.fakeInvites = [
|
||||||
{ _id: ObjectId(), one: 1 },
|
{ _id: new ObjectId(), one: 1 },
|
||||||
{ _id: ObjectId(), two: 2 },
|
{ _id: new ObjectId(), two: 2 },
|
||||||
]
|
]
|
||||||
this.req.params = { Project_id: this.projectId }
|
this.req.params = { Project_id: this.projectId }
|
||||||
})
|
})
|
||||||
|
@ -1295,7 +1295,7 @@ describe('CollaboratorsInviteController', function () {
|
||||||
|
|
||||||
describe('when user account is present', function () {
|
describe('when user account is present', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: ObjectId().toString() }
|
this.user = { _id: new ObjectId().toString() }
|
||||||
this.UserGetter.promises.getUserByAnyEmail.resolves(this.user)
|
this.UserGetter.promises.getUserByAnyEmail.resolves(this.user)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('CollaboratorsInviteHandler', function () {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
||||||
this._id = ObjectId()
|
this._id = new ObjectId()
|
||||||
for (const k in options) {
|
for (const k in options) {
|
||||||
const v = options[k]
|
const v = options[k]
|
||||||
this[k] = v
|
this[k] = v
|
||||||
|
@ -55,19 +55,19 @@ describe('CollaboratorsInviteHandler', function () {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
this.projectId = ObjectId()
|
this.projectId = new ObjectId()
|
||||||
this.sendingUserId = ObjectId()
|
this.sendingUserId = new ObjectId()
|
||||||
this.sendingUser = {
|
this.sendingUser = {
|
||||||
_id: this.sendingUserId,
|
_id: this.sendingUserId,
|
||||||
name: 'Bob',
|
name: 'Bob',
|
||||||
}
|
}
|
||||||
this.email = 'user@example.com'
|
this.email = 'user@example.com'
|
||||||
this.userId = ObjectId()
|
this.userId = new ObjectId()
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: this.userId,
|
_id: this.userId,
|
||||||
email: 'someone@example.com',
|
email: 'someone@example.com',
|
||||||
}
|
}
|
||||||
this.inviteId = ObjectId()
|
this.inviteId = new ObjectId()
|
||||||
this.token = 'hnhteaosuhtaeosuahs'
|
this.token = 'hnhteaosuhtaeosuahs'
|
||||||
this.privileges = 'readAndWrite'
|
this.privileges = 'readAndWrite'
|
||||||
this.fakeInvite = {
|
this.fakeInvite = {
|
||||||
|
@ -114,8 +114,8 @@ describe('CollaboratorsInviteHandler', function () {
|
||||||
describe('getAllInvites', function () {
|
describe('getAllInvites', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.fakeInvites = [
|
this.fakeInvites = [
|
||||||
{ _id: ObjectId(), one: 1 },
|
{ _id: new ObjectId(), one: 1 },
|
||||||
{ _id: ObjectId(), two: 2 },
|
{ _id: new ObjectId(), two: 2 },
|
||||||
]
|
]
|
||||||
this.ProjectInvite.find.returns({
|
this.ProjectInvite.find.returns({
|
||||||
exec: sinon.stub().resolves(this.fakeInvites),
|
exec: sinon.stub().resolves(this.fakeInvites),
|
||||||
|
@ -607,8 +607,8 @@ describe('CollaboratorsInviteHandler', function () {
|
||||||
|
|
||||||
describe('_tryCancelInviteNotification', function () {
|
describe('_tryCancelInviteNotification', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.inviteId = ObjectId()
|
this.inviteId = new ObjectId()
|
||||||
this.currentUser = { _id: ObjectId() }
|
this.currentUser = { _id: new ObjectId() }
|
||||||
this.notification = { read: sinon.stub().resolves() }
|
this.notification = { read: sinon.stub().resolves() }
|
||||||
this.NotificationsBuilder.promises.projectInvite = sinon
|
this.NotificationsBuilder.promises.projectInvite = sinon
|
||||||
.stub()
|
.stub()
|
||||||
|
@ -644,18 +644,18 @@ describe('CollaboratorsInviteHandler', function () {
|
||||||
describe('_trySendInviteNotification', function () {
|
describe('_trySendInviteNotification', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.invite = {
|
this.invite = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
token: 'some_token',
|
token: 'some_token',
|
||||||
sendingUserId: ObjectId(),
|
sendingUserId: new ObjectId(),
|
||||||
projectId: this.project_id,
|
projectId: this.project_id,
|
||||||
targetEmail: 'user@example.com',
|
targetEmail: 'user@example.com',
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
}
|
}
|
||||||
this.sendingUser = {
|
this.sendingUser = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
first_name: 'jim',
|
first_name: 'jim',
|
||||||
}
|
}
|
||||||
this.existingUser = { _id: ObjectId() }
|
this.existingUser = { _id: new ObjectId() }
|
||||||
this.UserGetter.promises.getUserByAnyEmail = sinon
|
this.UserGetter.promises.getUserByAnyEmail = sinon
|
||||||
.stub()
|
.stub()
|
||||||
.resolves(this.existingUser)
|
.resolves(this.existingUser)
|
||||||
|
|
|
@ -10,10 +10,13 @@ const MODULE_PATH =
|
||||||
|
|
||||||
describe('OwnershipTransferHandler', function () {
|
describe('OwnershipTransferHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: ObjectId(), email: 'owner@example.com' }
|
this.user = { _id: new ObjectId(), email: 'owner@example.com' }
|
||||||
this.collaborator = { _id: ObjectId(), email: 'collaborator@example.com' }
|
this.collaborator = {
|
||||||
|
_id: new ObjectId(),
|
||||||
|
email: 'collaborator@example.com',
|
||||||
|
}
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'project',
|
name: 'project',
|
||||||
owner_ref: this.user._id,
|
owner_ref: this.user._id,
|
||||||
collaberator_refs: [this.collaborator._id],
|
collaberator_refs: [this.collaborator._id],
|
||||||
|
@ -205,7 +208,7 @@ describe('OwnershipTransferHandler', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should track the change in BigQuery', async function () {
|
it('should track the change in BigQuery', async function () {
|
||||||
const sessionUserId = ObjectId()
|
const sessionUserId = new ObjectId()
|
||||||
await this.handler.promises.transferOwnership(
|
await this.handler.promises.transferOwnership(
|
||||||
this.project._id,
|
this.project._id,
|
||||||
this.collaborator._id,
|
this.collaborator._id,
|
||||||
|
@ -222,7 +225,7 @@ describe('OwnershipTransferHandler', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should write an entry in the audit log', async function () {
|
it('should write an entry in the audit log', async function () {
|
||||||
const sessionUserId = ObjectId()
|
const sessionUserId = new ObjectId()
|
||||||
await this.handler.promises.transferOwnership(
|
await this.handler.promises.transferOwnership(
|
||||||
this.project._id,
|
this.project._id,
|
||||||
this.collaborator._id,
|
this.collaborator._id,
|
||||||
|
|
|
@ -8,7 +8,7 @@ const MODULE_PATH = '../../../../app/src/Features/History/HistoryManager'
|
||||||
describe('HistoryManager', function () {
|
describe('HistoryManager', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user_id = 'user-id-123'
|
this.user_id = 'user-id-123'
|
||||||
this.historyId = ObjectId().toString()
|
this.historyId = new ObjectId().toString()
|
||||||
this.AuthenticationController = {
|
this.AuthenticationController = {
|
||||||
getLoggedInUserId: sinon.stub().returns(this.user_id),
|
getLoggedInUserId: sinon.stub().returns(this.user_id),
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ const SandboxedModule = require('sandboxed-module')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const sinon = require('sinon')
|
const sinon = require('sinon')
|
||||||
const { expect } = require('chai')
|
const { expect } = require('chai')
|
||||||
|
const { ObjectId } = require('mongodb')
|
||||||
const modulePath = path.join(
|
const modulePath = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'../../../../app/src/Features/Institutions/InstitutionsManager'
|
'../../../../app/src/Features/Institutions/InstitutionsManager'
|
||||||
|
@ -16,19 +17,23 @@ describe('InstitutionsManager', function () {
|
||||||
this.getConfirmedInstitutionAffiliations = sinon.stub()
|
this.getConfirmedInstitutionAffiliations = sinon.stub()
|
||||||
this.addAffiliation = sinon.stub().callsArgWith(3, null)
|
this.addAffiliation = sinon.stub().callsArgWith(3, null)
|
||||||
this.refreshFeatures = sinon.stub().yields()
|
this.refreshFeatures = sinon.stub().yields()
|
||||||
|
const lapsedUser = {
|
||||||
|
_id: '657300a08a14461b3d1aac3e',
|
||||||
|
features: {},
|
||||||
|
}
|
||||||
this.users = [
|
this.users = [
|
||||||
{ _id: 'lapsed', features: {} },
|
lapsedUser,
|
||||||
{ _id: '1a', features: {} },
|
{ _id: '657300a08a14461b3d1aac3f', features: {} },
|
||||||
{ _id: '2b', features: {} },
|
{ _id: '657300a08a14461b3d1aac40', features: {} },
|
||||||
{ _id: '3c', features: {} },
|
{ _id: '657300a08a14461b3d1aac41', features: {} },
|
||||||
]
|
]
|
||||||
this.ssoUsers = [
|
this.ssoUsers = [
|
||||||
{
|
{
|
||||||
_id: '1a',
|
_id: '657300a08a14461b3d1aac3f',
|
||||||
samlIdentifiers: [{ providerId: this.institutionId.toString() }],
|
samlIdentifiers: [{ providerId: this.institutionId.toString() }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: '2b',
|
_id: '657300a08a14461b3d1aac40',
|
||||||
samlIdentifiers: [
|
samlIdentifiers: [
|
||||||
{
|
{
|
||||||
providerId: this.institutionId.toString(),
|
providerId: this.institutionId.toString(),
|
||||||
|
@ -37,7 +42,7 @@ describe('InstitutionsManager', function () {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: 'lapsed',
|
_id: '657300a08a14461b3d1aac3e',
|
||||||
samlIdentifiers: [{ providerId: this.institutionId.toString() }],
|
samlIdentifiers: [{ providerId: this.institutionId.toString() }],
|
||||||
hasEntitlement: true,
|
hasEntitlement: true,
|
||||||
},
|
},
|
||||||
|
@ -83,12 +88,15 @@ describe('InstitutionsManager', function () {
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.Mongo = { ObjectId: sinon.stub().returnsArg(0) }
|
|
||||||
|
this.Mongo = {
|
||||||
|
ObjectId,
|
||||||
|
}
|
||||||
|
|
||||||
this.v1Counts = {
|
this.v1Counts = {
|
||||||
user_ids: this.users.map(user => user._id),
|
user_ids: this.users.map(user => user._id),
|
||||||
current_users_count: 3,
|
current_users_count: 3,
|
||||||
lapsed_user_ids: ['lapsed'],
|
lapsed_user_ids: [lapsedUser._id],
|
||||||
entitled_via_sso: 1, // 2 entitled, but 1 lapsed
|
entitled_via_sso: 1, // 2 entitled, but 1 lapsed
|
||||||
with_confirmed_email: 2, // 1 non entitled SSO + 1 email user
|
with_confirmed_email: 2, // 1 non entitled SSO + 1 email user
|
||||||
}
|
}
|
||||||
|
@ -151,8 +159,8 @@ describe('InstitutionsManager', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user1Id = '123abc123abc123abc123abc'
|
this.user1Id = '123abc123abc123abc123abc'
|
||||||
this.user2Id = '456def456def456def456def'
|
this.user2Id = '456def456def456def456def'
|
||||||
this.user3Id = 'trial123abc'
|
this.user3Id = '789abd789abd789abd789abd'
|
||||||
this.user4Id = 'group123abc'
|
this.user4Id = '321cba321cba321cba321cba'
|
||||||
this.affiliations = [
|
this.affiliations = [
|
||||||
{ user_id: this.user1Id },
|
{ user_id: this.user1Id },
|
||||||
{ user_id: this.user2Id },
|
{ user_id: this.user2Id },
|
||||||
|
@ -164,10 +172,18 @@ describe('InstitutionsManager', function () {
|
||||||
this.user3 = { _id: this.user3Id }
|
this.user3 = { _id: this.user3Id }
|
||||||
this.user4 = { _id: this.user4Id }
|
this.user4 = { _id: this.user4Id }
|
||||||
|
|
||||||
this.UserGetter.getUser.withArgs(this.user1Id).yields(null, this.user1)
|
this.UserGetter.getUser
|
||||||
this.UserGetter.getUser.withArgs(this.user2Id).yields(null, this.user2)
|
.withArgs(new ObjectId(this.user1Id))
|
||||||
this.UserGetter.getUser.withArgs(this.user3Id).yields(null, this.user3)
|
.yields(null, this.user1)
|
||||||
this.UserGetter.getUser.withArgs(this.user4Id).yields(null, this.user4)
|
this.UserGetter.getUser
|
||||||
|
.withArgs(new ObjectId(this.user2Id))
|
||||||
|
.yields(null, this.user2)
|
||||||
|
this.UserGetter.getUser
|
||||||
|
.withArgs(new ObjectId(this.user3Id))
|
||||||
|
.yields(null, this.user3)
|
||||||
|
this.UserGetter.getUser
|
||||||
|
.withArgs(new ObjectId(this.user4Id))
|
||||||
|
.yields(null, this.user4)
|
||||||
|
|
||||||
this.SubscriptionLocator.getUsersSubscription
|
this.SubscriptionLocator.getUsersSubscription
|
||||||
.withArgs(this.user2)
|
.withArgs(this.user2)
|
||||||
|
@ -188,7 +204,9 @@ describe('InstitutionsManager', function () {
|
||||||
groupPlan: true,
|
groupPlan: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.refreshFeatures.withArgs(this.user1Id).yields(null, {}, true)
|
this.refreshFeatures
|
||||||
|
.withArgs(new ObjectId(this.user1Id))
|
||||||
|
.yields(null, {}, true)
|
||||||
this.getInstitutionAffiliations.yields(null, this.affiliations)
|
this.getInstitutionAffiliations.yields(null, this.affiliations)
|
||||||
this.getConfirmedInstitutionAffiliations.yields(null, this.affiliations)
|
this.getConfirmedInstitutionAffiliations.yields(null, this.affiliations)
|
||||||
})
|
})
|
||||||
|
@ -370,7 +388,7 @@ describe('InstitutionsManager', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.host = 'mit.edu'.split('').reverse().join('')
|
this.host = 'mit.edu'.split('').reverse().join('')
|
||||||
this.stubbedUser1 = {
|
this.stubbedUser1 = {
|
||||||
_id: '3131231',
|
_id: '6573014d8a14461b3d1aac3f',
|
||||||
name: 'bob',
|
name: 'bob',
|
||||||
email: 'hello@world.com',
|
email: 'hello@world.com',
|
||||||
emails: [
|
emails: [
|
||||||
|
@ -393,7 +411,7 @@ describe('InstitutionsManager', function () {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
this.stubbedUser2 = {
|
this.stubbedUser2 = {
|
||||||
_id: '3131232',
|
_id: '6573014d8a14461b3d1aac40',
|
||||||
name: 'test',
|
name: 'test',
|
||||||
email: 'hello2@world.com',
|
email: 'hello2@world.com',
|
||||||
emails: [{ email: 'subb2@mit.edu', reversedHostname: this.host }],
|
emails: [{ email: 'subb2@mit.edu', reversedHostname: this.host }],
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
const { expect } = require('chai')
|
const { expect } = require('chai')
|
||||||
const sinon = require('sinon')
|
|
||||||
const SandboxedModule = require('sandboxed-module')
|
const SandboxedModule = require('sandboxed-module')
|
||||||
|
const { ObjectId } = require('mongodb')
|
||||||
|
|
||||||
const MODULE_PATH =
|
const MODULE_PATH =
|
||||||
'../../../../app/src/Features/Project/FolderStructureBuilder'
|
'../../../../app/src/Features/Project/FolderStructureBuilder'
|
||||||
const MOCK_OBJECT_ID = 'MOCK_OBJECT_ID'
|
const MOCK_OBJECT_ID = new ObjectId('657306930a1cf28031c358da')
|
||||||
|
|
||||||
describe('FolderStructureBuilder', function () {
|
describe('FolderStructureBuilder', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.ObjectId = sinon.stub().returns(MOCK_OBJECT_ID)
|
|
||||||
this.FolderStructureBuilder = SandboxedModule.require(MODULE_PATH, {
|
this.FolderStructureBuilder = SandboxedModule.require(MODULE_PATH, {
|
||||||
requires: {
|
requires: {
|
||||||
mongodb: { ObjectId: this.ObjectId },
|
mongodb: {
|
||||||
|
ObjectId: class {
|
||||||
|
constructor() {
|
||||||
|
return MOCK_OBJECT_ID
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,9 +25,9 @@ const modulePath = Path.join(
|
||||||
|
|
||||||
describe('ProjectCollabratecDetailsHandler', function () {
|
describe('ProjectCollabratecDetailsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.projectId = ObjectId('5bea8747c7bba6012fcaceb3')
|
this.projectId = new ObjectId('5bea8747c7bba6012fcaceb3')
|
||||||
this.userId = ObjectId('5be316a9c7f6aa03802ea8fb')
|
this.userId = new ObjectId('5be316a9c7f6aa03802ea8fb')
|
||||||
this.userId2 = ObjectId('5c1794b3f0e89b1d1c577eca')
|
this.userId2 = new ObjectId('5c1794b3f0e89b1d1c577eca')
|
||||||
this.ProjectModel = {}
|
this.ProjectModel = {}
|
||||||
this.ProjectCollabratecDetailsHandler = SandboxedModule.require(
|
this.ProjectCollabratecDetailsHandler = SandboxedModule.require(
|
||||||
modulePath,
|
modulePath,
|
||||||
|
@ -132,10 +132,10 @@ describe('ProjectCollabratecDetailsHandler', function () {
|
||||||
it('should call find with project and user id', function () {
|
it('should call find with project and user id', function () {
|
||||||
return expect(this.ProjectModel.findOne).to.have.been.calledWithMatch(
|
return expect(this.ProjectModel.findOne).to.have.been.calledWithMatch(
|
||||||
{
|
{
|
||||||
_id: ObjectId(this.projectId),
|
_id: new ObjectId(this.projectId),
|
||||||
collabratecUsers: {
|
collabratecUsers: {
|
||||||
$elemMatch: {
|
$elemMatch: {
|
||||||
user_id: ObjectId(this.userId),
|
user_id: new ObjectId(this.userId),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ const MODULE_PATH = path.join(
|
||||||
|
|
||||||
describe('ProjectController', function () {
|
describe('ProjectController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.project_id = ObjectId('abcdefabcdefabcdefabcdef')
|
this.project_id = new ObjectId('abcdefabcdefabcdefabcdef')
|
||||||
|
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId('123456123456123456123456'),
|
_id: new ObjectId('123456123456123456123456'),
|
||||||
email: 'test@overleaf.com',
|
email: 'test@overleaf.com',
|
||||||
first_name: 'bjkdsjfk',
|
first_name: 'bjkdsjfk',
|
||||||
features: {},
|
features: {},
|
||||||
|
@ -590,7 +590,7 @@ describe('ProjectController', function () {
|
||||||
this.res.render = (pageName, opts) => {
|
this.res.render = (pageName, opts) => {
|
||||||
expect(this.UserModel.updateOne).to.have.been.calledOnce
|
expect(this.UserModel.updateOne).to.have.been.calledOnce
|
||||||
expect(this.UserModel.updateOne.args[0][0]).to.deep.equal({
|
expect(this.UserModel.updateOne.args[0][0]).to.deep.equal({
|
||||||
_id: ObjectId(this.user._id),
|
_id: new ObjectId(this.user._id),
|
||||||
})
|
})
|
||||||
expect(this.UserModel.updateOne.args[0][1].$set.lastActive).to.exist
|
expect(this.UserModel.updateOne.args[0][1].$set.lastActive).to.exist
|
||||||
done()
|
done()
|
||||||
|
|
|
@ -567,7 +567,7 @@ describe('ProjectDeleter', function () {
|
||||||
|
|
||||||
describe('archiveProject', function () {
|
describe('archiveProject', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const archived = [ObjectId(this.user._id)]
|
const archived = [new ObjectId(this.user._id)]
|
||||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||||
|
|
||||||
this.ProjectMock.expects('findOne')
|
this.ProjectMock.expects('findOne')
|
||||||
|
@ -580,7 +580,7 @@ describe('ProjectDeleter', function () {
|
||||||
{ _id: this.project._id },
|
{ _id: this.project._id },
|
||||||
{
|
{
|
||||||
$set: { archived },
|
$set: { archived },
|
||||||
$pull: { trashed: ObjectId(this.user._id) },
|
$pull: { trashed: new ObjectId(this.user._id) },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.resolves()
|
.resolves()
|
||||||
|
@ -609,7 +609,7 @@ describe('ProjectDeleter', function () {
|
||||||
|
|
||||||
describe('unarchiveProject', function () {
|
describe('unarchiveProject', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const archived = [ObjectId(this.user._id)]
|
const archived = [new ObjectId(this.user._id)]
|
||||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||||
|
|
||||||
this.ProjectMock.expects('findOne')
|
this.ProjectMock.expects('findOne')
|
||||||
|
@ -645,7 +645,7 @@ describe('ProjectDeleter', function () {
|
||||||
|
|
||||||
describe('trashProject', function () {
|
describe('trashProject', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const archived = [ObjectId(this.user._id)]
|
const archived = [new ObjectId(this.user._id)]
|
||||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||||
|
|
||||||
this.ProjectMock.expects('findOne')
|
this.ProjectMock.expects('findOne')
|
||||||
|
@ -657,7 +657,7 @@ describe('ProjectDeleter', function () {
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{ _id: this.project._id },
|
{ _id: this.project._id },
|
||||||
{
|
{
|
||||||
$addToSet: { trashed: ObjectId(this.user._id) },
|
$addToSet: { trashed: new ObjectId(this.user._id) },
|
||||||
$set: { archived },
|
$set: { archived },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -695,7 +695,7 @@ describe('ProjectDeleter', function () {
|
||||||
this.ProjectMock.expects('updateOne')
|
this.ProjectMock.expects('updateOne')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{ _id: this.project._id },
|
{ _id: this.project._id },
|
||||||
{ $pull: { trashed: ObjectId(this.user._id) } }
|
{ $pull: { trashed: new ObjectId(this.user._id) } }
|
||||||
)
|
)
|
||||||
.resolves()
|
.resolves()
|
||||||
})
|
})
|
||||||
|
@ -731,8 +731,8 @@ describe('ProjectDeleter', function () {
|
||||||
|
|
||||||
describe('undeleteProject', function () {
|
describe('undeleteProject', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.unknownProjectId = ObjectId()
|
this.unknownProjectId = new ObjectId()
|
||||||
this.purgedProjectId = ObjectId()
|
this.purgedProjectId = new ObjectId()
|
||||||
|
|
||||||
this.deletedProject = {
|
this.deletedProject = {
|
||||||
_id: 'deleted',
|
_id: 'deleted',
|
||||||
|
|
|
@ -10,16 +10,16 @@ const MODULE_PATH = '../../../../app/src/Features/Project/ProjectDetailsHandler'
|
||||||
describe('ProjectDetailsHandler', function () {
|
describe('ProjectDetailsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
email: 'user@example.com',
|
email: 'user@example.com',
|
||||||
features: 'mock-features',
|
features: 'mock-features',
|
||||||
}
|
}
|
||||||
this.collaborator = {
|
this.collaborator = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
email: 'collaborator@example.com',
|
email: 'collaborator@example.com',
|
||||||
}
|
}
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'project',
|
name: 'project',
|
||||||
description: 'this is a great project',
|
description: 'this is a great project',
|
||||||
something: 'should not exist',
|
something: 'should not exist',
|
||||||
|
|
|
@ -13,7 +13,7 @@ const MODULE_PATH =
|
||||||
describe('ProjectEntityMongoUpdateHandler', function () {
|
describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.doc = {
|
this.doc = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'test-doc.txt',
|
name: 'test-doc.txt',
|
||||||
lines: ['hello', 'world'],
|
lines: ['hello', 'world'],
|
||||||
rev: 1234,
|
rev: 1234,
|
||||||
|
@ -23,7 +23,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
fileSystem: '/test-doc.txt',
|
fileSystem: '/test-doc.txt',
|
||||||
}
|
}
|
||||||
this.file = {
|
this.file = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'something.jpg',
|
name: 'something.jpg',
|
||||||
linkedFileData: { provider: 'url' },
|
linkedFileData: { provider: 'url' },
|
||||||
hash: 'some-hash',
|
hash: 'some-hash',
|
||||||
|
@ -32,18 +32,18 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
fileSystem: '/something.png',
|
fileSystem: '/something.png',
|
||||||
mongo: 'rootFolder.0.fileRefs.0',
|
mongo: 'rootFolder.0.fileRefs.0',
|
||||||
}
|
}
|
||||||
this.subfolder = { _id: ObjectId(), name: 'test-subfolder' }
|
this.subfolder = { _id: new ObjectId(), name: 'test-subfolder' }
|
||||||
this.subfolderPath = {
|
this.subfolderPath = {
|
||||||
fileSystem: '/test-folder/test-subfolder',
|
fileSystem: '/test-folder/test-subfolder',
|
||||||
mongo: 'rootFolder.0.folders.0.folders.0',
|
mongo: 'rootFolder.0.folders.0.folders.0',
|
||||||
}
|
}
|
||||||
this.notSubfolder = { _id: ObjectId(), name: 'test-folder-2' }
|
this.notSubfolder = { _id: new ObjectId(), name: 'test-folder-2' }
|
||||||
this.notSubfolderPath = {
|
this.notSubfolderPath = {
|
||||||
fileSystem: '/test-folder-2/test-subfolder',
|
fileSystem: '/test-folder-2/test-subfolder',
|
||||||
mongo: 'rootFolder.0.folders.0.folders.0',
|
mongo: 'rootFolder.0.folders.0.folders.0',
|
||||||
}
|
}
|
||||||
this.folder = {
|
this.folder = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'test-folder',
|
name: 'test-folder',
|
||||||
folders: [this.subfolder],
|
folders: [this.subfolder],
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
mongo: 'rootFolder.0.folders.0',
|
mongo: 'rootFolder.0.folders.0',
|
||||||
}
|
}
|
||||||
this.rootFolder = {
|
this.rootFolder = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
folders: [this.folder],
|
folders: [this.folder],
|
||||||
docs: [this.doc],
|
docs: [this.doc],
|
||||||
fileRefs: [this.file],
|
fileRefs: [this.file],
|
||||||
|
@ -62,7 +62,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
mongo: 'rootFolder.0',
|
mongo: 'rootFolder.0',
|
||||||
}
|
}
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'project name',
|
name: 'project name',
|
||||||
rootFolder: [this.rootFolder],
|
rootFolder: [this.rootFolder],
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('addDoc', function () {
|
describe('addDoc', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const doc = { _id: ObjectId(), name: 'other.txt' }
|
const doc = { _id: new ObjectId(), name: 'other.txt' }
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{
|
{
|
||||||
|
@ -261,7 +261,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('addFile', function () {
|
describe('addFile', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.newFile = { _id: ObjectId(), name: 'picture.jpg' }
|
this.newFile = { _id: new ObjectId(), name: 'picture.jpg' }
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{
|
{
|
||||||
|
@ -329,7 +329,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const folderName = 'New folder'
|
const folderName = 'New folder'
|
||||||
this.FolderModel.withArgs({ name: folderName }).returns({
|
this.FolderModel.withArgs({ name: folderName }).returns({
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: folderName,
|
name: folderName,
|
||||||
})
|
})
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
|
@ -364,7 +364,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
describe('replaceFileWithNew', function () {
|
describe('replaceFileWithNew', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const newFile = {
|
const newFile = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'some-other-file.png',
|
name: 'some-other-file.png',
|
||||||
linkedFileData: { some: 'data' },
|
linkedFileData: { some: 'data' },
|
||||||
hash: 'some-hash',
|
hash: 'some-hash',
|
||||||
|
@ -460,7 +460,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('when the path is a new folder at the top level', function () {
|
describe('when the path is a new folder at the top level', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.newFolder = { _id: ObjectId(), name: 'new-folder' }
|
this.newFolder = { _id: new ObjectId(), name: 'new-folder' }
|
||||||
this.FolderModel.returns(this.newFolder)
|
this.FolderModel.returns(this.newFolder)
|
||||||
this.exactCaseMatch = false
|
this.exactCaseMatch = false
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
|
@ -504,7 +504,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('adding a subfolder', function () {
|
describe('adding a subfolder', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.newFolder = { _id: ObjectId(), name: 'new-folder' }
|
this.newFolder = { _id: new ObjectId(), name: 'new-folder' }
|
||||||
this.FolderModel.returns(this.newFolder)
|
this.FolderModel.returns(this.newFolder)
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
|
@ -548,12 +548,12 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('when mutliple folders are missing', async function () {
|
describe('when mutliple folders are missing', async function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.folder1 = { _id: ObjectId(), name: 'folder1' }
|
this.folder1 = { _id: new ObjectId(), name: 'folder1' }
|
||||||
this.folder1Path = {
|
this.folder1Path = {
|
||||||
fileSystem: '/test-folder/folder1',
|
fileSystem: '/test-folder/folder1',
|
||||||
mongo: 'rootFolder.0.folders.0.folders.0',
|
mongo: 'rootFolder.0.folders.0.folders.0',
|
||||||
}
|
}
|
||||||
this.folder2 = { _id: ObjectId(), name: 'folder2' }
|
this.folder2 = { _id: new ObjectId(), name: 'folder2' }
|
||||||
this.folder2Path = {
|
this.folder2Path = {
|
||||||
fileSystem: '/test-folder/folder1/folder2',
|
fileSystem: '/test-folder/folder1/folder2',
|
||||||
mongo: 'rootFolder.0.folders.0.folders.0.folders.0',
|
mongo: 'rootFolder.0.folders.0.folders.0.folders.0',
|
||||||
|
@ -865,7 +865,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
describe('updating the project', function () {
|
describe('updating the project', function () {
|
||||||
describe('when the parent folder is given', function () {
|
describe('when the parent folder is given', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.newFile = { _id: ObjectId(), name: 'new file.png' }
|
this.newFile = { _id: new ObjectId(), name: 'new file.png' }
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{
|
{
|
||||||
|
@ -927,7 +927,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should error if element name contains invalid characters', async function () {
|
it('should error if element name contains invalid characters', async function () {
|
||||||
const file = { _id: ObjectId(), name: 'something*bad' }
|
const file = { _id: new ObjectId(), name: 'something*bad' }
|
||||||
await expect(
|
await expect(
|
||||||
this.subject.promises._putElement(
|
this.subject.promises._putElement(
|
||||||
this.project,
|
this.project,
|
||||||
|
@ -940,7 +940,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
it('should error if element name is too long', async function () {
|
it('should error if element name is too long', async function () {
|
||||||
const file = {
|
const file = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'long-'.repeat(1000) + 'something',
|
name: 'long-'.repeat(1000) + 'something',
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
|
@ -955,7 +955,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
it('should error if the folder name is too long', async function () {
|
it('should error if the folder name is too long', async function () {
|
||||||
const file = {
|
const file = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'something',
|
name: 'something',
|
||||||
}
|
}
|
||||||
this.ProjectLocator.promises.findElement
|
this.ProjectLocator.promises.findElement
|
||||||
|
@ -980,7 +980,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
;['file', 'doc', 'folder'].forEach(entityType => {
|
;['file', 'doc', 'folder'].forEach(entityType => {
|
||||||
it(`should error if a ${entityType} already exists with the same name`, async function () {
|
it(`should error if a ${entityType} already exists with the same name`, async function () {
|
||||||
const file = {
|
const file = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: this[entityType].name,
|
name: this[entityType].name,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
|
@ -998,7 +998,7 @@ describe('ProjectEntityMongoUpdateHandler', function () {
|
||||||
|
|
||||||
describe('when the parent folder is not given', function () {
|
describe('when the parent folder is not given', function () {
|
||||||
it('should default to root folder insert', async function () {
|
it('should default to root folder insert', async function () {
|
||||||
this.newFile = { _id: ObjectId(), name: 'new file.png' }
|
this.newFile = { _id: new ObjectId(), name: 'new file.png' }
|
||||||
this.ProjectMock.expects('findOneAndUpdate')
|
this.ProjectMock.expects('findOneAndUpdate')
|
||||||
.withArgs(
|
.withArgs(
|
||||||
{ _id: this.project._id, 'rootFolder.0': { $exists: true } },
|
{ _id: this.project._id, 'rootFolder.0': { $exists: true } },
|
||||||
|
|
|
@ -182,7 +182,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||||
this.ranges = { mock: 'ranges' }
|
this.ranges = { mock: 'ranges' }
|
||||||
this.lastUpdatedAt = new Date().getTime()
|
this.lastUpdatedAt = new Date().getTime()
|
||||||
this.lastUpdatedBy = 'fake-last-updater-id'
|
this.lastUpdatedBy = 'fake-last-updater-id'
|
||||||
this.parentFolder = { _id: ObjectId() }
|
this.parentFolder = { _id: new ObjectId() }
|
||||||
this.DocstoreManager.isDocDeleted.yields(null, false)
|
this.DocstoreManager.isDocDeleted.yields(null, false)
|
||||||
this.ProjectGetter.getProject.yields(null, this.project)
|
this.ProjectGetter.getProject.yields(null, this.project)
|
||||||
this.ProjectLocator.findElement.yields(
|
this.ProjectLocator.findElement.yields(
|
||||||
|
@ -1011,7 +1011,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||||
describe('updating an existing file', function () {
|
describe('updating an existing file', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.existingFile = { _id: fileId, name: this.fileName, rev: 1 }
|
this.existingFile = { _id: fileId, name: this.fileName, rev: 1 }
|
||||||
this.newFile = { _id: ObjectId(), name: this.fileName, rev: 3 }
|
this.newFile = { _id: new ObjectId(), name: this.fileName, rev: 3 }
|
||||||
this.folder = { _id: folderId, fileRefs: [this.existingFile], docs: [] }
|
this.folder = { _id: folderId, fileRefs: [this.existingFile], docs: [] }
|
||||||
this.ProjectLocator.findElement.yields(null, this.folder)
|
this.ProjectLocator.findElement.yields(null, this.folder)
|
||||||
this.newProject = 'new-project-stub'
|
this.newProject = 'new-project-stub'
|
||||||
|
@ -2634,7 +2634,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||||
describe('_cleanUpDoc', function () {
|
describe('_cleanUpDoc', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.doc = {
|
this.doc = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'test.tex',
|
name: 'test.tex',
|
||||||
}
|
}
|
||||||
this.path = '/path/to/doc'
|
this.path = '/path/to/doc'
|
||||||
|
@ -2679,7 +2679,7 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||||
|
|
||||||
describe('when the doc is not the root doc', function () {
|
describe('when the doc is not the root doc', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.project.rootDoc_id = ObjectId()
|
this.project.rootDoc_id = new ObjectId()
|
||||||
this.ProjectEntityUpdateHandler._cleanUpDoc(
|
this.ProjectEntityUpdateHandler._cleanUpDoc(
|
||||||
this.project,
|
this.project,
|
||||||
this.doc,
|
this.doc,
|
||||||
|
|
|
@ -47,8 +47,8 @@ describe('ProjectHelper', function () {
|
||||||
describe('project.archived being an array', function () {
|
describe('project.archived being an array', function () {
|
||||||
it('returns true if user id is found', function () {
|
it('returns true if user id is found', function () {
|
||||||
this.project.archived = [
|
this.project.archived = [
|
||||||
ObjectId('588f3ddae8ebc1bac07c9fa4'),
|
new ObjectId('588f3ddae8ebc1bac07c9fa4'),
|
||||||
ObjectId('5c41deb2b4ca500153340809'),
|
new ObjectId('5c41deb2b4ca500153340809'),
|
||||||
]
|
]
|
||||||
expect(
|
expect(
|
||||||
this.ProjectHelper.isArchived(this.project, this.user._id)
|
this.ProjectHelper.isArchived(this.project, this.user._id)
|
||||||
|
@ -76,8 +76,8 @@ describe('ProjectHelper', function () {
|
||||||
describe('isTrashed', function () {
|
describe('isTrashed', function () {
|
||||||
it('returns true if user id is found', function () {
|
it('returns true if user id is found', function () {
|
||||||
this.project.trashed = [
|
this.project.trashed = [
|
||||||
ObjectId('588f3ddae8ebc1bac07c9fa4'),
|
new ObjectId('588f3ddae8ebc1bac07c9fa4'),
|
||||||
ObjectId('5c41deb2b4ca500153340809'),
|
new ObjectId('5c41deb2b4ca500153340809'),
|
||||||
]
|
]
|
||||||
expect(
|
expect(
|
||||||
this.ProjectHelper.isTrashed(this.project, this.user._id)
|
this.ProjectHelper.isTrashed(this.project, this.user._id)
|
||||||
|
@ -107,17 +107,17 @@ describe('ProjectHelper', function () {
|
||||||
const project = { archived: [] }
|
const project = { archived: [] }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'ARCHIVE'
|
'ARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([ObjectId('5c922599cdb09e014aa7d499')])
|
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an array without the current user id when unarchiving', function () {
|
it('returns an array without the current user id when unarchiving', function () {
|
||||||
const project = { archived: [ObjectId('5c922599cdb09e014aa7d499')] }
|
const project = { archived: [new ObjectId('5c922599cdb09e014aa7d499')] }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'UNARCHIVE'
|
'UNARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([])
|
expect(result).to.deep.equal([])
|
||||||
|
@ -130,11 +130,13 @@ describe('ProjectHelper', function () {
|
||||||
archived: true,
|
archived: true,
|
||||||
owner_ref: this.user._id,
|
owner_ref: this.user._id,
|
||||||
collaberator_refs: [
|
collaberator_refs: [
|
||||||
ObjectId('4f2cfb341eb5855a5b000f8b'),
|
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||||
ObjectId('5c45f3bd425ead01488675aa'),
|
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||||
|
],
|
||||||
|
readOnly_refs: [new ObjectId('5c92243fcdb09e014aa7d487')],
|
||||||
|
tokenAccessReadAndWrite_refs: [
|
||||||
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
],
|
],
|
||||||
readOnly_refs: [ObjectId('5c92243fcdb09e014aa7d487')],
|
|
||||||
tokenAccessReadAndWrite_refs: [ObjectId('5c922599cdb09e014aa7d499')],
|
|
||||||
tokenAccessReadOnly_refs: [],
|
tokenAccessReadOnly_refs: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,10 +147,10 @@ describe('ProjectHelper', function () {
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([
|
expect(result).to.deep.equal([
|
||||||
this.user._id,
|
this.user._id,
|
||||||
ObjectId('4f2cfb341eb5855a5b000f8b'),
|
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||||
ObjectId('5c45f3bd425ead01488675aa'),
|
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||||
ObjectId('5c92243fcdb09e014aa7d487'),
|
new ObjectId('5c92243fcdb09e014aa7d487'),
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -157,12 +159,14 @@ describe('ProjectHelper', function () {
|
||||||
archived: true,
|
archived: true,
|
||||||
owner_ref: this.user._id,
|
owner_ref: this.user._id,
|
||||||
collaberator_refs: [
|
collaberator_refs: [
|
||||||
ObjectId('4f2cfb341eb5855a5b000f8b'),
|
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||||
ObjectId('5c45f3bd425ead01488675aa'),
|
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
|
],
|
||||||
|
readOnly_refs: [new ObjectId('5c92243fcdb09e014aa7d487')],
|
||||||
|
tokenAccessReadAndWrite_refs: [
|
||||||
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
],
|
],
|
||||||
readOnly_refs: [ObjectId('5c92243fcdb09e014aa7d487')],
|
|
||||||
tokenAccessReadAndWrite_refs: [ObjectId('5c922599cdb09e014aa7d499')],
|
|
||||||
tokenAccessReadOnly_refs: [],
|
tokenAccessReadOnly_refs: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,10 +176,10 @@ describe('ProjectHelper', function () {
|
||||||
'UNARCHIVE'
|
'UNARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([
|
expect(result).to.deep.equal([
|
||||||
ObjectId('4f2cfb341eb5855a5b000f8b'),
|
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||||
ObjectId('5c45f3bd425ead01488675aa'),
|
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
ObjectId('5c92243fcdb09e014aa7d487'),
|
new ObjectId('5c92243fcdb09e014aa7d487'),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -185,17 +189,17 @@ describe('ProjectHelper', function () {
|
||||||
const project = { archived: false }
|
const project = { archived: false }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'ARCHIVE'
|
'ARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([ObjectId('5c922599cdb09e014aa7d499')])
|
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an empty array when unarchiving', function () {
|
it('returns an empty array when unarchiving', function () {
|
||||||
const project = { archived: false }
|
const project = { archived: false }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'UNARCHIVE'
|
'UNARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([])
|
expect(result).to.deep.equal([])
|
||||||
|
@ -207,17 +211,17 @@ describe('ProjectHelper', function () {
|
||||||
const project = { archived: undefined }
|
const project = { archived: undefined }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'ARCHIVE'
|
'ARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([ObjectId('5c922599cdb09e014aa7d499')])
|
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an empty array when unarchiving', function () {
|
it('returns an empty array when unarchiving', function () {
|
||||||
const project = { archived: undefined }
|
const project = { archived: undefined }
|
||||||
const result = this.ProjectHelper.calculateArchivedArray(
|
const result = this.ProjectHelper.calculateArchivedArray(
|
||||||
project,
|
project,
|
||||||
ObjectId('5c922599cdb09e014aa7d499'),
|
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||||
'UNARCHIVE'
|
'UNARCHIVE'
|
||||||
)
|
)
|
||||||
expect(result).to.deep.equal([])
|
expect(result).to.deep.equal([])
|
||||||
|
|
|
@ -12,10 +12,10 @@ const MODULE_PATH = path.join(
|
||||||
|
|
||||||
describe('ProjectListController', function () {
|
describe('ProjectListController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.project_id = ObjectId('abcdefabcdefabcdefabcdef')
|
this.project_id = new ObjectId('abcdefabcdefabcdefabcdef')
|
||||||
|
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId('123456123456123456123456'),
|
_id: new ObjectId('123456123456123456123456'),
|
||||||
email: 'test@overleaf.com',
|
email: 'test@overleaf.com',
|
||||||
first_name: 'bjkdsjfk',
|
first_name: 'bjkdsjfk',
|
||||||
features: {},
|
features: {},
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe('SplitTestHandler', function () {
|
||||||
describe('with an existing user', function () {
|
describe('with an existing user', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
splitTests: {
|
splitTests: {
|
||||||
'active-test': [
|
'active-test': [
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ describe('SplitTestHandler', function () {
|
||||||
|
|
||||||
describe('with an non-existent user', function () {
|
describe('with an non-existent user', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const unknownUserId = ObjectId()
|
const unknownUserId = new ObjectId()
|
||||||
this.assignments =
|
this.assignments =
|
||||||
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
||||||
unknownUserId
|
unknownUserId
|
||||||
|
@ -163,7 +163,7 @@ describe('SplitTestHandler', function () {
|
||||||
|
|
||||||
describe('with a user without assignments', function () {
|
describe('with a user without assignments', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.user = { _id: ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
this.UserGetter.promises.getUser
|
this.UserGetter.promises.getUser
|
||||||
.withArgs(this.user._id)
|
.withArgs(this.user._id)
|
||||||
.resolves(this.user)
|
.resolves(this.user)
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('GroupSSOHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: new ObjectId(), enrollment: { sso: [] } }
|
this.user = { _id: new ObjectId(), enrollment: { sso: [] } }
|
||||||
this.subscription = {
|
this.subscription = {
|
||||||
_id: ObjectId().toString(),
|
_id: new ObjectId().toString(),
|
||||||
admin_id: new ObjectId(),
|
admin_id: new ObjectId(),
|
||||||
member_ids: [this.user._id],
|
member_ids: [this.user._id],
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,12 +181,12 @@ describe('SubscriptionUpdater', function () {
|
||||||
this.otherUserId
|
this.otherUserId
|
||||||
)
|
)
|
||||||
const query = {
|
const query = {
|
||||||
_id: ObjectId(this.subscription._id),
|
_id: new ObjectId(this.subscription._id),
|
||||||
customAccount: true,
|
customAccount: true,
|
||||||
}
|
}
|
||||||
const update = {
|
const update = {
|
||||||
$set: { admin_id: ObjectId(this.otherUserId) },
|
$set: { admin_id: new ObjectId(this.otherUserId) },
|
||||||
$addToSet: { manager_ids: ObjectId(this.otherUserId) },
|
$addToSet: { manager_ids: new ObjectId(this.otherUserId) },
|
||||||
}
|
}
|
||||||
this.SubscriptionModel.updateOne.should.have.been.calledOnce
|
this.SubscriptionModel.updateOne.should.have.been.calledOnce
|
||||||
this.SubscriptionModel.updateOne.should.have.been.calledWith(
|
this.SubscriptionModel.updateOne.should.have.been.calledWith(
|
||||||
|
@ -201,13 +201,13 @@ describe('SubscriptionUpdater', function () {
|
||||||
this.otherUserId
|
this.otherUserId
|
||||||
)
|
)
|
||||||
const query = {
|
const query = {
|
||||||
_id: ObjectId(this.subscription._id),
|
_id: new ObjectId(this.subscription._id),
|
||||||
customAccount: true,
|
customAccount: true,
|
||||||
}
|
}
|
||||||
const update = {
|
const update = {
|
||||||
$set: {
|
$set: {
|
||||||
admin_id: ObjectId(this.otherUserId),
|
admin_id: new ObjectId(this.otherUserId),
|
||||||
manager_ids: [ObjectId(this.otherUserId)],
|
manager_ids: [new ObjectId(this.otherUserId)],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.SubscriptionModel.updateOne.should.have.been.calledOnce
|
this.SubscriptionModel.updateOne.should.have.been.calledOnce
|
||||||
|
@ -710,10 +710,10 @@ describe('SubscriptionUpdater', function () {
|
||||||
describe('deleteSubscription', function () {
|
describe('deleteSubscription', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.subscription = {
|
this.subscription = {
|
||||||
_id: ObjectId().toString(),
|
_id: new ObjectId().toString(),
|
||||||
mock: 'subscription',
|
mock: 'subscription',
|
||||||
admin_id: ObjectId(),
|
admin_id: new ObjectId(),
|
||||||
member_ids: [ObjectId(), ObjectId(), ObjectId()],
|
member_ids: [new ObjectId(), new ObjectId(), new ObjectId()],
|
||||||
}
|
}
|
||||||
await this.SubscriptionUpdater.promises.deleteSubscription(
|
await this.SubscriptionUpdater.promises.deleteSubscription(
|
||||||
this.subscription,
|
this.subscription,
|
||||||
|
|
|
@ -10,13 +10,13 @@ const modulePath = require('path').join(
|
||||||
|
|
||||||
describe('TagsHandler', function () {
|
describe('TagsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.userId = ObjectId().toString()
|
this.userId = new ObjectId().toString()
|
||||||
this.callback = sinon.stub()
|
this.callback = sinon.stub()
|
||||||
|
|
||||||
this.tag = { user_id: this.userId, name: 'some name', color: '#3399CC' }
|
this.tag = { user_id: this.userId, name: 'some name', color: '#3399CC' }
|
||||||
this.tagId = ObjectId().toString()
|
this.tagId = new ObjectId().toString()
|
||||||
this.projectId = ObjectId().toString()
|
this.projectId = new ObjectId().toString()
|
||||||
this.projectIds = [ObjectId().toString(), ObjectId().toString()]
|
this.projectIds = [new ObjectId().toString(), new ObjectId().toString()]
|
||||||
|
|
||||||
this.mongodb = { ObjectId }
|
this.mongodb = { ObjectId }
|
||||||
this.TagMock = sinon.mock(Tag)
|
this.TagMock = sinon.mock(Tag)
|
||||||
|
|
|
@ -12,9 +12,9 @@ const MODULE_PATH =
|
||||||
describe('TpdsController', function () {
|
describe('TpdsController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.metadata = {
|
this.metadata = {
|
||||||
projectId: ObjectId(),
|
projectId: new ObjectId(),
|
||||||
entityId: ObjectId(),
|
entityId: new ObjectId(),
|
||||||
folderId: ObjectId(),
|
folderId: new ObjectId(),
|
||||||
entityType: 'doc',
|
entityType: 'doc',
|
||||||
rev: 2,
|
rev: 2,
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ describe('TpdsController', function () {
|
||||||
conflict: sinon.stub(),
|
conflict: sinon.stub(),
|
||||||
}
|
}
|
||||||
|
|
||||||
this.newProject = { _id: ObjectId() }
|
this.newProject = { _id: new ObjectId() }
|
||||||
this.ProjectCreationHandler = {
|
this.ProjectCreationHandler = {
|
||||||
promises: { createBlankProject: sinon.stub().resolves(this.newProject) },
|
promises: { createBlankProject: sinon.stub().resolves(this.newProject) },
|
||||||
}
|
}
|
||||||
|
@ -291,10 +291,10 @@ describe('TpdsController', function () {
|
||||||
|
|
||||||
it("creates a folder if it doesn't exist", function (done) {
|
it("creates a folder if it doesn't exist", function (done) {
|
||||||
const metadata = {
|
const metadata = {
|
||||||
folderId: ObjectId(),
|
folderId: new ObjectId(),
|
||||||
projectId: ObjectId(),
|
projectId: new ObjectId(),
|
||||||
path: '/def/ghi.txt',
|
path: '/def/ghi.txt',
|
||||||
parentFolderId: ObjectId(),
|
parentFolderId: new ObjectId(),
|
||||||
}
|
}
|
||||||
this.TpdsUpdateHandler.promises.createFolder.resolves(metadata)
|
this.TpdsUpdateHandler.promises.createFolder.resolves(metadata)
|
||||||
this.res.json.callsFake(body => {
|
this.res.json.callsFake(body => {
|
||||||
|
@ -311,8 +311,8 @@ describe('TpdsController', function () {
|
||||||
|
|
||||||
it('supports top level folders', function (done) {
|
it('supports top level folders', function (done) {
|
||||||
const metadata = {
|
const metadata = {
|
||||||
folderId: ObjectId(),
|
folderId: new ObjectId(),
|
||||||
projectId: ObjectId(),
|
projectId: new ObjectId(),
|
||||||
path: '/',
|
path: '/',
|
||||||
parentFolderId: null,
|
parentFolderId: null,
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ const MODULE_PATH =
|
||||||
|
|
||||||
describe('TpdsProjectFlusher', function () {
|
describe('TpdsProjectFlusher', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.project = { _id: ObjectId() }
|
this.project = { _id: new ObjectId() }
|
||||||
this.folder = { _id: ObjectId() }
|
this.folder = { _id: new ObjectId() }
|
||||||
this.docs = {
|
this.docs = {
|
||||||
'/doc/one': {
|
'/doc/one': {
|
||||||
_id: 'mock-doc-1',
|
_id: 'mock-doc-1',
|
||||||
|
|
|
@ -38,8 +38,8 @@ describe('TpdsUpdateHandler', function () {
|
||||||
this.update = {}
|
this.update = {}
|
||||||
this.folderPath = '/some/folder'
|
this.folderPath = '/some/folder'
|
||||||
this.folder = {
|
this.folder = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
parentFolder_id: ObjectId(),
|
parentFolder_id: new ObjectId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
this.CooldownManager = {
|
this.CooldownManager = {
|
||||||
|
@ -125,7 +125,7 @@ describe('TpdsUpdateHandler', function () {
|
||||||
describe('byId', function () {
|
describe('byId', function () {
|
||||||
describe('with no matching project', function () {
|
describe('with no matching project', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.projectId = ObjectId().toString()
|
this.projectId = new ObjectId().toString()
|
||||||
})
|
})
|
||||||
receiveUpdateById()
|
receiveUpdateById()
|
||||||
expectProjectNotCreated()
|
expectProjectNotCreated()
|
||||||
|
@ -222,7 +222,7 @@ describe('TpdsUpdateHandler', function () {
|
||||||
describe('byId', function () {
|
describe('byId', function () {
|
||||||
describe('with no matching project', function () {
|
describe('with no matching project', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.projectId = ObjectId().toString()
|
this.projectId = new ObjectId().toString()
|
||||||
})
|
})
|
||||||
receiveFileDeleteById()
|
receiveFileDeleteById()
|
||||||
expectDeleteNotProcessed()
|
expectDeleteNotProcessed()
|
||||||
|
|
|
@ -10,9 +10,9 @@ const modulePath = path.join(
|
||||||
)
|
)
|
||||||
|
|
||||||
const projectId = 'project_id_here'
|
const projectId = 'project_id_here'
|
||||||
const userId = ObjectId()
|
const userId = new ObjectId()
|
||||||
const readOnlyRef = ObjectId()
|
const readOnlyRef = new ObjectId()
|
||||||
const collaberatorRef = ObjectId()
|
const collaberatorRef = new ObjectId()
|
||||||
const projectName = 'project_name_here'
|
const projectName = 'project_name_here'
|
||||||
|
|
||||||
const thirdPartyDataStoreApiUrl = 'http://third-party-json-store.herokuapp.com'
|
const thirdPartyDataStoreApiUrl = 'http://third-party-json-store.herokuapp.com'
|
||||||
|
|
|
@ -48,17 +48,17 @@ describe('UpdateMerger :', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doc = {
|
this.doc = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
rev: 2,
|
rev: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.file = {
|
this.file = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
rev: 6,
|
rev: 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.folder = {
|
this.folder = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
this.EditorController = {
|
this.EditorController = {
|
||||||
|
|
|
@ -12,9 +12,9 @@ const MODULE_PATH =
|
||||||
describe('TokenAccessController', function () {
|
describe('TokenAccessController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.token = 'abc123'
|
this.token = 'abc123'
|
||||||
this.user = { _id: ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
tokenAccessReadAndWrite_refs: [],
|
tokenAccessReadAndWrite_refs: [],
|
||||||
tokenAccessReadOnly_refs: [],
|
tokenAccessReadOnly_refs: [],
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ const { ObjectId } = require('mongodb')
|
||||||
describe('TokenAccessHandler', function () {
|
describe('TokenAccessHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.token = 'abcdefabcdef'
|
this.token = 'abcdefabcdef'
|
||||||
this.projectId = ObjectId()
|
this.projectId = new ObjectId()
|
||||||
this.project = {
|
this.project = {
|
||||||
_id: this.projectId,
|
_id: this.projectId,
|
||||||
publicAccesLevel: 'tokenBased',
|
publicAccesLevel: 'tokenBased',
|
||||||
owner_ref: ObjectId(),
|
owner_ref: new ObjectId(),
|
||||||
}
|
}
|
||||||
this.userId = ObjectId()
|
this.userId = new ObjectId()
|
||||||
this.req = {}
|
this.req = {}
|
||||||
this.TokenAccessHandler = SandboxedModule.require(modulePath, {
|
this.TokenAccessHandler = SandboxedModule.require(modulePath, {
|
||||||
requires: {
|
requires: {
|
||||||
|
|
|
@ -370,7 +370,7 @@ describe('SAMLIdentityManager', function () {
|
||||||
expect(
|
expect(
|
||||||
this.UserGetter.promises.getUser
|
this.UserGetter.promises.getUser
|
||||||
).to.have.been.calledWithMatch({
|
).to.have.been.calledWithMatch({
|
||||||
_id: ObjectId('6005c75b12cbcaf771f4a105'),
|
_id: new ObjectId('6005c75b12cbcaf771f4a105'),
|
||||||
'samlIdentifiers.providerId': '123456',
|
'samlIdentifiers.providerId': '123456',
|
||||||
})
|
})
|
||||||
expect(error).to.be.instanceof(Errors.SAMLAlreadyLinkedError)
|
expect(error).to.be.instanceof(Errors.SAMLAlreadyLinkedError)
|
||||||
|
|
|
@ -8,8 +8,8 @@ const MODULE_PATH = '../../../../app/src/Features/User/UserAuditLogHandler'
|
||||||
|
|
||||||
describe('UserAuditLogHandler', function () {
|
describe('UserAuditLogHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.userId = ObjectId()
|
this.userId = new ObjectId()
|
||||||
this.initiatorId = ObjectId()
|
this.initiatorId = new ObjectId()
|
||||||
this.action = {
|
this.action = {
|
||||||
operation: 'clear-sessions',
|
operation: 'clear-sessions',
|
||||||
initiatorId: this.initiatorId,
|
initiatorId: this.initiatorId,
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('UserDeleter', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
tk.freeze(Date.now())
|
tk.freeze(Date.now())
|
||||||
|
|
||||||
this.userId = ObjectId()
|
this.userId = new ObjectId()
|
||||||
|
|
||||||
this.UserMock = sinon.mock(User)
|
this.UserMock = sinon.mock(User)
|
||||||
this.DeletedUserMock = sinon.mock(DeletedUser)
|
this.DeletedUserMock = sinon.mock(DeletedUser)
|
||||||
|
@ -289,7 +289,7 @@ describe('UserDeleter', function () {
|
||||||
describe('when a user and IP address are specified', function () {
|
describe('when a user and IP address are specified', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.ipAddress = '1.2.3.4'
|
this.ipAddress = '1.2.3.4'
|
||||||
this.deleterId = ObjectId()
|
this.deleterId = new ObjectId()
|
||||||
|
|
||||||
this.deletedUser.deleterData.deleterIpAddress = this.ipAddress
|
this.deletedUser.deleterData.deleterIpAddress = this.ipAddress
|
||||||
this.deletedUser.deleterData.deleterId = this.deleterId
|
this.deletedUser.deleterData.deleterId = this.deleterId
|
||||||
|
|
|
@ -32,8 +32,8 @@ describe('UserInfoController', function () {
|
||||||
describe('getPersonalInfo', function () {
|
describe('getPersonalInfo', function () {
|
||||||
describe('when the user exists with sharelatex id', function () {
|
describe('when the user exists with sharelatex id', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = new ObjectId().toString()
|
||||||
this.user = { _id: ObjectId(this.user_id) }
|
this.user = { _id: new ObjectId(this.user_id) }
|
||||||
this.req.params = { user_id: this.user_id }
|
this.req.params = { user_id: this.user_id }
|
||||||
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, this.user)
|
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, this.user)
|
||||||
this.UserInfoController.sendFormattedPersonalInfo = sinon.stub()
|
this.UserInfoController.sendFormattedPersonalInfo = sinon.stub()
|
||||||
|
@ -43,7 +43,7 @@ describe('UserInfoController', function () {
|
||||||
it('should look up the user in the database', function () {
|
it('should look up the user in the database', function () {
|
||||||
this.UserGetter.getUser
|
this.UserGetter.getUser
|
||||||
.calledWith(
|
.calledWith(
|
||||||
{ _id: ObjectId(this.user_id) },
|
{ _id: new ObjectId(this.user_id) },
|
||||||
{ _id: true, first_name: true, last_name: true, email: true }
|
{ _id: true, first_name: true, last_name: true, email: true }
|
||||||
)
|
)
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
@ -54,7 +54,7 @@ describe('UserInfoController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user_id = 12345
|
this.user_id = 12345
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
overleaf: {
|
overleaf: {
|
||||||
id: this.user_id,
|
id: this.user_id,
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ describe('UserInfoController', function () {
|
||||||
|
|
||||||
describe('when the user does not exist', function () {
|
describe('when the user does not exist', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = new ObjectId().toString()
|
||||||
this.req.params = { user_id: this.user_id }
|
this.req.params = { user_id: this.user_id }
|
||||||
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, null)
|
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, null)
|
||||||
this.UserInfoController.getPersonalInfo(this.req, this.res, this.next)
|
this.UserInfoController.getPersonalInfo(this.req, this.res, this.next)
|
||||||
|
@ -104,7 +104,7 @@ describe('UserInfoController', function () {
|
||||||
describe('sendFormattedPersonalInfo', function () {
|
describe('sendFormattedPersonalInfo', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
first_name: 'Douglas',
|
first_name: 'Douglas',
|
||||||
last_name: 'Adams',
|
last_name: 'Adams',
|
||||||
email: 'doug@sharelatex.com',
|
email: 'doug@sharelatex.com',
|
||||||
|
@ -126,7 +126,7 @@ describe('UserInfoController', function () {
|
||||||
describe('formatPersonalInfo', function () {
|
describe('formatPersonalInfo', function () {
|
||||||
it('should return the correctly formatted data', function () {
|
it('should return the correctly formatted data', function () {
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
first_name: 'Douglas',
|
first_name: 'Douglas',
|
||||||
last_name: 'Adams',
|
last_name: 'Adams',
|
||||||
email: 'doug@sharelatex.com',
|
email: 'doug@sharelatex.com',
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('UserUpdater', function () {
|
||||||
tk.freeze(Date.now())
|
tk.freeze(Date.now())
|
||||||
|
|
||||||
this.user = {
|
this.user = {
|
||||||
_id: ObjectId(),
|
_id: new ObjectId(),
|
||||||
name: 'bob',
|
name: 'bob',
|
||||||
email: 'hello@world.com',
|
email: 'hello@world.com',
|
||||||
emails: [{ email: 'hello@world.com' }],
|
emails: [{ email: 'hello@world.com' }],
|
||||||
|
@ -31,9 +31,7 @@ describe('UserUpdater', function () {
|
||||||
}
|
}
|
||||||
this.mongodb = {
|
this.mongodb = {
|
||||||
db: this.db,
|
db: this.db,
|
||||||
ObjectId(id) {
|
ObjectId,
|
||||||
return id
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.UserGetter = {
|
this.UserGetter = {
|
||||||
|
|
|
@ -27,15 +27,15 @@ const {
|
||||||
|
|
||||||
describe('UserMembershipHandler', function () {
|
describe('UserMembershipHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
this.newUser = { _id: ObjectId(), email: 'new-user-email@foo.bar' }
|
this.newUser = { _id: new ObjectId(), email: 'new-user-email@foo.bar' }
|
||||||
this.fakeEntityId = ObjectId()
|
this.fakeEntityId = new ObjectId()
|
||||||
this.subscription = {
|
this.subscription = {
|
||||||
_id: 'mock-subscription-id',
|
_id: 'mock-subscription-id',
|
||||||
groupPlan: true,
|
groupPlan: true,
|
||||||
membersLimit: 10,
|
membersLimit: 10,
|
||||||
member_ids: [ObjectId(), ObjectId()],
|
member_ids: [new ObjectId(), new ObjectId()],
|
||||||
manager_ids: [ObjectId()],
|
manager_ids: [new ObjectId()],
|
||||||
invited_emails: ['mock-email-1@foo.com'],
|
invited_emails: ['mock-email-1@foo.com'],
|
||||||
teamInvites: [{ email: 'mock-email-1@bar.com' }],
|
teamInvites: [{ email: 'mock-email-1@bar.com' }],
|
||||||
update: sinon.stub().yields(null),
|
update: sinon.stub().yields(null),
|
||||||
|
@ -43,13 +43,13 @@ describe('UserMembershipHandler', function () {
|
||||||
this.institution = {
|
this.institution = {
|
||||||
_id: 'mock-institution-id',
|
_id: 'mock-institution-id',
|
||||||
v1Id: 123,
|
v1Id: 123,
|
||||||
managerIds: [ObjectId(), ObjectId(), ObjectId()],
|
managerIds: [new ObjectId(), new ObjectId(), new ObjectId()],
|
||||||
updateOne: sinon.stub().yields(null),
|
updateOne: sinon.stub().yields(null),
|
||||||
}
|
}
|
||||||
this.publisher = {
|
this.publisher = {
|
||||||
_id: 'mock-publisher-id',
|
_id: 'mock-publisher-id',
|
||||||
slug: 'slug',
|
slug: 'slug',
|
||||||
managerIds: [ObjectId(), ObjectId()],
|
managerIds: [new ObjectId(), new ObjectId()],
|
||||||
updateOne: sinon.stub().yields(null),
|
updateOne: sinon.stub().yields(null),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ describe('UserMembershipViewModel', function () {
|
||||||
it('build user id', function (done) {
|
it('build user id', function (done) {
|
||||||
this.UserGetter.getUser.yields(null, this.user)
|
this.UserGetter.getUser.yields(null, this.user)
|
||||||
return this.UserMembershipViewModel.buildAsync(
|
return this.UserMembershipViewModel.buildAsync(
|
||||||
ObjectId(),
|
new ObjectId(),
|
||||||
(error, viewModel) => {
|
(error, viewModel) => {
|
||||||
expect(error).not.to.exist
|
expect(error).not.to.exist
|
||||||
assertNotCalled(this.UserMembershipViewModel.build)
|
assertNotCalled(this.UserMembershipViewModel.build)
|
||||||
|
@ -127,7 +127,7 @@ describe('UserMembershipViewModel', function () {
|
||||||
|
|
||||||
it('build user id with error', function (done) {
|
it('build user id with error', function (done) {
|
||||||
this.UserGetter.getUser.yields(new Error('nope'))
|
this.UserGetter.getUser.yields(new Error('nope'))
|
||||||
const userId = ObjectId()
|
const userId = new ObjectId()
|
||||||
return this.UserMembershipViewModel.buildAsync(
|
return this.UserMembershipViewModel.buildAsync(
|
||||||
userId,
|
userId,
|
||||||
(error, viewModel) => {
|
(error, viewModel) => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ const SandboxedModule = require('sandboxed-module')
|
||||||
|
|
||||||
describe('UserMembershipsHandler', function () {
|
describe('UserMembershipsHandler', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.user = { _id: ObjectId() }
|
this.user = { _id: new ObjectId() }
|
||||||
|
|
||||||
this.Institution = { updateMany: sinon.stub().yields(null) }
|
this.Institution = { updateMany: sinon.stub().yields(null) }
|
||||||
this.Subscription = { updateMany: sinon.stub().yields(null) }
|
this.Subscription = { updateMany: sinon.stub().yields(null) }
|
||||||
|
|
Loading…
Reference in a new issue