mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #130 from overleaf/jpa-bump-dev-env-3-3-2-testing
[misc] bump the dev-env to 3.3.2
This commit is contained in:
commit
773c9df99c
28 changed files with 566 additions and 625 deletions
17
services/filestore/.github/dependabot.yml
vendored
Normal file
17
services/filestore/.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
pull-request-branch-name:
|
||||
# Separate sections of the branch name with a hyphen
|
||||
# Docker images use the branch name and do not support slashes in tags
|
||||
# https://github.com/overleaf/google-ops/issues/822
|
||||
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#pull-request-branch-nameseparator
|
||||
separator: "-"
|
||||
|
||||
# Block informal upgrades -- security upgrades use a separate queue.
|
||||
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#open-pull-requests-limit
|
||||
open-pull-requests-limit: 0
|
3
services/filestore/.gitignore
vendored
3
services/filestore/.gitignore
vendored
|
@ -49,3 +49,6 @@ template_files/*
|
|||
|
||||
/log.json
|
||||
hash_folder
|
||||
|
||||
# managed by dev-environment$ bin/update_build_scripts
|
||||
.npmrc
|
||||
|
|
|
@ -17,8 +17,6 @@ RUN npm ci --quiet
|
|||
|
||||
COPY . /app
|
||||
|
||||
|
||||
|
||||
FROM base
|
||||
|
||||
COPY --from=app /app /app
|
||||
|
|
131
services/filestore/Jenkinsfile
vendored
131
services/filestore/Jenkinsfile
vendored
|
@ -1,131 +0,0 @@
|
|||
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
GIT_PROJECT = "filestore"
|
||||
JENKINS_WORKFLOW = "filestore-sharelatex"
|
||||
TARGET_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${JENKINS_WORKFLOW}/detail/$BRANCH_NAME/$BUILD_NUMBER/pipeline"
|
||||
GIT_API_URL = "https://api.github.com/repos/overleaf/${GIT_PROJECT}/statuses/$GIT_COMMIT"
|
||||
}
|
||||
|
||||
triggers {
|
||||
pollSCM('* * * * *')
|
||||
cron(cron_string)
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Install') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"pending\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build is underway\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'make build'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Linting') {
|
||||
steps {
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make format'
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make lint'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Acceptance Tests') {
|
||||
steps {
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Package and docker push') {
|
||||
steps {
|
||||
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
||||
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make tar'
|
||||
|
||||
withCredentials([file(credentialsId: 'gcr.io_overleaf-ops', variable: 'DOCKER_REPO_KEY_PATH')]) {
|
||||
sh 'docker login -u _json_key --password-stdin https://gcr.io/overleaf-ops < ${DOCKER_REPO_KEY_PATH}'
|
||||
}
|
||||
sh 'DOCKER_REPO=gcr.io/overleaf-ops make publish'
|
||||
sh 'docker logout https://gcr.io/overleaf-ops'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
stage('Publish to s3') {
|
||||
steps {
|
||||
sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
|
||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
||||
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
||||
}
|
||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
||||
// The deployment process uses this file to figure out the latest build
|
||||
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
|
||||
sh 'make clean'
|
||||
}
|
||||
|
||||
success {
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"success\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build succeeded!\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
|
||||
failure {
|
||||
mail(from: "${EMAIL_ALERT_FROM}",
|
||||
to: "${EMAIL_ALERT_TO}",
|
||||
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
|
||||
body: "Build: ${BUILD_URL}")
|
||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
||||
sh "curl $GIT_API_URL \
|
||||
--data '{ \
|
||||
\"state\" : \"failure\", \
|
||||
\"target_url\": \"$TARGET_URL\", \
|
||||
\"description\": \"Your build failed\", \
|
||||
\"context\": \"ci/jenkins\" }' \
|
||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The options directive is for configuration that applies to the whole job.
|
||||
options {
|
||||
// we'd like to make sure remove old builds, so we don't fill up our storage!
|
||||
buildDiscarder(logRotator(numToKeepStr:'50'))
|
||||
|
||||
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
|
||||
timeout(time: 30, unit: 'MINUTES')
|
||||
}
|
||||
}
|
|
@ -25,13 +25,13 @@ clean:
|
|||
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
||||
|
||||
format:
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run format
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format
|
||||
|
||||
format_fix:
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run format:fix
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format:fix
|
||||
|
||||
lint:
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run lint
|
||||
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent lint
|
||||
|
||||
test: format lint test_unit test_acceptance
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ if (Metrics.event_loop) {
|
|||
Metrics.event_loop.monitor(logger)
|
||||
}
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
app.use(function (req, res, next) {
|
||||
Metrics.inc('http-request')
|
||||
next()
|
||||
})
|
||||
|
@ -127,7 +127,7 @@ app.get(
|
|||
fileController.getFile
|
||||
)
|
||||
|
||||
app.get('/status', function(req, res) {
|
||||
app.get('/status', function (req, res) {
|
||||
res.send('filestore sharelatex up')
|
||||
})
|
||||
|
||||
|
@ -140,7 +140,7 @@ const host = '0.0.0.0'
|
|||
|
||||
if (!module.parent) {
|
||||
// Called directly
|
||||
app.listen(port, host, error => {
|
||||
app.listen(port, host, (error) => {
|
||||
if (error) {
|
||||
logger.error('Error starting Filestore', error)
|
||||
throw error
|
||||
|
@ -153,7 +153,7 @@ process
|
|||
.on('unhandledRejection', (reason, p) => {
|
||||
logger.err(reason, 'Unhandled Rejection at Promise', p)
|
||||
})
|
||||
.on('uncaughtException', err => {
|
||||
.on('uncaughtException', (err) => {
|
||||
logger.err(err, 'Uncaught Exception thrown')
|
||||
process.exit(1)
|
||||
})
|
||||
|
|
|
@ -46,7 +46,7 @@ function getFile(req, res, next) {
|
|||
}
|
||||
}
|
||||
|
||||
FileHandler.getRedirectUrl(bucket, key, options, function(err, redirectUrl) {
|
||||
FileHandler.getRedirectUrl(bucket, key, options, function (err, redirectUrl) {
|
||||
if (err) {
|
||||
metrics.inc('file_redirect_error')
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ function getFile(req, res, next) {
|
|||
return res.redirect(redirectUrl)
|
||||
}
|
||||
|
||||
FileHandler.getFile(bucket, key, options, function(err, fileStream) {
|
||||
FileHandler.getFile(bucket, key, options, function (err, fileStream) {
|
||||
if (err) {
|
||||
if (err instanceof Errors.NotFoundError) {
|
||||
res.sendStatus(404)
|
||||
|
@ -70,7 +70,7 @@ function getFile(req, res, next) {
|
|||
return res.sendStatus(200).end()
|
||||
}
|
||||
|
||||
pipeline(fileStream, res, err => {
|
||||
pipeline(fileStream, res, (err) => {
|
||||
if (err && err.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
res.end()
|
||||
} else if (err) {
|
||||
|
@ -94,7 +94,7 @@ function getFileHead(req, res, next) {
|
|||
req.requestLogger.setMessage('getting file size')
|
||||
req.requestLogger.addFields({ key, bucket })
|
||||
|
||||
FileHandler.getFileSize(bucket, key, function(err, fileSize) {
|
||||
FileHandler.getFileSize(bucket, key, function (err, fileSize) {
|
||||
if (err) {
|
||||
if (err instanceof Errors.NotFoundError) {
|
||||
res.sendStatus(404)
|
||||
|
@ -115,7 +115,7 @@ function insertFile(req, res, next) {
|
|||
req.requestLogger.setMessage('inserting file')
|
||||
req.requestLogger.addFields({ key, bucket })
|
||||
|
||||
FileHandler.insertFile(bucket, key, req, function(err) {
|
||||
FileHandler.insertFile(bucket, key, req, function (err) {
|
||||
if (err) {
|
||||
next(err)
|
||||
} else {
|
||||
|
@ -140,7 +140,7 @@ function copyFile(req, res, next) {
|
|||
|
||||
PersistorManager.copyObject(bucket, `${oldProjectId}/${oldFileId}`, key)
|
||||
.then(() => res.sendStatus(200))
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err) {
|
||||
if (err instanceof Errors.NotFoundError) {
|
||||
res.sendStatus(404)
|
||||
|
@ -158,7 +158,7 @@ function deleteFile(req, res, next) {
|
|||
req.requestLogger.addFields({ key, bucket })
|
||||
req.requestLogger.setMessage('deleting file')
|
||||
|
||||
FileHandler.deleteFile(bucket, key, function(err) {
|
||||
FileHandler.deleteFile(bucket, key, function (err) {
|
||||
if (err) {
|
||||
next(err)
|
||||
} else {
|
||||
|
@ -174,7 +174,7 @@ function deleteProject(req, res, next) {
|
|||
req.requestLogger.setMessage('deleting project')
|
||||
req.requestLogger.addFields({ key, bucket })
|
||||
|
||||
FileHandler.deleteProject(bucket, key, function(err) {
|
||||
FileHandler.deleteProject(bucket, key, function (err) {
|
||||
if (err) {
|
||||
if (err instanceof Errors.InvalidParametersError) {
|
||||
return res.sendStatus(400)
|
||||
|
@ -193,7 +193,7 @@ function directorySize(req, res, next) {
|
|||
req.requestLogger.setMessage('getting project size')
|
||||
req.requestLogger.addFields({ projectId, bucket })
|
||||
|
||||
FileHandler.getDirectorySize(bucket, projectId, function(err, size) {
|
||||
FileHandler.getDirectorySize(bucket, projectId, function (err, size) {
|
||||
if (err) {
|
||||
return next(err)
|
||||
}
|
||||
|
|
|
@ -143,8 +143,8 @@ async function _getConvertedFileAndCache(bucket, key, convertedKey, opts) {
|
|||
// S3 provides eventual consistency for read-after-write.""
|
||||
// https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html#ConsistencyModel
|
||||
const readStream = fs.createReadStream(convertedFsPath)
|
||||
readStream.on('end', function() {
|
||||
LocalFileWriter.deleteFile(convertedFsPath, function() {})
|
||||
readStream.on('end', function () {
|
||||
LocalFileWriter.deleteFile(convertedFsPath, function () {})
|
||||
})
|
||||
return readStream
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ async function _convertFile(bucket, originalKey, opts) {
|
|||
err
|
||||
)
|
||||
}
|
||||
LocalFileWriter.deleteFile(originalFsPath, function() {})
|
||||
LocalFileWriter.deleteFile(originalFsPath, function () {})
|
||||
return destPath
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ module.exports = {
|
|||
check(req, res, next) {
|
||||
Promise.all([checkCanGetFiles(), checkFileConvert()])
|
||||
.then(() => res.sendStatus(200))
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
next(err)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class RequestLogger {
|
|||
|
||||
// override the 'end' method to log and record metrics
|
||||
const end = res.end
|
||||
res.end = function() {
|
||||
res.end = function () {
|
||||
// apply the standard request 'end' method before logging and metrics
|
||||
end.apply(this, arguments)
|
||||
|
||||
|
@ -38,10 +38,7 @@ class RequestLogger {
|
|||
metrics.timing('http_request', responseTime, null, {
|
||||
method: req.method,
|
||||
status_code: res.statusCode,
|
||||
path: routePath
|
||||
.replace(/\//g, '_')
|
||||
.replace(/:/g, '')
|
||||
.slice(1)
|
||||
path: routePath.replace(/\//g, '_').replace(/:/g, '').slice(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ function safeExec(command, options, callback) {
|
|||
|
||||
let killTimer
|
||||
|
||||
const cleanup = lodashOnce(function(err) {
|
||||
const cleanup = lodashOnce(function (err) {
|
||||
if (killTimer) {
|
||||
clearTimeout(killTimer)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ function safeExec(command, options, callback) {
|
|||
})
|
||||
|
||||
if (options.timeout) {
|
||||
killTimer = setTimeout(function() {
|
||||
killTimer = setTimeout(function () {
|
||||
try {
|
||||
// use negative process id to kill process group
|
||||
process.kill(-child.pid, options.killSignal || 'SIGTERM')
|
||||
|
@ -52,7 +52,7 @@ function safeExec(command, options, callback) {
|
|||
}, options.timeout)
|
||||
}
|
||||
|
||||
child.on('close', function(code, signal) {
|
||||
child.on('close', function (code, signal) {
|
||||
if (code || signal) {
|
||||
return cleanup(
|
||||
new FailedCommandError(command, code || signal, stdout, stderr)
|
||||
|
@ -62,13 +62,13 @@ function safeExec(command, options, callback) {
|
|||
cleanup()
|
||||
})
|
||||
|
||||
child.on('error', err => {
|
||||
child.on('error', (err) => {
|
||||
cleanup(err)
|
||||
})
|
||||
child.stdout.on('data', chunk => {
|
||||
child.stdout.on('data', (chunk) => {
|
||||
stdout += chunk
|
||||
})
|
||||
child.stderr.on('data', chunk => {
|
||||
child.stderr.on('data', (chunk) => {
|
||||
stderr += chunk
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
filestore
|
||||
--acceptance-creds=
|
||||
--data-dirs=uploads,user_files,template_files
|
||||
--dependencies=s3,gcs
|
||||
--docker-repos=gcr.io/overleaf-ops
|
||||
--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,AWS_S3_PUBLIC_FILES_BUCKET_NAME=fake_public_files
|
||||
--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,AWS_S3_PUBLIC_FILES_BUCKET_NAME=fake_public_files,GCS_USER_FILES_BUCKET_NAME=fake_userfiles,GCS_TEMPLATE_FILES_BUCKET_NAME=fake_templatefiles,GCS_PUBLIC_FILES_BUCKET_NAME=fake_publicfiles
|
||||
--env-pass-through=
|
||||
--language=es
|
||||
--node-version=12.18.0
|
||||
--public-repo=True
|
||||
--script-version=2.2.0
|
||||
--script-version=3.3.2
|
||||
|
|
|
@ -11,6 +11,7 @@ services:
|
|||
command: npm run test:unit:_run
|
||||
environment:
|
||||
NODE_ENV: test
|
||||
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||
|
||||
|
||||
test_acceptance:
|
||||
|
@ -21,23 +22,25 @@ services:
|
|||
REDIS_HOST: redis
|
||||
MONGO_HOST: mongo
|
||||
POSTGRES_HOST: postgres
|
||||
AWS_S3_ENDPOINT: http://s3:9090
|
||||
AWS_S3_PATH_STYLE: 'true'
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
GCS_API_ENDPOINT: gcs:9090
|
||||
GCS_API_SCHEME: http
|
||||
GCS_PROJECT_ID: fake
|
||||
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
|
||||
MOCHA_GREP: ${MOCHA_GREP}
|
||||
NODE_ENV: test
|
||||
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||
ENABLE_CONVERSIONS: "true"
|
||||
USE_PROM_METRICS: "true"
|
||||
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
|
||||
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
|
||||
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
|
||||
AWS_S3_ENDPOINT: http://s3:9090
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
AWS_S3_PATH_STYLE: 'true'
|
||||
GCS_API_ENDPOINT: gcs:9090
|
||||
GCS_API_SCHEME: http
|
||||
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
|
||||
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
|
||||
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
|
||||
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
|
@ -59,8 +62,7 @@ services:
|
|||
context: test/acceptance/deps
|
||||
dockerfile: Dockerfile.s3mock
|
||||
environment:
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files
|
||||
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
|
||||
gcs:
|
||||
build:
|
||||
context: test/acceptance/deps
|
||||
|
|
|
@ -15,7 +15,8 @@ services:
|
|||
environment:
|
||||
MOCHA_GREP: ${MOCHA_GREP}
|
||||
NODE_ENV: test
|
||||
command: npm run test:unit
|
||||
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||
command: npm run --silent test:unit
|
||||
user: node
|
||||
|
||||
test_acceptance:
|
||||
|
@ -30,39 +31,40 @@ services:
|
|||
REDIS_HOST: redis
|
||||
MONGO_HOST: mongo
|
||||
POSTGRES_HOST: postgres
|
||||
MOCHA_GREP: ${MOCHA_GREP}
|
||||
LOG_LEVEL: ERROR
|
||||
NODE_ENV: test
|
||||
ENABLE_CONVERSIONS: "true"
|
||||
USE_PROM_METRICS: "true"
|
||||
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
|
||||
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
|
||||
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
|
||||
AWS_S3_ENDPOINT: http://s3:9090
|
||||
AWS_S3_PATH_STYLE: 'true'
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
GCS_API_ENDPOINT: gcs:9090
|
||||
GCS_API_SCHEME: http
|
||||
GCS_PROJECT_ID: fake
|
||||
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
|
||||
MOCHA_GREP: ${MOCHA_GREP}
|
||||
LOG_LEVEL: ERROR
|
||||
NODE_ENV: test
|
||||
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||
ENABLE_CONVERSIONS: "true"
|
||||
USE_PROM_METRICS: "true"
|
||||
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
|
||||
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
|
||||
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
|
||||
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
|
||||
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
|
||||
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
|
||||
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
|
||||
user: node
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
gcs:
|
||||
condition: service_healthy
|
||||
command: npm run test:acceptance
|
||||
command: npm run --silent test:acceptance
|
||||
|
||||
s3:
|
||||
build:
|
||||
context: test/acceptance/deps
|
||||
dockerfile: Dockerfile.s3mock
|
||||
environment:
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files
|
||||
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
|
||||
gcs:
|
||||
build:
|
||||
context: test/acceptance/deps
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
"execMap": {
|
||||
"js": "npm run start"
|
||||
},
|
||||
|
||||
"watch": [
|
||||
"app/js/",
|
||||
"app.js",
|
||||
|
|
329
services/filestore/package-lock.json
generated
329
services/filestore/package-lock.json
generated
|
@ -149,6 +149,24 @@
|
|||
"google-auth-library": "^5.5.0",
|
||||
"retry-request": "^4.0.0",
|
||||
"teeny-request": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-auth-library": {
|
||||
"version": "5.10.1",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.10.1.tgz",
|
||||
"integrity": "sha512-rOlaok5vlpV9rSiUu5EpR0vVpc+PhN62oF4RyX/6++DG1VsaulAFEMlDYBLjJDDPI6OcNOCGAKy9UVB/3NIDXg==",
|
||||
"requires": {
|
||||
"arrify": "^2.0.0",
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^2.1.0",
|
||||
"gcp-metadata": "^3.4.0",
|
||||
"gtoken": "^4.1.0",
|
||||
"jws": "^4.0.0",
|
||||
"lru-cache": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@google-cloud/debug-agent": {
|
||||
|
@ -369,6 +387,24 @@
|
|||
"stream-events": "^1.0.4",
|
||||
"through2": "^3.0.0",
|
||||
"type-fest": "^0.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-auth-library": {
|
||||
"version": "5.10.1",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.10.1.tgz",
|
||||
"integrity": "sha512-rOlaok5vlpV9rSiUu5EpR0vVpc+PhN62oF4RyX/6++DG1VsaulAFEMlDYBLjJDDPI6OcNOCGAKy9UVB/3NIDXg==",
|
||||
"requires": {
|
||||
"arrify": "^2.0.0",
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^2.1.0",
|
||||
"gcp-metadata": "^3.4.0",
|
||||
"gtoken": "^4.1.0",
|
||||
"jws": "^4.0.0",
|
||||
"lru-cache": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@google-cloud/logging-bunyan": {
|
||||
|
@ -378,69 +414,6 @@
|
|||
"requires": {
|
||||
"@google-cloud/logging": "^7.0.0",
|
||||
"google-auth-library": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"gaxios": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-3.0.3.tgz",
|
||||
"integrity": "sha512-PkzQludeIFhd535/yucALT/Wxyj/y2zLyrMwPcJmnLHDugmV49NvAi/vb+VUq/eWztATZCNcb8ue+ywPG+oLuw==",
|
||||
"requires": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"extend": "^3.0.2",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"is-stream": "^2.0.0",
|
||||
"node-fetch": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"gcp-metadata": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.1.0.tgz",
|
||||
"integrity": "sha512-r57SV28+olVsflPlKyVig3Muo/VDlcsObMtvDGOEtEJXj+DDE8bEl0coIkXh//hbkSDTvo+f5lbihZOndYXQQQ==",
|
||||
"requires": {
|
||||
"gaxios": "^3.0.0",
|
||||
"json-bigint": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"google-auth-library": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.3.tgz",
|
||||
"integrity": "sha512-2Np6ojPmaJGXHSMsBhtTQEKfSMdLc8hefoihv7N2cwEr8E5bq39fhoat6TcXHwa0XoGO5Guh9sp3nxHFPmibMw==",
|
||||
"requires": {
|
||||
"arrify": "^2.0.0",
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^3.0.0",
|
||||
"gcp-metadata": "^4.1.0",
|
||||
"gtoken": "^5.0.0",
|
||||
"jws": "^4.0.0",
|
||||
"lru-cache": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"google-p12-pem": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.1.tgz",
|
||||
"integrity": "sha512-VlQgtozgNVVVcYTXS36eQz4PXPt9gIPqLOhHN0QiV6W6h4qSCNVKPtKC5INtJsaHHF2r7+nOIa26MJeJMTaZEQ==",
|
||||
"requires": {
|
||||
"node-forge": "^0.9.0"
|
||||
}
|
||||
},
|
||||
"gtoken": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.0.1.tgz",
|
||||
"integrity": "sha512-33w4FNDkUcyIOq/TqyC+drnKdI4PdXmWp9lZzssyEQKuvu9ZFN3KttaSnDKo52U3E51oujVGop93mKxmqO8HHg==",
|
||||
"requires": {
|
||||
"gaxios": "^3.0.0",
|
||||
"google-p12-pem": "^3.0.0",
|
||||
"jws": "^4.0.0",
|
||||
"mime": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"mime": {
|
||||
"version": "2.4.6",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
|
||||
"integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@google-cloud/paginator": {
|
||||
|
@ -1097,9 +1070,9 @@
|
|||
}
|
||||
},
|
||||
"@grpc/proto-loader": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.4.tgz",
|
||||
"integrity": "sha512-HTM4QpI9B2XFkPz7pjwMyMgZchJ93TVkL3kWPW8GDMDKYxsMnmf4w2TNMJK7+KNiYHS5cJrCEAFlF+AwtXWVPA==",
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.5.tgz",
|
||||
"integrity": "sha512-WwN9jVNdHRQoOBo9FDH7qU+mgfjPc8GygPYms3M+y3fbQLfnCe/Kv/E01t7JRgnrsOHH8euvSbed3mIalXhwqQ==",
|
||||
"requires": {
|
||||
"lodash.camelcase": "^4.3.0",
|
||||
"protobufjs": "^6.8.6"
|
||||
|
@ -1821,7 +1794,6 @@
|
|||
"version": "1.8.14",
|
||||
"resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.14.tgz",
|
||||
"integrity": "sha512-LlahJUxXzZLuw/hetUQJmRgZ1LF6+cr5TPpRj6jf327AsiIq2jhYEH4oqUUkVKTor+9w2BT3oxVwhzE5lw9tcg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"dtrace-provider": "~0.8",
|
||||
"moment": "^2.19.3",
|
||||
|
@ -1905,7 +1877,7 @@
|
|||
"charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA=="
|
||||
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
|
||||
},
|
||||
"check-error": {
|
||||
"version": "1.0.2",
|
||||
|
@ -2141,7 +2113,7 @@
|
|||
"crypt": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
||||
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow=="
|
||||
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
|
||||
},
|
||||
"crypto-random-string": {
|
||||
"version": "2.0.0",
|
||||
|
@ -2151,7 +2123,7 @@
|
|||
"d64": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d64/-/d64-1.0.0.tgz",
|
||||
"integrity": "sha512-5eNy3WZziVYnrogqgXhcdEmqcDB2IHurTqLcrgssJsfkMVCUoUaZpK6cJjxxvLV2dUm5SuJMNcYfVGoin9UIRw=="
|
||||
"integrity": "sha1-QAKofoUMv8n52XBrYPymE6MzbpA="
|
||||
},
|
||||
"dashdash": {
|
||||
"version": "1.14.1",
|
||||
|
@ -2521,9 +2493,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"eslint-plugin-chai-friendly": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.6.0.tgz",
|
||||
"integrity": "sha512-Uvvv1gkbRGp/qfN15B0kQyQWg+oFA8buDSqrwmW3egNSk/FpqH2MjQqKOuKwmEL6w4QIQrIjDp+gg6kGGmD3oQ==",
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.5.0.tgz",
|
||||
"integrity": "sha512-Pxe6z8C9fP0pn2X2nGFU/b3GBOCM/5FVus1hsMwJsXP3R7RiXFl7g0ksJbsc0GxiLyidTW4mEFk77qsNn7Tk7g==",
|
||||
"dev": true
|
||||
},
|
||||
"eslint-plugin-es": {
|
||||
|
@ -3037,9 +3009,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"gaxios": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-2.3.1.tgz",
|
||||
"integrity": "sha512-DQOesWEx59/bm63lTX0uHDDXpGTW9oKqNsoigwCoRe2lOb5rFqxzHjLTa6aqEBecLcz69dHLw7rbS068z1fvIQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-2.3.4.tgz",
|
||||
"integrity": "sha512-US8UMj8C5pRnao3Zykc4AAVr+cffoNKRTg9Rsf2GiuZCW69vgJj38VK2PzlPuQU73FZ/nTk9/Av6/JGcE1N9vA==",
|
||||
"requires": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"extend": "^3.0.2",
|
||||
|
@ -3049,9 +3021,9 @@
|
|||
}
|
||||
},
|
||||
"gcp-metadata": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-3.4.0.tgz",
|
||||
"integrity": "sha512-fizmBtCXHp8b7FZuzbgKaixO8DzsSYoEVmMgZIna7x8t6cfBF3eqirODWYxVbgmasA5qudCAKiszfB7yVwroIQ==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-3.5.0.tgz",
|
||||
"integrity": "sha512-ZQf+DLZ5aKcRpLzYUyBS3yo3N0JSa82lNDO8rj3nMSlovLcz2riKFBsYgDzeXcv75oo5eqB2lx+B14UvPoCRnA==",
|
||||
"requires": {
|
||||
"gaxios": "^2.1.0",
|
||||
"json-bigint": "^0.3.0"
|
||||
|
@ -3215,19 +3187,92 @@
|
|||
"dev": true
|
||||
},
|
||||
"google-auth-library": {
|
||||
"version": "5.10.1",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.10.1.tgz",
|
||||
"integrity": "sha512-rOlaok5vlpV9rSiUu5EpR0vVpc+PhN62oF4RyX/6++DG1VsaulAFEMlDYBLjJDDPI6OcNOCGAKy9UVB/3NIDXg==",
|
||||
"version": "6.0.6",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.6.tgz",
|
||||
"integrity": "sha512-fWYdRdg55HSJoRq9k568jJA1lrhg9i2xgfhVIMJbskUmbDpJGHsbv9l41DGhCDXM21F9Kn4kUwdysgxSYBYJUw==",
|
||||
"requires": {
|
||||
"arrify": "^2.0.0",
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^2.1.0",
|
||||
"gcp-metadata": "^3.4.0",
|
||||
"gtoken": "^4.1.0",
|
||||
"gaxios": "^3.0.0",
|
||||
"gcp-metadata": "^4.1.0",
|
||||
"gtoken": "^5.0.0",
|
||||
"jws": "^4.0.0",
|
||||
"lru-cache": "^5.0.0"
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bignumber.js": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
||||
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=="
|
||||
},
|
||||
"gaxios": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-3.1.0.tgz",
|
||||
"integrity": "sha512-DDTn3KXVJJigtz+g0J3vhcfbDbKtAroSTxauWsdnP57sM5KZ3d2c/3D9RKFJ86s43hfw6WULg6TXYw/AYiBlpA==",
|
||||
"requires": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"extend": "^3.0.2",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"is-stream": "^2.0.0",
|
||||
"node-fetch": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"gcp-metadata": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.1.4.tgz",
|
||||
"integrity": "sha512-5J/GIH0yWt/56R3dNaNWPGQ/zXsZOddYECfJaqxFWgrZ9HC2Kvc5vl9upOgUUHKzURjAVf2N+f6tEJiojqXUuA==",
|
||||
"requires": {
|
||||
"gaxios": "^3.0.0",
|
||||
"json-bigint": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"google-p12-pem": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.2.tgz",
|
||||
"integrity": "sha512-tbjzndQvSIHGBLzHnhDs3cL4RBjLbLXc2pYvGH+imGVu5b4RMAttUTdnmW2UH0t11QeBTXZ7wlXPS7hrypO/tg==",
|
||||
"requires": {
|
||||
"node-forge": "^0.9.0"
|
||||
}
|
||||
},
|
||||
"gtoken": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.0.3.tgz",
|
||||
"integrity": "sha512-Nyd1wZCMRc2dj/mAD0LlfQLcAO06uKdpKJXvK85SGrF5+5+Bpfil9u/2aw35ltvEHjvl0h5FMKN5knEU+9JrOg==",
|
||||
"requires": {
|
||||
"gaxios": "^3.0.0",
|
||||
"google-p12-pem": "^3.0.0",
|
||||
"jws": "^4.0.0",
|
||||
"mime": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"json-bigint": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
|
||||
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
|
||||
"requires": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"requires": {
|
||||
"yallist": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"mime": {
|
||||
"version": "2.4.6",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
|
||||
"integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA=="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"google-gax": {
|
||||
|
@ -3250,6 +3295,24 @@
|
|||
"retry-request": "^4.0.0",
|
||||
"semver": "^6.0.0",
|
||||
"walkdir": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-auth-library": {
|
||||
"version": "5.10.1",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.10.1.tgz",
|
||||
"integrity": "sha512-rOlaok5vlpV9rSiUu5EpR0vVpc+PhN62oF4RyX/6++DG1VsaulAFEMlDYBLjJDDPI6OcNOCGAKy9UVB/3NIDXg==",
|
||||
"requires": {
|
||||
"arrify": "^2.0.0",
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"fast-text-encoding": "^1.0.0",
|
||||
"gaxios": "^2.1.0",
|
||||
"gcp-metadata": "^3.4.0",
|
||||
"gtoken": "^4.1.0",
|
||||
"jws": "^4.0.0",
|
||||
"lru-cache": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"google-p12-pem": {
|
||||
|
@ -3283,9 +3346,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"mime": {
|
||||
"version": "2.4.4",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz",
|
||||
"integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA=="
|
||||
"version": "2.4.6",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
|
||||
"integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3812,12 +3875,12 @@
|
|||
"lodash.at": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz",
|
||||
"integrity": "sha512-GOTh0SEp+Yosnlpjic+8cl2WM9MykorogkGA9xyIFkkObQ3H3kNZqZ+ohuq4K3FrSVo7hMcZBMataJemrxC3BA=="
|
||||
"integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g="
|
||||
},
|
||||
"lodash.camelcase": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
|
||||
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
|
||||
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
|
||||
},
|
||||
"lodash.get": {
|
||||
"version": "4.4.2",
|
||||
|
@ -3828,7 +3891,7 @@
|
|||
"lodash.has": {
|
||||
"version": "4.5.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
|
||||
"integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
|
||||
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
|
||||
},
|
||||
"lodash.memoize": {
|
||||
"version": "4.1.2",
|
||||
|
@ -3873,28 +3936,16 @@
|
|||
}
|
||||
},
|
||||
"logger-sharelatex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/logger-sharelatex/-/logger-sharelatex-2.1.1.tgz",
|
||||
"integrity": "sha512-qqSrBqUgHWnStxtTZ/fSsqPxj9Ju9onok7Vfm3bv5MS702jH+hRsCSA9oXOMvOLcWJrZFnhCZaLGeOvXToUaxw==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/logger-sharelatex/-/logger-sharelatex-2.2.0.tgz",
|
||||
"integrity": "sha512-ko+OmE25XHJJCiz1R9EgwlfM7J/5olpunUfR3WcfuqOQrcUqsdBrDA2sOytngT0ViwjCR0Fh4qZVPwEWfmrvwA==",
|
||||
"requires": {
|
||||
"@google-cloud/logging-bunyan": "^3.0.0",
|
||||
"@overleaf/o-error": "^3.0.0",
|
||||
"bunyan": "^1.8.14",
|
||||
"node-fetch": "^2.6.0",
|
||||
"raven": "^2.6.4",
|
||||
"yn": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bunyan": {
|
||||
"version": "1.8.14",
|
||||
"resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.14.tgz",
|
||||
"integrity": "sha512-LlahJUxXzZLuw/hetUQJmRgZ1LF6+cr5TPpRj6jf327AsiIq2jhYEH4oqUUkVKTor+9w2BT3oxVwhzE5lw9tcg==",
|
||||
"requires": {
|
||||
"dtrace-provider": "~0.8",
|
||||
"moment": "^2.19.3",
|
||||
"mv": "~2",
|
||||
"safe-json-stringify": "~1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"loglevel": {
|
||||
|
@ -4009,13 +4060,13 @@
|
|||
"integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g=="
|
||||
},
|
||||
"md5": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
|
||||
"integrity": "sha512-PlGG4z5mBANDGCKsYQe0CaUYHdZYZt8ZPZLmEt+Urf0W4GlpTX4HescwHU+dc9+Z/G/vZKYZYFrwgm9VxK6QOQ==",
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
||||
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
||||
"requires": {
|
||||
"charenc": "~0.0.1",
|
||||
"crypt": "~0.0.1",
|
||||
"is-buffer": "~1.1.1"
|
||||
"charenc": "0.0.2",
|
||||
"crypt": "0.0.2",
|
||||
"is-buffer": "~1.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-buffer": {
|
||||
|
@ -4737,9 +4788,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
|
||||
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier-eslint": {
|
||||
|
@ -4938,6 +4989,12 @@
|
|||
"mimic-fn": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||
"dev": true
|
||||
},
|
||||
"restore-cursor": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
|
||||
|
@ -5333,9 +5390,9 @@
|
|||
}
|
||||
},
|
||||
"protobufjs": {
|
||||
"version": "6.9.0",
|
||||
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.9.0.tgz",
|
||||
"integrity": "sha512-LlGVfEWDXoI/STstRDdZZKb/qusoAWUnmLg9R8OLSO473mBLWHowx8clbX5/+mKDEI+v7GzjoK9tRPZMMcoTrg==",
|
||||
"version": "6.10.1",
|
||||
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.1.tgz",
|
||||
"integrity": "sha512-pb8kTchL+1Ceg4lFd5XUpK8PdWacbvV5SK2ULH2ebrYtl4GjJmS24m6CKME67jzV53tbJxHlnNOSqQHbTsR9JQ==",
|
||||
"requires": {
|
||||
"@protobufjs/aspromise": "^1.1.2",
|
||||
"@protobufjs/base64": "^1.1.2",
|
||||
|
@ -5455,12 +5512,12 @@
|
|||
"cookie": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
|
||||
"integrity": "sha512-+IJOX0OqlHCszo2mBUq+SrEbCj6w7Kpffqx60zYbPTFaO4+yYgRjHwcZNpWvaTylDHaV7PPmBHzSecZiMhtPgw=="
|
||||
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
|
||||
},
|
||||
"stack-trace": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
|
||||
"integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="
|
||||
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
|
@ -6221,22 +6278,15 @@
|
|||
}
|
||||
},
|
||||
"teeny-request": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-6.0.2.tgz",
|
||||
"integrity": "sha512-B6fxA0fSnY/bul06NggdN1nywtr5U5Uvt96pHfTi8pi4MNe6++VUWcAAFBrcMeha94s+gULwA5WvagoSZ+AcYg==",
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-6.0.3.tgz",
|
||||
"integrity": "sha512-TZG/dfd2r6yeji19es1cUIwAlVD8y+/svB1kAC2Y0bjEyysrfbO8EZvJBRwIE6WkwmUoB7uvWLwTIhJbMXZ1Dw==",
|
||||
"requires": {
|
||||
"http-proxy-agent": "^4.0.0",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"node-fetch": "^2.2.0",
|
||||
"stream-events": "^1.0.5",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
"uuid": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"text-table": {
|
||||
|
@ -6261,7 +6311,7 @@
|
|||
"timed-out": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
|
||||
"integrity": "sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA=="
|
||||
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
|
||||
},
|
||||
"timekeeper": {
|
||||
"version": "2.2.0",
|
||||
|
@ -6303,7 +6353,7 @@
|
|||
"to-no-case": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz",
|
||||
"integrity": "sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg=="
|
||||
"integrity": "sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo="
|
||||
},
|
||||
"to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
|
@ -6317,7 +6367,7 @@
|
|||
"to-snake-case": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-snake-case/-/to-snake-case-1.0.0.tgz",
|
||||
"integrity": "sha512-joRpzBAk1Bhi2eGEYBjukEWHOe/IvclOkiJl3DtA91jV6NwQ3MwXA4FHYeqk8BNp/D8bmi9tcNbRu/SozP0jbQ==",
|
||||
"integrity": "sha1-znRpE4l5RgGah+Yu366upMYIq4w=",
|
||||
"requires": {
|
||||
"to-space-case": "^1.0.0"
|
||||
}
|
||||
|
@ -6325,7 +6375,7 @@
|
|||
"to-space-case": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz",
|
||||
"integrity": "sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==",
|
||||
"integrity": "sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=",
|
||||
"requires": {
|
||||
"to-no-case": "^1.0.0"
|
||||
}
|
||||
|
@ -6482,6 +6532,11 @@
|
|||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz",
|
||||
"integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg=="
|
||||
},
|
||||
"v8-compile-cache": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"test:unit": "npm run test:unit:_run -- --grep=$MOCHA_GREP",
|
||||
"start": "node $NODE_APP_OPTIONS app.js",
|
||||
"nodemon": "nodemon --config nodemon.json",
|
||||
"lint": "node_modules/.bin/eslint app test *.js",
|
||||
"lint": "node_modules/.bin/eslint --max-warnings 0 .",
|
||||
"format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
|
||||
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write",
|
||||
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
||||
|
@ -27,7 +27,7 @@
|
|||
"fast-crc32c": "^2.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"lodash.once": "^4.1.1",
|
||||
"logger-sharelatex": "^2.1.1",
|
||||
"logger-sharelatex": "^2.2.0",
|
||||
"metrics-sharelatex": "^2.7.0",
|
||||
"node-uuid": "~1.4.8",
|
||||
"range-parser": "^1.2.1",
|
||||
|
@ -46,18 +46,19 @@
|
|||
"chai-as-promised": "^7.1.1",
|
||||
"disrequire": "^1.1.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-config-standard": "^14.1.0",
|
||||
"eslint-plugin-chai-expect": "^2.1.0",
|
||||
"eslint-plugin-chai-friendly": "^0.6.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-chai-friendly": "^0.5.0",
|
||||
"eslint-plugin-import": "^2.20.1",
|
||||
"eslint-plugin-mocha": "^6.3.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"mocha": "7.2.0",
|
||||
"mongodb": "^3.5.9",
|
||||
"prettier": "^2.0.0",
|
||||
"prettier-eslint": "^9.0.2",
|
||||
"prettier-eslint-cli": "^5.0.0",
|
||||
"sandboxed-module": "2.0.4",
|
||||
|
|
|
@ -33,7 +33,7 @@ class FilestoreApp {
|
|||
this.server = this.app.listen(
|
||||
Settings.internal.filestore.port,
|
||||
'localhost',
|
||||
err => {
|
||||
(err) => {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class FilestoreApp {
|
|||
// unload the app, as we may be doing this on multiple runs with
|
||||
// different settings, which affect startup in some cases
|
||||
const files = await fsReaddir(Path.resolve(__dirname, '../../../app/js'))
|
||||
files.forEach(file => {
|
||||
files.forEach((file) => {
|
||||
disrequire(Path.resolve(__dirname, '../../../app/js', file))
|
||||
})
|
||||
disrequire(Path.resolve(__dirname, '../../../app'))
|
||||
|
|
|
@ -29,7 +29,7 @@ if (!process.env.AWS_ACCESS_KEY_ID) {
|
|||
throw new Error('please provide credentials for the AWS S3 test server')
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', e => {
|
||||
process.on('unhandledRejection', (e) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('** Unhandled Promise Rejection **\n', e)
|
||||
throw e
|
||||
|
@ -39,7 +39,7 @@ process.on('unhandledRejection', e => {
|
|||
// fs will always be available - add others if they are configured
|
||||
const BackendSettings = require('./TestConfig')
|
||||
|
||||
describe('Filestore', function() {
|
||||
describe('Filestore', function () {
|
||||
this.timeout(1000 * 10)
|
||||
const filestoreUrl = `http://localhost:${Settings.internal.filestore.port}`
|
||||
|
||||
|
@ -51,7 +51,7 @@ describe('Filestore', function() {
|
|||
|
||||
const badSockets = []
|
||||
for (const socket of stdout.split('\n')) {
|
||||
const fields = socket.split(' ').filter(part => part !== '')
|
||||
const fields = socket.split(' ').filter((part) => part !== '')
|
||||
if (
|
||||
fields.length > 2 &&
|
||||
parseInt(fields[1]) &&
|
||||
|
@ -79,11 +79,11 @@ describe('Filestore', function() {
|
|||
}
|
||||
|
||||
// redefine the test suite for every available backend
|
||||
Object.keys(BackendSettings).forEach(backend => {
|
||||
describe(backend, function() {
|
||||
Object.keys(BackendSettings).forEach((backend) => {
|
||||
describe(backend, function () {
|
||||
let app, previousEgress, previousIngress, metricPrefix, projectId
|
||||
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
// create the app with the relevant filestore settings
|
||||
Settings.filestore = BackendSettings[backend]
|
||||
app = new FilestoreApp()
|
||||
|
@ -91,7 +91,7 @@ describe('Filestore', function() {
|
|||
})
|
||||
|
||||
if (BackendSettings[backend].gcs) {
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
const storage = new Storage(Settings.filestore.gcs.endpoint)
|
||||
await storage.createBucket(process.env.GCS_USER_FILES_BUCKET_NAME)
|
||||
await storage.createBucket(process.env.GCS_PUBLIC_FILES_BUCKET_NAME)
|
||||
|
@ -108,12 +108,12 @@ describe('Filestore', function() {
|
|||
})
|
||||
}
|
||||
|
||||
after(async function() {
|
||||
after(async function () {
|
||||
await msleep(3000)
|
||||
await app.stop()
|
||||
})
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
// retrieve previous metrics from the app
|
||||
if (['s3', 'gcs'].includes(Settings.filestore.backend)) {
|
||||
metricPrefix = Settings.filestore.backend
|
||||
|
@ -125,26 +125,26 @@ describe('Filestore', function() {
|
|||
projectId = ObjectId().toString()
|
||||
})
|
||||
|
||||
it('should send a 200 for the status endpoint', async function() {
|
||||
it('should send a 200 for the status endpoint', async function () {
|
||||
const response = await rp(`${filestoreUrl}/status`)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
expect(response.body).to.contain('filestore')
|
||||
expect(response.body).to.contain('up')
|
||||
})
|
||||
|
||||
it('should send a 200 for the health-check endpoint', async function() {
|
||||
it('should send a 200 for the health-check endpoint', async function () {
|
||||
const response = await rp(`${filestoreUrl}/health_check`)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
expect(response.body).to.equal('OK')
|
||||
})
|
||||
|
||||
describe('with a file on the server', function() {
|
||||
describe('with a file on the server', function () {
|
||||
let fileId, fileUrl, constantFileContent
|
||||
|
||||
const localFileReadPath =
|
||||
'/tmp/filestore_acceptance_tests_file_read.txt'
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
fileId = ObjectId().toString()
|
||||
fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
|
||||
constantFileContent = [
|
||||
|
@ -174,14 +174,14 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should return 404 for a non-existant id', async function() {
|
||||
it('should return 404 for a non-existant id', async function () {
|
||||
const options = { uri: fileUrl + '___this_is_clearly_wrong___' }
|
||||
await expect(
|
||||
rp.get(options)
|
||||
).to.eventually.be.rejected.and.have.property('statusCode', 404)
|
||||
})
|
||||
|
||||
it('should return the file size on a HEAD request', async function() {
|
||||
it('should return the file size on a HEAD request', async function () {
|
||||
const expectedLength = Buffer.byteLength(constantFileContent)
|
||||
const res = await rp.head(fileUrl)
|
||||
expect(res.statusCode).to.equal(200)
|
||||
|
@ -190,17 +190,17 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should be able get the file back', async function() {
|
||||
it('should be able get the file back', async function () {
|
||||
const res = await rp.get(fileUrl)
|
||||
expect(res.body).to.equal(constantFileContent)
|
||||
})
|
||||
|
||||
it('should not leak a socket', async function() {
|
||||
it('should not leak a socket', async function () {
|
||||
await rp.get(fileUrl)
|
||||
await expectNoSockets()
|
||||
})
|
||||
|
||||
it('should be able to get back the first 9 bytes of the file', async function() {
|
||||
it('should be able to get back the first 9 bytes of the file', async function () {
|
||||
const options = {
|
||||
uri: fileUrl,
|
||||
headers: {
|
||||
|
@ -211,7 +211,7 @@ describe('Filestore', function() {
|
|||
expect(res.body).to.equal('hello wor')
|
||||
})
|
||||
|
||||
it('should be able to get back bytes 4 through 10 of the file', async function() {
|
||||
it('should be able to get back bytes 4 through 10 of the file', async function () {
|
||||
const options = {
|
||||
uri: fileUrl,
|
||||
headers: {
|
||||
|
@ -222,7 +222,7 @@ describe('Filestore', function() {
|
|||
expect(res.body).to.equal('o world')
|
||||
})
|
||||
|
||||
it('should be able to delete the file', async function() {
|
||||
it('should be able to delete the file', async function () {
|
||||
const response = await rp.del(fileUrl)
|
||||
expect(response.statusCode).to.equal(204)
|
||||
await expect(
|
||||
|
@ -230,7 +230,7 @@ describe('Filestore', function() {
|
|||
).to.eventually.be.rejected.and.have.property('statusCode', 404)
|
||||
})
|
||||
|
||||
it('should be able to copy files', async function() {
|
||||
it('should be able to copy files', async function () {
|
||||
const newProjectID = ObjectId().toString()
|
||||
const newFileId = ObjectId().toString()
|
||||
const newFileUrl = `${filestoreUrl}/project/${newProjectID}/file/${newFileId}`
|
||||
|
@ -252,7 +252,7 @@ describe('Filestore', function() {
|
|||
expect(response.body).to.equal(constantFileContent)
|
||||
})
|
||||
|
||||
it('should be able to overwrite the file', async function() {
|
||||
it('should be able to overwrite the file', async function () {
|
||||
const newContent = `here is some different content, ${Math.random()}`
|
||||
const writeStream = request.post(fileUrl)
|
||||
const readStream = streamifier.createReadStream(newContent)
|
||||
|
@ -265,7 +265,7 @@ describe('Filestore', function() {
|
|||
})
|
||||
|
||||
if (['S3Persistor', 'GcsPersistor'].includes(backend)) {
|
||||
it('should record an egress metric for the upload', async function() {
|
||||
it('should record an egress metric for the upload', async function () {
|
||||
const metric = await TestHelper.getMetric(
|
||||
filestoreUrl,
|
||||
`${metricPrefix}_egress`
|
||||
|
@ -273,7 +273,7 @@ describe('Filestore', function() {
|
|||
expect(metric - previousEgress).to.equal(constantFileContent.length)
|
||||
})
|
||||
|
||||
it('should record an ingress metric when downloading the file', async function() {
|
||||
it('should record an ingress metric when downloading the file', async function () {
|
||||
await rp.get(fileUrl)
|
||||
const metric = await TestHelper.getMetric(
|
||||
filestoreUrl,
|
||||
|
@ -284,7 +284,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should record an ingress metric for a partial download', async function() {
|
||||
it('should record an ingress metric for a partial download', async function () {
|
||||
const options = {
|
||||
uri: fileUrl,
|
||||
headers: {
|
||||
|
@ -301,7 +301,7 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
describe('with multiple files', function() {
|
||||
describe('with multiple files', function () {
|
||||
let fileIds, fileUrls, projectUrl
|
||||
const localFileReadPaths = [
|
||||
'/tmp/filestore_acceptance_tests_file_read_1.txt',
|
||||
|
@ -320,14 +320,14 @@ describe('Filestore', function() {
|
|||
].join('\n')
|
||||
]
|
||||
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
return Promise.all([
|
||||
fsWriteFile(localFileReadPaths[0], constantFileContents[0]),
|
||||
fsWriteFile(localFileReadPaths[1], constantFileContents[1])
|
||||
])
|
||||
})
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
projectUrl = `${filestoreUrl}/project/${projectId}`
|
||||
fileIds = [ObjectId().toString(), ObjectId().toString()]
|
||||
fileUrls = [
|
||||
|
@ -354,7 +354,7 @@ describe('Filestore', function() {
|
|||
])
|
||||
})
|
||||
|
||||
it('should get the directory size', async function() {
|
||||
it('should get the directory size', async function () {
|
||||
const response = await rp.get(
|
||||
`${filestoreUrl}/project/${projectId}/size`
|
||||
)
|
||||
|
@ -363,7 +363,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should store the files', async function() {
|
||||
it('should store the files', async function () {
|
||||
for (const index in fileUrls) {
|
||||
await expect(rp.get(fileUrls[index])).to.eventually.have.property(
|
||||
'body',
|
||||
|
@ -372,7 +372,7 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should be able to delete the project', async function() {
|
||||
it('should be able to delete the project', async function () {
|
||||
await expect(rp.delete(projectUrl)).to.eventually.have.property(
|
||||
'statusCode',
|
||||
204
|
||||
|
@ -385,17 +385,17 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should not delete a partial project id', async function() {
|
||||
it('should not delete a partial project id', async function () {
|
||||
await expect(
|
||||
rp.delete(`${filestoreUrl}/project/5`)
|
||||
).to.eventually.be.rejected.and.have.property('statusCode', 400)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a large file', function() {
|
||||
describe('with a large file', function () {
|
||||
let fileId, fileUrl, largeFileContent, error
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
fileId = ObjectId().toString()
|
||||
fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
|
||||
|
||||
|
@ -414,26 +414,26 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should be able to get the file back', async function() {
|
||||
it('should be able to get the file back', async function () {
|
||||
const response = await rp.get(fileUrl)
|
||||
expect(response.body).to.equal(largeFileContent)
|
||||
})
|
||||
|
||||
it('should not throw an error', function() {
|
||||
it('should not throw an error', function () {
|
||||
expect(error).not.to.exist
|
||||
})
|
||||
|
||||
it('should not leak a socket', async function() {
|
||||
it('should not leak a socket', async function () {
|
||||
await rp.get(fileUrl)
|
||||
await expectNoSockets()
|
||||
})
|
||||
|
||||
it('should not leak a socket if the connection is aborted', async function() {
|
||||
it('should not leak a socket if the connection is aborted', async function () {
|
||||
this.timeout(20000)
|
||||
for (let i = 0; i < 5; i++) {
|
||||
// test is not 100% reliable, so repeat
|
||||
// create a new connection and have it time out before reading any data
|
||||
await new Promise(resolve => {
|
||||
await new Promise((resolve) => {
|
||||
const streamThatHangs = new Stream.PassThrough()
|
||||
const stream = request({ url: fileUrl, timeout: 1000 })
|
||||
stream.pipe(streamThatHangs)
|
||||
|
@ -449,10 +449,10 @@ describe('Filestore', function() {
|
|||
})
|
||||
|
||||
if (backend === 'S3Persistor' || backend === 'FallbackGcsToS3Persistor') {
|
||||
describe('with a file in a specific bucket', function() {
|
||||
describe('with a file in a specific bucket', function () {
|
||||
let constantFileContent, fileId, fileUrl, bucketName
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
constantFileContent = `This is a file in a different S3 bucket ${Math.random()}`
|
||||
fileId = ObjectId().toString()
|
||||
bucketName = ObjectId().toString()
|
||||
|
@ -483,7 +483,7 @@ describe('Filestore', function() {
|
|||
.promise()
|
||||
})
|
||||
|
||||
it('should get the file from the specified bucket', async function() {
|
||||
it('should get the file from the specified bucket', async function () {
|
||||
const response = await rp.get(fileUrl)
|
||||
expect(response.body).to.equal(constantFileContent)
|
||||
})
|
||||
|
@ -491,10 +491,10 @@ describe('Filestore', function() {
|
|||
}
|
||||
|
||||
if (backend === 'GcsPersistor') {
|
||||
describe('when deleting a file in GCS', function() {
|
||||
describe('when deleting a file in GCS', function () {
|
||||
let fileId, fileUrl, content, error, date
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
date = new Date()
|
||||
tk.freeze(date)
|
||||
fileId = ObjectId()
|
||||
|
@ -515,15 +515,15 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
tk.reset()
|
||||
})
|
||||
|
||||
it('should not throw an error', function() {
|
||||
it('should not throw an error', function () {
|
||||
expect(error).not.to.exist
|
||||
})
|
||||
|
||||
it('should copy the file to the deleted-files bucket', async function() {
|
||||
it('should copy the file to the deleted-files bucket', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor,
|
||||
`${Settings.filestore.stores.user_files}-deleted`,
|
||||
|
@ -532,7 +532,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should remove the file from the original bucket', async function() {
|
||||
it('should remove the file from the original bucket', async function () {
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
app.persistor,
|
||||
Settings.filestore.stores.user_files,
|
||||
|
@ -543,7 +543,7 @@ describe('Filestore', function() {
|
|||
}
|
||||
|
||||
if (BackendSettings[backend].fallback) {
|
||||
describe('with a fallback', function() {
|
||||
describe('with a fallback', function () {
|
||||
let constantFileContent,
|
||||
fileId,
|
||||
fileKey,
|
||||
|
@ -551,7 +551,7 @@ describe('Filestore', function() {
|
|||
bucket,
|
||||
fallbackBucket
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
constantFileContent = `This is yet more file content ${Math.random()}`
|
||||
fileId = ObjectId().toString()
|
||||
fileKey = `${projectId}/${fileId}`
|
||||
|
@ -561,8 +561,8 @@ describe('Filestore', function() {
|
|||
fallbackBucket = Settings.filestore.fallback.buckets[bucket]
|
||||
})
|
||||
|
||||
describe('with a file in the fallback bucket', function() {
|
||||
beforeEach(async function() {
|
||||
describe('with a file in the fallback bucket', function () {
|
||||
beforeEach(async function () {
|
||||
await TestHelper.uploadStringToPersistor(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -571,7 +571,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should not find file in the primary', async function() {
|
||||
it('should not find file in the primary', async function () {
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -579,7 +579,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should find the file in the fallback', async function() {
|
||||
it('should find the file in the fallback', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -588,17 +588,17 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
describe('when copyOnMiss is disabled', function() {
|
||||
beforeEach(function() {
|
||||
describe('when copyOnMiss is disabled', function () {
|
||||
beforeEach(function () {
|
||||
app.persistor.settings.copyOnMiss = false
|
||||
})
|
||||
|
||||
it('should fetch the file', async function() {
|
||||
it('should fetch the file', async function () {
|
||||
const res = await rp.get(fileUrl)
|
||||
expect(res.body).to.equal(constantFileContent)
|
||||
})
|
||||
|
||||
it('should not copy the file to the primary', async function() {
|
||||
it('should not copy the file to the primary', async function () {
|
||||
await rp.get(fileUrl)
|
||||
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
|
@ -609,17 +609,17 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when copyOnMiss is enabled', function() {
|
||||
beforeEach(function() {
|
||||
describe('when copyOnMiss is enabled', function () {
|
||||
beforeEach(function () {
|
||||
app.persistor.settings.copyOnMiss = true
|
||||
})
|
||||
|
||||
it('should fetch the file', async function() {
|
||||
it('should fetch the file', async function () {
|
||||
const res = await rp.get(fileUrl)
|
||||
expect(res.body).to.equal(constantFileContent)
|
||||
})
|
||||
|
||||
it('copies the file to the primary', async function() {
|
||||
it('copies the file to the primary', async function () {
|
||||
await rp.get(fileUrl)
|
||||
// wait for the file to copy in the background
|
||||
await msleep(1000)
|
||||
|
@ -633,10 +633,10 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when copying a file', function() {
|
||||
describe('when copying a file', function () {
|
||||
let newFileId, newFileUrl, newFileKey, opts
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
const newProjectID = ObjectId().toString()
|
||||
newFileId = ObjectId().toString()
|
||||
newFileUrl = `${filestoreUrl}/project/${newProjectID}/file/${newFileId}`
|
||||
|
@ -654,15 +654,15 @@ describe('Filestore', function() {
|
|||
}
|
||||
})
|
||||
|
||||
describe('when copyOnMiss is false', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when copyOnMiss is false', function () {
|
||||
beforeEach(async function () {
|
||||
app.persistor.settings.copyOnMiss = false
|
||||
|
||||
const response = await rp(opts)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
||||
it('should leave the old file in the old bucket', async function() {
|
||||
it('should leave the old file in the old bucket', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -671,7 +671,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should not create a new file in the old bucket', async function() {
|
||||
it('should not create a new file in the old bucket', async function () {
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -679,7 +679,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should create a new file in the new bucket', async function() {
|
||||
it('should create a new file in the new bucket', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -688,7 +688,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should not copy the old file to the primary with the old key', async function() {
|
||||
it('should not copy the old file to the primary with the old key', async function () {
|
||||
// wait for the file to copy in the background
|
||||
await msleep(1000)
|
||||
|
||||
|
@ -700,15 +700,15 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when copyOnMiss is true', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when copyOnMiss is true', function () {
|
||||
beforeEach(async function () {
|
||||
app.persistor.settings.copyOnMiss = true
|
||||
|
||||
const response = await rp(opts)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
||||
it('should leave the old file in the old bucket', async function() {
|
||||
it('should leave the old file in the old bucket', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -717,7 +717,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should not create a new file in the old bucket', async function() {
|
||||
it('should not create a new file in the old bucket', async function () {
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -725,7 +725,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should create a new file in the new bucket', async function() {
|
||||
it('should create a new file in the new bucket', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -734,7 +734,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should copy the old file to the primary with the old key', async function() {
|
||||
it('should copy the old file to the primary with the old key', async function () {
|
||||
// wait for the file to copy in the background
|
||||
await msleep(1000)
|
||||
|
||||
|
@ -749,8 +749,8 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when sending a file', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when sending a file', function () {
|
||||
beforeEach(async function () {
|
||||
const writeStream = request.post(fileUrl)
|
||||
const readStream = streamifier.createReadStream(
|
||||
constantFileContent
|
||||
|
@ -760,7 +760,7 @@ describe('Filestore', function() {
|
|||
await pipeline(readStream, writeStream, resultStream)
|
||||
})
|
||||
|
||||
it('should store the file on the primary', async function() {
|
||||
it('should store the file on the primary', async function () {
|
||||
await TestHelper.expectPersistorToHaveFile(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -769,7 +769,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should not store the file on the fallback', async function() {
|
||||
it('should not store the file on the fallback', async function () {
|
||||
await TestHelper.expectPersistorNotToHaveFile(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -778,9 +778,9 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when deleting a file', function() {
|
||||
describe('when the file exists on the primary', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when deleting a file', function () {
|
||||
describe('when the file exists on the primary', function () {
|
||||
beforeEach(async function () {
|
||||
await TestHelper.uploadStringToPersistor(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -789,7 +789,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should delete the file', async function() {
|
||||
it('should delete the file', async function () {
|
||||
const response = await rp.del(fileUrl)
|
||||
expect(response.statusCode).to.equal(204)
|
||||
await expect(
|
||||
|
@ -798,8 +798,8 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when the file exists on the fallback', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when the file exists on the fallback', function () {
|
||||
beforeEach(async function () {
|
||||
await TestHelper.uploadStringToPersistor(
|
||||
app.persistor.fallbackPersistor,
|
||||
fallbackBucket,
|
||||
|
@ -808,7 +808,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should delete the file', async function() {
|
||||
it('should delete the file', async function () {
|
||||
const response = await rp.del(fileUrl)
|
||||
expect(response.statusCode).to.equal(204)
|
||||
await expect(
|
||||
|
@ -817,8 +817,8 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when the file exists on both the primary and the fallback', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when the file exists on both the primary and the fallback', function () {
|
||||
beforeEach(async function () {
|
||||
await TestHelper.uploadStringToPersistor(
|
||||
app.persistor.primaryPersistor,
|
||||
bucket,
|
||||
|
@ -833,7 +833,7 @@ describe('Filestore', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should delete the files', async function() {
|
||||
it('should delete the files', async function () {
|
||||
const response = await rp.del(fileUrl)
|
||||
expect(response.statusCode).to.equal(204)
|
||||
await expect(
|
||||
|
@ -842,8 +842,8 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when the file does not exist', function() {
|
||||
it('should return return 204', async function() {
|
||||
describe('when the file does not exist', function () {
|
||||
it('should return return 204', async function () {
|
||||
// S3 doesn't give us a 404 when the object doesn't exist, so to stay
|
||||
// consistent we merrily return 204 ourselves here as well
|
||||
const response = await rp.del(fileUrl)
|
||||
|
@ -854,14 +854,14 @@ describe('Filestore', function() {
|
|||
})
|
||||
}
|
||||
|
||||
describe('with a pdf file', function() {
|
||||
describe('with a pdf file', function () {
|
||||
let fileId, fileUrl, localFileSize
|
||||
const localFileReadPath = Path.resolve(
|
||||
__dirname,
|
||||
'../../fixtures/test.pdf'
|
||||
)
|
||||
|
||||
beforeEach(async function() {
|
||||
beforeEach(async function () {
|
||||
fileId = ObjectId().toString()
|
||||
fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
|
||||
const stat = await fsStat(localFileReadPath)
|
||||
|
@ -872,13 +872,13 @@ describe('Filestore', function() {
|
|||
await pipeline(readStream, writeStream, endStream)
|
||||
})
|
||||
|
||||
it('should be able get the file back', async function() {
|
||||
it('should be able get the file back', async function () {
|
||||
const response = await rp.get(fileUrl)
|
||||
expect(response.body.substring(0, 8)).to.equal('%PDF-1.5')
|
||||
})
|
||||
|
||||
if (['S3Persistor', 'GcsPersistor'].includes(backend)) {
|
||||
it('should record an egress metric for the upload', async function() {
|
||||
it('should record an egress metric for the upload', async function () {
|
||||
const metric = await TestHelper.getMetric(
|
||||
filestoreUrl,
|
||||
`${metricPrefix}_egress`
|
||||
|
@ -887,20 +887,20 @@ describe('Filestore', function() {
|
|||
})
|
||||
}
|
||||
|
||||
describe('getting the preview image', function() {
|
||||
describe('getting the preview image', function () {
|
||||
this.timeout(1000 * 20)
|
||||
let previewFileUrl
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
previewFileUrl = `${fileUrl}?style=preview`
|
||||
})
|
||||
|
||||
it('should not time out', async function() {
|
||||
it('should not time out', async function () {
|
||||
const response = await rp.get(previewFileUrl)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
||||
it('should respond with image data', async function() {
|
||||
it('should respond with image data', async function () {
|
||||
// note: this test relies of the imagemagick conversion working
|
||||
const response = await rp.get(previewFileUrl)
|
||||
expect(response.body.length).to.be.greaterThan(400)
|
||||
|
@ -908,20 +908,20 @@ describe('Filestore', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('warming the cache', function() {
|
||||
describe('warming the cache', function () {
|
||||
this.timeout(1000 * 20)
|
||||
let previewFileUrl
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
previewFileUrl = `${fileUrl}?style=preview&cacheWarm=true`
|
||||
})
|
||||
|
||||
it('should not time out', async function() {
|
||||
it('should not time out', async function () {
|
||||
const response = await rp.get(previewFileUrl)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
||||
it("should respond with only an 'OK'", async function() {
|
||||
it("should respond with only an 'OK'", async function () {
|
||||
// note: this test relies of the imagemagick conversion working
|
||||
const response = await rp.get(previewFileUrl)
|
||||
expect(response.body).to.equal('OK')
|
||||
|
|
|
@ -25,7 +25,7 @@ async function getMetric(filestoreUrl, metric) {
|
|||
function streamToString(stream) {
|
||||
const chunks = []
|
||||
return new Promise((resolve, reject) => {
|
||||
stream.on('data', chunk => chunks.push(chunk))
|
||||
stream.on('data', (chunk) => chunks.push(chunk))
|
||||
stream.on('error', reject)
|
||||
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
||||
stream.resume()
|
||||
|
|
|
@ -5,7 +5,7 @@ const SandboxedModule = require('sandboxed-module')
|
|||
const Errors = require('../../../app/js/Errors')
|
||||
const modulePath = '../../../app/js/FileController.js'
|
||||
|
||||
describe('FileController', function() {
|
||||
describe('FileController', function () {
|
||||
let PersistorManager,
|
||||
FileHandler,
|
||||
LocalFileWriter,
|
||||
|
@ -29,7 +29,7 @@ describe('FileController', function() {
|
|||
const key = `${projectId}/${fileId}`
|
||||
const error = new Error('incorrect utensil')
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
PersistorManager = {
|
||||
sendStream: sinon.stub().yields(),
|
||||
copyObject: sinon.stub().resolves(),
|
||||
|
@ -91,76 +91,76 @@ describe('FileController', function() {
|
|||
next = sinon.stub()
|
||||
})
|
||||
|
||||
describe('getFile', function() {
|
||||
it('should try and get a redirect url first', function() {
|
||||
describe('getFile', function () {
|
||||
it('should try and get a redirect url first', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(FileHandler.getRedirectUrl).to.have.been.calledWith(bucket, key)
|
||||
})
|
||||
|
||||
it('should pipe the stream', function() {
|
||||
it('should pipe the stream', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(stream.pipeline).to.have.been.calledWith(fileStream, res)
|
||||
})
|
||||
|
||||
it('should send a 200 if the cacheWarm param is true', function(done) {
|
||||
it('should send a 200 if the cacheWarm param is true', function (done) {
|
||||
req.query.cacheWarm = true
|
||||
res.sendStatus = statusCode => {
|
||||
res.sendStatus = (statusCode) => {
|
||||
statusCode.should.equal(200)
|
||||
done()
|
||||
}
|
||||
FileController.getFile(req, res, next)
|
||||
})
|
||||
|
||||
it('should send an error if there is a problem', function() {
|
||||
it('should send an error if there is a problem', function () {
|
||||
FileHandler.getFile.yields(error)
|
||||
FileController.getFile(req, res, next)
|
||||
expect(next).to.have.been.calledWith(error)
|
||||
})
|
||||
|
||||
describe('with a redirect url', function() {
|
||||
describe('with a redirect url', function () {
|
||||
const redirectUrl = 'https://wombat.potato/giraffe'
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
FileHandler.getRedirectUrl.yields(null, redirectUrl)
|
||||
res.redirect = sinon.stub()
|
||||
})
|
||||
|
||||
it('should redirect', function() {
|
||||
it('should redirect', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(res.redirect).to.have.been.calledWith(redirectUrl)
|
||||
})
|
||||
|
||||
it('should not get a file stream', function() {
|
||||
it('should not get a file stream', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(FileHandler.getFile).not.to.have.been.called
|
||||
})
|
||||
|
||||
describe('when there is an error getting the redirect url', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there is an error getting the redirect url', function () {
|
||||
beforeEach(function () {
|
||||
FileHandler.getRedirectUrl.yields(new Error('wombat herding error'))
|
||||
})
|
||||
|
||||
it('should not redirect', function() {
|
||||
it('should not redirect', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(res.redirect).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should not return an error', function() {
|
||||
it('should not return an error', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(next).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should proxy the file', function() {
|
||||
it('should proxy the file', function () {
|
||||
FileController.getFile(req, res, next)
|
||||
expect(FileHandler.getFile).to.have.been.calledWith(bucket, key)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a range header', function() {
|
||||
describe('with a range header', function () {
|
||||
let expectedOptions
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
expectedOptions = {
|
||||
bucket,
|
||||
key,
|
||||
|
@ -169,7 +169,7 @@ describe('FileController', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should pass range options to FileHandler', function() {
|
||||
it('should pass range options to FileHandler', function () {
|
||||
req.headers.range = 'bytes=0-8'
|
||||
expectedOptions.start = 0
|
||||
expectedOptions.end = 8
|
||||
|
@ -182,7 +182,7 @@ describe('FileController', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should ignore an invalid range header', function() {
|
||||
it('should ignore an invalid range header', function () {
|
||||
req.headers.range = 'potato'
|
||||
FileController.getFile(req, res, next)
|
||||
expect(FileHandler.getFile).to.have.been.calledWith(
|
||||
|
@ -192,7 +192,7 @@ describe('FileController', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it("should ignore any type other than 'bytes'", function() {
|
||||
it("should ignore any type other than 'bytes'", function () {
|
||||
req.headers.range = 'wombats=0-8'
|
||||
FileController.getFile(req, res, next)
|
||||
expect(FileHandler.getFile).to.have.been.calledWith(
|
||||
|
@ -204,8 +204,8 @@ describe('FileController', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('getFileHead', function() {
|
||||
it('should return the file size in a Content-Length header', function(done) {
|
||||
describe('getFileHead', function () {
|
||||
it('should return the file size in a Content-Length header', function (done) {
|
||||
res.end = () => {
|
||||
expect(res.status).to.have.been.calledWith(200)
|
||||
expect(res.set).to.have.been.calledWith('Content-Length', fileSize)
|
||||
|
@ -215,12 +215,12 @@ describe('FileController', function() {
|
|||
FileController.getFileHead(req, res, next)
|
||||
})
|
||||
|
||||
it('should return a 404 is the file is not found', function(done) {
|
||||
it('should return a 404 is the file is not found', function (done) {
|
||||
FileHandler.getFileSize.yields(
|
||||
new Errors.NotFoundError({ message: 'not found', info: {} })
|
||||
)
|
||||
|
||||
res.sendStatus = code => {
|
||||
res.sendStatus = (code) => {
|
||||
expect(code).to.equal(404)
|
||||
done()
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ describe('FileController', function() {
|
|||
FileController.getFileHead(req, res, next)
|
||||
})
|
||||
|
||||
it('should send an error on internal errors', function() {
|
||||
it('should send an error on internal errors', function () {
|
||||
FileHandler.getFileSize.yields(error)
|
||||
|
||||
FileController.getFileHead(req, res, next)
|
||||
|
@ -236,9 +236,9 @@ describe('FileController', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('insertFile', function() {
|
||||
it('should send bucket name key and res to PersistorManager', function(done) {
|
||||
res.sendStatus = code => {
|
||||
describe('insertFile', function () {
|
||||
it('should send bucket name key and res to PersistorManager', function (done) {
|
||||
res.sendStatus = (code) => {
|
||||
expect(FileHandler.insertFile).to.have.been.calledWith(bucket, key, req)
|
||||
expect(code).to.equal(200)
|
||||
done()
|
||||
|
@ -247,12 +247,12 @@ describe('FileController', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('copyFile', function() {
|
||||
describe('copyFile', function () {
|
||||
const oldFileId = 'oldFileId'
|
||||
const oldProjectId = 'oldProjectid'
|
||||
const oldKey = `${oldProjectId}/${oldFileId}`
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
req.body = {
|
||||
source: {
|
||||
project_id: oldProjectId,
|
||||
|
@ -261,8 +261,8 @@ describe('FileController', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should send bucket name and both keys to PersistorManager', function(done) {
|
||||
res.sendStatus = code => {
|
||||
it('should send bucket name and both keys to PersistorManager', function (done) {
|
||||
res.sendStatus = (code) => {
|
||||
code.should.equal(200)
|
||||
expect(PersistorManager.copyObject).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -274,29 +274,29 @@ describe('FileController', function() {
|
|||
FileController.copyFile(req, res, next)
|
||||
})
|
||||
|
||||
it('should send a 404 if the original file was not found', function(done) {
|
||||
it('should send a 404 if the original file was not found', function (done) {
|
||||
PersistorManager.copyObject.rejects(
|
||||
new Errors.NotFoundError({ message: 'not found', info: {} })
|
||||
)
|
||||
res.sendStatus = code => {
|
||||
res.sendStatus = (code) => {
|
||||
code.should.equal(404)
|
||||
done()
|
||||
}
|
||||
FileController.copyFile(req, res, next)
|
||||
})
|
||||
|
||||
it('should send an error if there was an error', function(done) {
|
||||
it('should send an error if there was an error', function (done) {
|
||||
PersistorManager.copyObject.rejects(error)
|
||||
FileController.copyFile(req, res, err => {
|
||||
FileController.copyFile(req, res, (err) => {
|
||||
expect(err).to.equal(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('delete file', function() {
|
||||
it('should tell the file handler', function(done) {
|
||||
res.sendStatus = code => {
|
||||
describe('delete file', function () {
|
||||
it('should tell the file handler', function (done) {
|
||||
res.sendStatus = (code) => {
|
||||
code.should.equal(204)
|
||||
expect(FileHandler.deleteFile).to.have.been.calledWith(bucket, key)
|
||||
done()
|
||||
|
@ -304,16 +304,16 @@ describe('FileController', function() {
|
|||
FileController.deleteFile(req, res, next)
|
||||
})
|
||||
|
||||
it('should send a 500 if there was an error', function() {
|
||||
it('should send a 500 if there was an error', function () {
|
||||
FileHandler.deleteFile.yields(error)
|
||||
FileController.deleteFile(req, res, next)
|
||||
expect(next).to.have.been.calledWith(error)
|
||||
})
|
||||
})
|
||||
|
||||
describe('delete project', function() {
|
||||
it('should tell the file handler', function(done) {
|
||||
res.sendStatus = code => {
|
||||
describe('delete project', function () {
|
||||
it('should tell the file handler', function (done) {
|
||||
res.sendStatus = (code) => {
|
||||
code.should.equal(204)
|
||||
expect(FileHandler.deleteProject).to.have.been.calledWith(bucket, key)
|
||||
done()
|
||||
|
@ -321,24 +321,24 @@ describe('FileController', function() {
|
|||
FileController.deleteProject(req, res, next)
|
||||
})
|
||||
|
||||
it('should send a 500 if there was an error', function() {
|
||||
it('should send a 500 if there was an error', function () {
|
||||
FileHandler.deleteProject.yields(error)
|
||||
FileController.deleteProject(req, res, next)
|
||||
expect(next).to.have.been.calledWith(error)
|
||||
})
|
||||
})
|
||||
|
||||
describe('directorySize', function() {
|
||||
it('should return total directory size bytes', function(done) {
|
||||
describe('directorySize', function () {
|
||||
it('should return total directory size bytes', function (done) {
|
||||
FileController.directorySize(req, {
|
||||
json: result => {
|
||||
json: (result) => {
|
||||
expect(result['total bytes']).to.equal(fileSize)
|
||||
done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should send a 500 if there was an error', function() {
|
||||
it('should send a 500 if there was an error', function () {
|
||||
FileHandler.getDirectorySize.yields(error)
|
||||
FileController.directorySize(req, res, next)
|
||||
expect(next).to.have.been.calledWith(error)
|
||||
|
|
|
@ -6,7 +6,7 @@ const { Errors } = require('@overleaf/object-persistor')
|
|||
|
||||
const modulePath = '../../../app/js/FileConverter.js'
|
||||
|
||||
describe('FileConverter', function() {
|
||||
describe('FileConverter', function () {
|
||||
let SafeExec, FileConverter
|
||||
const sourcePath = '/data/wombat.eps'
|
||||
const destPath = '/tmp/dest.png'
|
||||
|
@ -18,7 +18,7 @@ describe('FileConverter', function() {
|
|||
}
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
SafeExec = {
|
||||
promises: sinon.stub().resolves(destPath)
|
||||
}
|
||||
|
@ -38,20 +38,20 @@ describe('FileConverter', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('convert', function() {
|
||||
it('should convert the source to the requested format', async function() {
|
||||
describe('convert', function () {
|
||||
it('should convert the source to the requested format', async function () {
|
||||
await FileConverter.promises.convert(sourcePath, format)
|
||||
const args = SafeExec.promises.args[0][0]
|
||||
expect(args).to.include(`${sourcePath}[0]`)
|
||||
expect(args).to.include(`${sourcePath}.${format}`)
|
||||
})
|
||||
|
||||
it('should return the dest path', async function() {
|
||||
it('should return the dest path', async function () {
|
||||
const destPath = await FileConverter.promises.convert(sourcePath, format)
|
||||
destPath.should.equal(`${sourcePath}.${format}`)
|
||||
})
|
||||
|
||||
it('should wrap the error from convert', async function() {
|
||||
it('should wrap the error from convert', async function () {
|
||||
SafeExec.promises.rejects(errorMessage)
|
||||
try {
|
||||
await FileConverter.promises.convert(sourcePath, format)
|
||||
|
@ -62,7 +62,7 @@ describe('FileConverter', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should not accept an non approved format', async function() {
|
||||
it('should not accept an non approved format', async function () {
|
||||
try {
|
||||
await FileConverter.promises.convert(sourcePath, 'potato')
|
||||
expect('error should have been thrown').not.to.exist
|
||||
|
@ -71,12 +71,12 @@ describe('FileConverter', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should prefix the command with Settings.commands.convertCommandPrefix', async function() {
|
||||
it('should prefix the command with Settings.commands.convertCommandPrefix', async function () {
|
||||
Settings.commands.convertCommandPrefix = ['nice']
|
||||
await FileConverter.promises.convert(sourcePath, format)
|
||||
})
|
||||
|
||||
it('should convert the file when called as a callback', function(done) {
|
||||
it('should convert the file when called as a callback', function (done) {
|
||||
FileConverter.convert(sourcePath, format, (err, destPath) => {
|
||||
expect(err).not.to.exist
|
||||
destPath.should.equal(`${sourcePath}.${format}`)
|
||||
|
@ -89,16 +89,16 @@ describe('FileConverter', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('thumbnail', function() {
|
||||
it('should call converter resize with args', async function() {
|
||||
describe('thumbnail', function () {
|
||||
it('should call converter resize with args', async function () {
|
||||
await FileConverter.promises.thumbnail(sourcePath)
|
||||
const args = SafeExec.promises.args[0][0]
|
||||
expect(args).to.include(`${sourcePath}[0]`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('preview', function() {
|
||||
it('should call converter resize with args', async function() {
|
||||
describe('preview', function () {
|
||||
it('should call converter resize with args', async function () {
|
||||
await FileConverter.promises.preview(sourcePath)
|
||||
const args = SafeExec.promises.args[0][0]
|
||||
expect(args).to.include(`${sourcePath}[0]`)
|
||||
|
|
|
@ -9,7 +9,7 @@ const { Errors } = require('@overleaf/object-persistor')
|
|||
chai.use(require('sinon-chai'))
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
describe('FileHandler', function() {
|
||||
describe('FileHandler', function () {
|
||||
let PersistorManager,
|
||||
LocalFileWriter,
|
||||
FileConverter,
|
||||
|
@ -31,7 +31,7 @@ describe('FileHandler', function() {
|
|||
on: sinon.stub()
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
PersistorManager = {
|
||||
getObjectStream: sinon.stub().resolves(sourceStream),
|
||||
getRedirectUrl: sinon.stub().resolves(redirectUrl),
|
||||
|
@ -89,11 +89,11 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('insertFile', function() {
|
||||
describe('insertFile', function () {
|
||||
const stream = 'stream'
|
||||
|
||||
it('should send file to the filestore', function(done) {
|
||||
FileHandler.insertFile(bucket, key, stream, err => {
|
||||
it('should send file to the filestore', function (done) {
|
||||
FileHandler.insertFile(bucket, key, stream, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.sendStream).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -104,39 +104,39 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should not make a delete request for the convertedKey folder', function(done) {
|
||||
FileHandler.insertFile(bucket, key, stream, err => {
|
||||
it('should not make a delete request for the convertedKey folder', function (done) {
|
||||
FileHandler.insertFile(bucket, key, stream, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteDirectory).not.to.have.been.called
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should accept templates-api key format', function(done) {
|
||||
it('should accept templates-api key format', function (done) {
|
||||
KeyBuilder.getConvertedFolderKey.returns(
|
||||
'5ecba29f1a294e007d0bccb4/v/0/pdf'
|
||||
)
|
||||
FileHandler.insertFile(bucket, key, stream, err => {
|
||||
FileHandler.insertFile(bucket, key, stream, (err) => {
|
||||
expect(err).not.to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw an error when the key is in the wrong format', function(done) {
|
||||
it('should throw an error when the key is in the wrong format', function (done) {
|
||||
KeyBuilder.getConvertedFolderKey.returns('wombat')
|
||||
FileHandler.insertFile(bucket, key, stream, err => {
|
||||
FileHandler.insertFile(bucket, key, stream, (err) => {
|
||||
expect(err).to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('when conversions are enabled', function() {
|
||||
beforeEach(function() {
|
||||
describe('when conversions are enabled', function () {
|
||||
beforeEach(function () {
|
||||
Settings.enableConversions = true
|
||||
})
|
||||
|
||||
it('should delete the convertedKey folder', function(done) {
|
||||
FileHandler.insertFile(bucket, key, stream, err => {
|
||||
it('should delete the convertedKey folder', function (done) {
|
||||
FileHandler.insertFile(bucket, key, stream, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -148,9 +148,9 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('deleteFile', function() {
|
||||
it('should tell the filestore manager to delete the file', function(done) {
|
||||
FileHandler.deleteFile(bucket, key, err => {
|
||||
describe('deleteFile', function () {
|
||||
it('should tell the filestore manager to delete the file', function (done) {
|
||||
FileHandler.deleteFile(bucket, key, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteObject).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -160,39 +160,39 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should not tell the filestore manager to delete the cached folder', function(done) {
|
||||
FileHandler.deleteFile(bucket, key, err => {
|
||||
it('should not tell the filestore manager to delete the cached folder', function (done) {
|
||||
FileHandler.deleteFile(bucket, key, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteDirectory).not.to.have.been.called
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should accept templates-api key format', function(done) {
|
||||
it('should accept templates-api key format', function (done) {
|
||||
KeyBuilder.getConvertedFolderKey.returns(
|
||||
'5ecba29f1a294e007d0bccb4/v/0/pdf'
|
||||
)
|
||||
FileHandler.deleteFile(bucket, key, err => {
|
||||
FileHandler.deleteFile(bucket, key, (err) => {
|
||||
expect(err).not.to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw an error when the key is in the wrong format', function(done) {
|
||||
it('should throw an error when the key is in the wrong format', function (done) {
|
||||
KeyBuilder.getConvertedFolderKey.returns('wombat')
|
||||
FileHandler.deleteFile(bucket, key, err => {
|
||||
FileHandler.deleteFile(bucket, key, (err) => {
|
||||
expect(err).to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('when conversions are enabled', function() {
|
||||
beforeEach(function() {
|
||||
describe('when conversions are enabled', function () {
|
||||
beforeEach(function () {
|
||||
Settings.enableConversions = true
|
||||
})
|
||||
|
||||
it('should delete the convertedKey folder', function(done) {
|
||||
FileHandler.deleteFile(bucket, key, err => {
|
||||
it('should delete the convertedKey folder', function (done) {
|
||||
FileHandler.deleteFile(bucket, key, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -204,9 +204,9 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('deleteProject', function() {
|
||||
it('should tell the filestore manager to delete the folder', function(done) {
|
||||
FileHandler.deleteProject(bucket, projectKey, err => {
|
||||
describe('deleteProject', function () {
|
||||
it('should tell the filestore manager to delete the folder', function (done) {
|
||||
FileHandler.deleteProject(bucket, projectKey, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -216,16 +216,16 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should throw an error when the key is in the wrong format', function(done) {
|
||||
FileHandler.deleteProject(bucket, 'wombat', err => {
|
||||
it('should throw an error when the key is in the wrong format', function (done) {
|
||||
FileHandler.deleteProject(bucket, 'wombat', (err) => {
|
||||
expect(err).to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getFile', function() {
|
||||
it('should return the source stream no format or style are defined', function(done) {
|
||||
describe('getFile', function () {
|
||||
it('should return the source stream no format or style are defined', function (done) {
|
||||
FileHandler.getFile(bucket, key, null, (err, stream) => {
|
||||
expect(err).not.to.exist
|
||||
expect(stream).to.equal(sourceStream)
|
||||
|
@ -233,9 +233,9 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should pass options through to PersistorManager', function(done) {
|
||||
it('should pass options through to PersistorManager', function (done) {
|
||||
const options = { start: 0, end: 8 }
|
||||
FileHandler.getFile(bucket, key, options, err => {
|
||||
FileHandler.getFile(bucket, key, options, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.getObjectStream).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -246,26 +246,26 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when a format is defined', function() {
|
||||
describe('when a format is defined', function () {
|
||||
let result
|
||||
|
||||
describe('when the file is not cached', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('when the file is not cached', function () {
|
||||
beforeEach(function (done) {
|
||||
FileHandler.getFile(bucket, key, { format: 'png' }, (err, stream) => {
|
||||
result = { err, stream }
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should convert the file', function() {
|
||||
it('should convert the file', function () {
|
||||
expect(FileConverter.promises.convert).to.have.been.called
|
||||
})
|
||||
|
||||
it('should compress the converted file', function() {
|
||||
it('should compress the converted file', function () {
|
||||
expect(ImageOptimiser.promises.compressPng).to.have.been.called
|
||||
})
|
||||
|
||||
it('should return the the converted stream', function() {
|
||||
it('should return the the converted stream', function () {
|
||||
expect(result.err).not.to.exist
|
||||
expect(result.stream).to.equal(readStream)
|
||||
expect(PersistorManager.getObjectStream).to.have.been.calledWith(
|
||||
|
@ -275,8 +275,8 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when the file is cached', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('when the file is cached', function () {
|
||||
beforeEach(function (done) {
|
||||
PersistorManager.checkIfObjectExists = sinon.stub().resolves(true)
|
||||
FileHandler.getFile(bucket, key, { format: 'png' }, (err, stream) => {
|
||||
result = { err, stream }
|
||||
|
@ -284,15 +284,15 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should not convert the file', function() {
|
||||
it('should not convert the file', function () {
|
||||
expect(FileConverter.promises.convert).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should not compress the converted file again', function() {
|
||||
it('should not compress the converted file again', function () {
|
||||
expect(ImageOptimiser.promises.compressPng).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should return the cached stream', function() {
|
||||
it('should return the cached stream', function () {
|
||||
expect(result.err).not.to.exist
|
||||
expect(result.stream).to.equal(sourceStream)
|
||||
expect(PersistorManager.getObjectStream).to.have.been.calledWith(
|
||||
|
@ -303,9 +303,9 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when a style is defined', function() {
|
||||
it('generates a thumbnail when requested', function(done) {
|
||||
FileHandler.getFile(bucket, key, { style: 'thumbnail' }, err => {
|
||||
describe('when a style is defined', function () {
|
||||
it('generates a thumbnail when requested', function (done) {
|
||||
FileHandler.getFile(bucket, key, { style: 'thumbnail' }, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(FileConverter.promises.thumbnail).to.have.been.called
|
||||
expect(FileConverter.promises.preview).not.to.have.been.called
|
||||
|
@ -313,8 +313,8 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('generates a preview when requested', function(done) {
|
||||
FileHandler.getFile(bucket, key, { style: 'preview' }, err => {
|
||||
it('generates a preview when requested', function (done) {
|
||||
FileHandler.getFile(bucket, key, { style: 'preview' }, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(FileConverter.promises.thumbnail).not.to.have.been.called
|
||||
expect(FileConverter.promises.preview).to.have.been.called
|
||||
|
@ -324,8 +324,8 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('getRedirectUrl', function() {
|
||||
beforeEach(function() {
|
||||
describe('getRedirectUrl', function () {
|
||||
beforeEach(function () {
|
||||
Settings.filestore = {
|
||||
allowRedirects: true,
|
||||
stores: {
|
||||
|
@ -334,7 +334,7 @@ describe('FileHandler', function() {
|
|||
}
|
||||
})
|
||||
|
||||
it('should return a redirect url', function(done) {
|
||||
it('should return a redirect url', function (done) {
|
||||
FileHandler.getRedirectUrl(bucket, key, (err, url) => {
|
||||
expect(err).not.to.exist
|
||||
expect(url).to.equal(redirectUrl)
|
||||
|
@ -342,7 +342,7 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should call the persistor to get a redirect url', function(done) {
|
||||
it('should call the persistor to get a redirect url', function (done) {
|
||||
FileHandler.getRedirectUrl(bucket, key, () => {
|
||||
expect(PersistorManager.getRedirectUrl).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
@ -352,7 +352,7 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should return null if options are supplied', function(done) {
|
||||
it('should return null if options are supplied', function (done) {
|
||||
FileHandler.getRedirectUrl(
|
||||
bucket,
|
||||
key,
|
||||
|
@ -365,7 +365,7 @@ describe('FileHandler', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should return null if the bucket is not one of the defined ones', function(done) {
|
||||
it('should return null if the bucket is not one of the defined ones', function (done) {
|
||||
FileHandler.getRedirectUrl('a_different_bucket', key, (err, url) => {
|
||||
expect(err).not.to.exist
|
||||
expect(url).to.be.null
|
||||
|
@ -373,7 +373,7 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should return null if redirects are not enabled', function(done) {
|
||||
it('should return null if redirects are not enabled', function (done) {
|
||||
Settings.filestore.allowRedirects = false
|
||||
FileHandler.getRedirectUrl(bucket, key, (err, url) => {
|
||||
expect(err).not.to.exist
|
||||
|
@ -383,9 +383,9 @@ describe('FileHandler', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('getDirectorySize', function() {
|
||||
it('should call the filestore manager to get directory size', function(done) {
|
||||
FileHandler.getDirectorySize(bucket, key, err => {
|
||||
describe('getDirectorySize', function () {
|
||||
it('should call the filestore manager to get directory size', function (done) {
|
||||
FileHandler.getDirectorySize(bucket, key, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(PersistorManager.directorySize).to.have.been.calledWith(
|
||||
bucket,
|
||||
|
|
|
@ -5,11 +5,11 @@ const modulePath = '../../../app/js/ImageOptimiser.js'
|
|||
const { FailedCommandError } = require('../../../app/js/Errors')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('ImageOptimiser', function() {
|
||||
describe('ImageOptimiser', function () {
|
||||
let ImageOptimiser, SafeExec, logger
|
||||
const sourcePath = '/wombat/potato.eps'
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
SafeExec = {
|
||||
promises: sinon.stub().resolves()
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ describe('ImageOptimiser', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('compressPng', function() {
|
||||
it('should convert the file', function(done) {
|
||||
ImageOptimiser.compressPng(sourcePath, err => {
|
||||
describe('compressPng', function () {
|
||||
it('should convert the file', function (done) {
|
||||
ImageOptimiser.compressPng(sourcePath, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(SafeExec.promises).to.have.been.calledWith([
|
||||
'optipng',
|
||||
|
@ -39,32 +39,32 @@ describe('ImageOptimiser', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should return the error', function(done) {
|
||||
it('should return the error', function (done) {
|
||||
SafeExec.promises.rejects('wombat herding failure')
|
||||
ImageOptimiser.compressPng(sourcePath, err => {
|
||||
ImageOptimiser.compressPng(sourcePath, (err) => {
|
||||
expect(err.toString()).to.equal('wombat herding failure')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when optimiser is sigkilled', function() {
|
||||
describe('when optimiser is sigkilled', function () {
|
||||
const expectedError = new FailedCommandError('', 'SIGKILL', '', '')
|
||||
let error
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
SafeExec.promises.rejects(expectedError)
|
||||
ImageOptimiser.compressPng(sourcePath, err => {
|
||||
ImageOptimiser.compressPng(sourcePath, (err) => {
|
||||
error = err
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function() {
|
||||
it('should not produce an error', function () {
|
||||
expect(error).not.to.exist
|
||||
})
|
||||
|
||||
it('should log a warning', function() {
|
||||
it('should log a warning', function () {
|
||||
expect(logger.warn).to.have.been.calledOnce
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2,30 +2,30 @@ const SandboxedModule = require('sandboxed-module')
|
|||
|
||||
const modulePath = '../../../app/js/KeyBuilder.js'
|
||||
|
||||
describe('KeybuilderTests', function() {
|
||||
describe('KeybuilderTests', function () {
|
||||
let KeyBuilder
|
||||
const key = 'wombat/potato'
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
KeyBuilder = SandboxedModule.require(modulePath, {
|
||||
requires: { 'settings-sharelatex': {} }
|
||||
})
|
||||
})
|
||||
|
||||
describe('cachedKey', function() {
|
||||
it('should add the format to the key', function() {
|
||||
describe('cachedKey', function () {
|
||||
it('should add the format to the key', function () {
|
||||
const opts = { format: 'png' }
|
||||
const newKey = KeyBuilder.addCachingToKey(key, opts)
|
||||
newKey.should.equal(`${key}-converted-cache/format-png`)
|
||||
})
|
||||
|
||||
it('should add the style to the key', function() {
|
||||
it('should add the style to the key', function () {
|
||||
const opts = { style: 'thumbnail' }
|
||||
const newKey = KeyBuilder.addCachingToKey(key, opts)
|
||||
newKey.should.equal(`${key}-converted-cache/style-thumbnail`)
|
||||
})
|
||||
|
||||
it('should add format first, then style', function() {
|
||||
it('should add format first, then style', function () {
|
||||
const opts = {
|
||||
style: 'thumbnail',
|
||||
format: 'png'
|
||||
|
|
|
@ -6,7 +6,7 @@ const SandboxedModule = require('sandboxed-module')
|
|||
const { Errors } = require('@overleaf/object-persistor')
|
||||
chai.use(require('sinon-chai'))
|
||||
|
||||
describe('LocalFileWriter', function() {
|
||||
describe('LocalFileWriter', function () {
|
||||
const writeStream = 'writeStream'
|
||||
const readStream = 'readStream'
|
||||
const settings = { path: { uploadFolder: '/uploads' } }
|
||||
|
@ -14,7 +14,7 @@ describe('LocalFileWriter', function() {
|
|||
const filename = 'wombat'
|
||||
let stream, fs, LocalFileWriter
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
fs = {
|
||||
createWriteStream: sinon.stub().returns(writeStream),
|
||||
unlink: sinon.stub().yields()
|
||||
|
@ -39,8 +39,8 @@ describe('LocalFileWriter', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('writeStream', function() {
|
||||
it('writes the stream to the upload folder', function(done) {
|
||||
describe('writeStream', function () {
|
||||
it('writes the stream to the upload folder', function (done) {
|
||||
LocalFileWriter.writeStream(readStream, filename, (err, path) => {
|
||||
expect(err).not.to.exist
|
||||
expect(fs.createWriteStream).to.have.been.calledWith(fsPath)
|
||||
|
@ -50,20 +50,20 @@ describe('LocalFileWriter', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when there is an error', function() {
|
||||
describe('when there is an error', function () {
|
||||
const error = new Error('not enough ketchup')
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
stream.pipeline.yields(error)
|
||||
})
|
||||
|
||||
it('should wrap the error', function() {
|
||||
LocalFileWriter.writeStream(readStream, filename, err => {
|
||||
it('should wrap the error', function () {
|
||||
LocalFileWriter.writeStream(readStream, filename, (err) => {
|
||||
expect(err).to.exist
|
||||
expect(err.cause).to.equal(error)
|
||||
})
|
||||
})
|
||||
|
||||
it('should delete the temporary file', function() {
|
||||
it('should delete the temporary file', function () {
|
||||
LocalFileWriter.writeStream(readStream, filename, () => {
|
||||
expect(fs.unlink).to.have.been.calledWith(fsPath)
|
||||
})
|
||||
|
@ -71,37 +71,37 @@ describe('LocalFileWriter', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('deleteFile', function() {
|
||||
it('should unlink the file', function(done) {
|
||||
LocalFileWriter.deleteFile(fsPath, err => {
|
||||
describe('deleteFile', function () {
|
||||
it('should unlink the file', function (done) {
|
||||
LocalFileWriter.deleteFile(fsPath, (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(fs.unlink).to.have.been.calledWith(fsPath)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call unlink with an empty path', function(done) {
|
||||
LocalFileWriter.deleteFile('', err => {
|
||||
it('should not call unlink with an empty path', function (done) {
|
||||
LocalFileWriter.deleteFile('', (err) => {
|
||||
expect(err).not.to.exist
|
||||
expect(fs.unlink).not.to.have.been.called
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not throw a error if the file does not exist', function(done) {
|
||||
it('should not throw a error if the file does not exist', function (done) {
|
||||
const error = new Error('file not found')
|
||||
error.code = 'ENOENT'
|
||||
fs.unlink = sinon.stub().yields(error)
|
||||
LocalFileWriter.deleteFile(fsPath, err => {
|
||||
LocalFileWriter.deleteFile(fsPath, (err) => {
|
||||
expect(err).not.to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should wrap the error', function(done) {
|
||||
it('should wrap the error', function (done) {
|
||||
const error = new Error('failed to reticulate splines')
|
||||
fs.unlink = sinon.stub().yields(error)
|
||||
LocalFileWriter.deleteFile(fsPath, err => {
|
||||
LocalFileWriter.deleteFile(fsPath, (err) => {
|
||||
expect(err).to.exist
|
||||
expect(err.cause).to.equal(error)
|
||||
done()
|
||||
|
|
|
@ -5,10 +5,10 @@ const modulePath = '../../../app/js/SafeExec'
|
|||
const { Errors } = require('@overleaf/object-persistor')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('SafeExec', function() {
|
||||
describe('SafeExec', function () {
|
||||
let settings, options, safeExec
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
settings = { enableConversions: true }
|
||||
options = { timeout: 10 * 1000, killSignal: 'SIGTERM' }
|
||||
|
||||
|
@ -23,8 +23,8 @@ describe('SafeExec', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('safeExec', function() {
|
||||
it('should execute a valid command', function(done) {
|
||||
describe('safeExec', function () {
|
||||
it('should execute a valid command', function (done) {
|
||||
safeExec(['/bin/echo', 'hello'], options, (err, stdout, stderr) => {
|
||||
stdout.should.equal('hello\n')
|
||||
stderr.should.equal('')
|
||||
|
@ -33,16 +33,16 @@ describe('SafeExec', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should error when conversions are disabled', function(done) {
|
||||
it('should error when conversions are disabled', function (done) {
|
||||
settings.enableConversions = false
|
||||
safeExec(['/bin/echo', 'hello'], options, err => {
|
||||
safeExec(['/bin/echo', 'hello'], options, (err) => {
|
||||
expect(err).to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should execute a command with non-zero exit status', function(done) {
|
||||
safeExec(['/usr/bin/env', 'false'], options, err => {
|
||||
it('should execute a command with non-zero exit status', function (done) {
|
||||
safeExec(['/usr/bin/env', 'false'], options, (err) => {
|
||||
expect(err).to.exist
|
||||
expect(err.name).to.equal('FailedCommandError')
|
||||
expect(err.code).to.equal(1)
|
||||
|
@ -52,18 +52,18 @@ describe('SafeExec', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should handle an invalid command', function(done) {
|
||||
safeExec(['/bin/foobar'], options, err => {
|
||||
it('should handle an invalid command', function (done) {
|
||||
safeExec(['/bin/foobar'], options, (err) => {
|
||||
err.code.should.equal('ENOENT')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should handle a command that runs too long', function(done) {
|
||||
it('should handle a command that runs too long', function (done) {
|
||||
safeExec(
|
||||
['/bin/sleep', '10'],
|
||||
{ timeout: 500, killSignal: 'SIGTERM' },
|
||||
err => {
|
||||
(err) => {
|
||||
expect(err).to.exist
|
||||
expect(err.name).to.equal('FailedCommandError')
|
||||
expect(err.code).to.equal('SIGTERM')
|
||||
|
@ -73,19 +73,19 @@ describe('SafeExec', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('as a promise', function() {
|
||||
beforeEach(function() {
|
||||
describe('as a promise', function () {
|
||||
beforeEach(function () {
|
||||
safeExec = safeExec.promises
|
||||
})
|
||||
|
||||
it('should execute a valid command', async function() {
|
||||
it('should execute a valid command', async function () {
|
||||
const { stdout, stderr } = await safeExec(['/bin/echo', 'hello'], options)
|
||||
|
||||
stdout.should.equal('hello\n')
|
||||
stderr.should.equal('')
|
||||
})
|
||||
|
||||
it('should throw a ConversionsDisabledError when appropriate', async function() {
|
||||
it('should throw a ConversionsDisabledError when appropriate', async function () {
|
||||
settings.enableConversions = false
|
||||
try {
|
||||
await safeExec(['/bin/echo', 'hello'], options)
|
||||
|
@ -96,7 +96,7 @@ describe('SafeExec', function() {
|
|||
expect('method did not throw an error').not.to.exist
|
||||
})
|
||||
|
||||
it('should throw a FailedCommandError when appropriate', async function() {
|
||||
it('should throw a FailedCommandError when appropriate', async function () {
|
||||
try {
|
||||
await safeExec(['/usr/bin/env', 'false'], options)
|
||||
} catch (err) {
|
||||
|
|
|
@ -2,9 +2,9 @@ const chai = require('chai')
|
|||
const { expect } = chai
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('Settings', function() {
|
||||
describe('s3', function() {
|
||||
it('should use JSONified env var if present', function() {
|
||||
describe('Settings', function () {
|
||||
describe('s3', function () {
|
||||
it('should use JSONified env var if present', function () {
|
||||
const s3Settings = {
|
||||
bucket1: {
|
||||
auth_key: 'bucket1_key',
|
||||
|
|
Loading…
Reference in a new issue