Files
overleaf-cep/server-ce/test/helpers/config.ts
T
Brian Gough f5dbbadf79 add option to disable link sharing (#27626)
* add option to remove link-sharing from backend

* restrict make link-sharing in the frontend based on capability

* extend e2e project-sharing tests to cover OVERLEAF_DISABLE_LINK_SHARING=true

* throw an error when link sharing is disabled in TokenAccessHandler

* throw errors when attempting to add users to projects with link sharing disabled

* Update server-ce/test/project-sharing.spec.ts

Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>

* add tests for existing access when link sharing is disabled

* update tests to specify access restrictions for read-only and read-write link shared projects

* [web] block access to legacy public project with link-sharing disabled

---------

Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
GitOrigin-RevId: 5f194dbcb790e973e427c58a3a4a738a5dd74cb4
2025-08-20 08:05:33 +00:00

112 lines
2.4 KiB
TypeScript

import { reconfigure } from './hostAdminClient'
import { resetActivateUserRateLimit, resetCreatedUsersCache } from './login'
export const STARTUP_TIMEOUT =
parseInt(Cypress.env('STARTUP_TIMEOUT'), 10) || 120_000
export function isExcludedBySharding(
shard:
| 'LOCAL_ONLY'
| 'CE_DEFAULT'
| 'CE_CUSTOM_1'
| 'PRO_DEFAULT_1'
| 'PRO_DEFAULT_2'
| 'PRO_CUSTOM_1'
| 'PRO_CUSTOM_2'
| 'PRO_CUSTOM_3'
| 'PRO_CUSTOM_4'
) {
const SHARD = Cypress.env('SHARD')
return SHARD && shard !== SHARD
}
let previousConfigFrontend: string
export function startWith({
pro = false,
version = 'latest',
vars = {},
varsFn = () => ({}),
withDataDir = false,
resetData = false,
mongoVersion = '',
}) {
before(async function () {
Object.assign(vars, varsFn())
const cfg = JSON.stringify({
pro,
version,
vars,
withDataDir,
resetData,
mongoVersion,
})
if (resetData) {
cy.log('resetting data and sessions')
resetCreatedUsersCache()
resetActivateUserRateLimit()
// no return here, always reconfigure when resetting data
} else if (previousConfigFrontend === cfg) {
cy.log(`already running with ${cfg}`)
return
}
cy.log(`starting with ${cfg}`)
this.timeout(STARTUP_TIMEOUT)
const { previousConfigServer } = await reconfigure({
pro,
version,
vars,
withDataDir,
resetData,
mongoVersion,
})
if (previousConfigServer !== cfg) {
await Cypress.session.clearAllSavedSessions()
}
previousConfigFrontend = cfg
})
}
// Allow reloading the server in other places, e.g. beforeEach hooks.
export async function reloadWith({
pro = false,
version = 'latest',
vars = {},
varsFn = () => ({}),
withDataDir = false,
resetData = false,
mongoVersion = '',
}) {
Object.assign(vars, varsFn())
const cfg = JSON.stringify({
pro,
version,
vars,
withDataDir,
resetData,
mongoVersion,
})
if (resetData) {
resetCreatedUsersCache()
resetActivateUserRateLimit()
// no return here, always reconfigure when resetting data
} else if (previousConfigFrontend === cfg) {
return
}
const { previousConfigServer } = await reconfigure({
pro,
version,
vars,
withDataDir,
resetData,
mongoVersion,
})
if (previousConfigServer !== cfg) {
await Cypress.session.clearAllSavedSessions()
}
previousConfigFrontend = cfg
}
export { reconfigure }