mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4885 from overleaf/bg-filestore-delete-project
extend filestore project deletion acceptance tests GitOrigin-RevId: 0433817eee88a7465ab90034043398a6f6736bc0
This commit is contained in:
parent
d4563c8786
commit
18192e4559
2 changed files with 35 additions and 4 deletions
2
services/filestore/package-lock.json
generated
2
services/filestore/package-lock.json
generated
|
@ -1079,7 +1079,7 @@
|
|||
"integrity": "sha512-LsM2s6Iy9G97ktPo0ys4VxtI/m3ahc1ZHwjo5XnhXtjeIkkkVAehsrcRRoV/yWepPjymB0oZonhcfojpjYR/tg=="
|
||||
},
|
||||
"@overleaf/object-persistor": {
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@overleaf/object-persistor/-/object-persistor-1.0.1.tgz",
|
||||
"integrity": "sha512-8yGsmPIeeFqsfXKdKdW1CWQ60mr3Wfoc/HBPl36gKspjehvDKuOrhEnSRxmE5GBZacK3wvW4JloVaUV0RiAKfA==",
|
||||
"requires": {
|
||||
|
|
|
@ -81,7 +81,12 @@ describe('Filestore', function () {
|
|||
// redefine the test suite for every available backend
|
||||
Object.keys(BackendSettings).forEach(backend => {
|
||||
describe(backend, function () {
|
||||
let app, previousEgress, previousIngress, metricPrefix, projectId
|
||||
let app,
|
||||
previousEgress,
|
||||
previousIngress,
|
||||
metricPrefix,
|
||||
projectId,
|
||||
otherProjectId
|
||||
|
||||
before(async function () {
|
||||
// create the app with the relevant filestore settings
|
||||
|
@ -123,6 +128,7 @@ describe('Filestore', function () {
|
|||
)
|
||||
}
|
||||
projectId = ObjectId().toString()
|
||||
otherProjectId = ObjectId().toString()
|
||||
})
|
||||
|
||||
it('should send a 200 for the status endpoint', async function () {
|
||||
|
@ -302,10 +308,11 @@ describe('Filestore', function () {
|
|||
})
|
||||
|
||||
describe('with multiple files', function () {
|
||||
let fileIds, fileUrls, projectUrl
|
||||
let fileIds, fileUrls, otherFileUrls, projectUrl, otherProjectUrl
|
||||
const localFileReadPaths = [
|
||||
'/tmp/filestore_acceptance_tests_file_read_1.txt',
|
||||
'/tmp/filestore_acceptance_tests_file_read_2.txt',
|
||||
'/tmp/filestore_acceptance_tests_file_read_3.txt',
|
||||
]
|
||||
const constantFileContents = [
|
||||
[
|
||||
|
@ -318,39 +325,55 @@ describe('Filestore', function () {
|
|||
'cats are the best animals',
|
||||
'wombats are a close second',
|
||||
].join('\n'),
|
||||
[
|
||||
`another file: ${Math.random()}`,
|
||||
'with multiple lines',
|
||||
'the end',
|
||||
].join('\n'),
|
||||
]
|
||||
|
||||
before(async function () {
|
||||
return Promise.all([
|
||||
fsWriteFile(localFileReadPaths[0], constantFileContents[0]),
|
||||
fsWriteFile(localFileReadPaths[1], constantFileContents[1]),
|
||||
fsWriteFile(localFileReadPaths[2], constantFileContents[2]),
|
||||
])
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
projectUrl = `${filestoreUrl}/project/${projectId}`
|
||||
fileIds = [ObjectId().toString(), ObjectId().toString()]
|
||||
otherProjectUrl = `${filestoreUrl}/project/${otherProjectId}`
|
||||
fileIds = [
|
||||
ObjectId().toString(),
|
||||
ObjectId().toString(),
|
||||
ObjectId().toString(),
|
||||
]
|
||||
fileUrls = [
|
||||
`${projectUrl}/file/${fileIds[0]}`,
|
||||
`${projectUrl}/file/${fileIds[1]}`,
|
||||
]
|
||||
otherFileUrls = [`${otherProjectUrl}/file/${fileIds[2]}`]
|
||||
|
||||
const writeStreams = [
|
||||
request.post(fileUrls[0]),
|
||||
request.post(fileUrls[1]),
|
||||
request.post(otherFileUrls[0]),
|
||||
]
|
||||
const readStreams = [
|
||||
fs.createReadStream(localFileReadPaths[0]),
|
||||
fs.createReadStream(localFileReadPaths[1]),
|
||||
fs.createReadStream(localFileReadPaths[2]),
|
||||
]
|
||||
// hack to consume the result to ensure the http request has been fully processed
|
||||
const resultStreams = [
|
||||
fs.createWriteStream('/dev/null'),
|
||||
fs.createWriteStream('/dev/null'),
|
||||
fs.createWriteStream('/dev/null'),
|
||||
]
|
||||
return Promise.all([
|
||||
pipeline(readStreams[0], writeStreams[0], resultStreams[0]),
|
||||
pipeline(readStreams[1], writeStreams[1], resultStreams[1]),
|
||||
pipeline(readStreams[2], writeStreams[2], resultStreams[2]),
|
||||
])
|
||||
})
|
||||
|
||||
|
@ -385,6 +408,14 @@ describe('Filestore', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('should not delete files in other projects', async function () {
|
||||
for (const index in otherFileUrls) {
|
||||
await expect(
|
||||
rp.get(otherFileUrls[index])
|
||||
).to.eventually.have.property('statusCode', 200)
|
||||
}
|
||||
})
|
||||
|
||||
it('should not delete a partial project id', async function () {
|
||||
await expect(
|
||||
rp.delete(`${filestoreUrl}/project/5`)
|
||||
|
|
Loading…
Reference in a new issue