diff --git a/deploy/api-test/datasets/mouse.2015.spec.js b/deploy/api-test/datasets/mouse.2015.e2e-spec.js similarity index 100% rename from deploy/api-test/datasets/mouse.2015.spec.js rename to deploy/api-test/datasets/mouse.2015.e2e-spec.js diff --git a/deploy/api-test/datasets/mouse.2017.spec.js b/deploy/api-test/datasets/mouse.2017.e2e-spec.js similarity index 100% rename from deploy/api-test/datasets/mouse.2017.spec.js rename to deploy/api-test/datasets/mouse.2017.e2e-spec.js diff --git a/deploy/api-test/datasets/rat.v1_01.spec.js b/deploy/api-test/datasets/rat.v1_01.e2e-spec.js similarity index 100% rename from deploy/api-test/datasets/rat.v1_01.spec.js rename to deploy/api-test/datasets/rat.v1_01.e2e-spec.js diff --git a/deploy/api-test/datasets/rat.v2.spec.js b/deploy/api-test/datasets/rat.v2.e2e-spec.js similarity index 100% rename from deploy/api-test/datasets/rat.v2.spec.js rename to deploy/api-test/datasets/rat.v2.e2e-spec.js diff --git a/deploy/api-test/datasets/rat.v3.spec.js b/deploy/api-test/datasets/rat.v3.e2e-spec.js similarity index 100% rename from deploy/api-test/datasets/rat.v3.spec.js rename to deploy/api-test/datasets/rat.v3.e2e-spec.js diff --git a/deploy/package.json b/deploy/package.json index 87307b5943c9c15b55431d850de58fbe8721bba9..70050ceae9bbb9bf2829bacfc8f615ef92140f66 100644 --- a/deploy/package.json +++ b/deploy/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "start": "node server.js", - "test": "DISABLE_LIMITER=1 node -r dotenv/config ./node_modules/.bin/mocha ./**/*.spec.js --timeout 60000", + "test": "DISABLE_LIMITER=1 node -r dotenv/config ./node_modules/.bin/mocha './**/*.spec.js' --exclude 'node_modules/*' --timeout 60000", "mocha": "mocha" }, "keywords": [], diff --git a/deploy/saneUrl/index.js b/deploy/saneUrl/index.js index 2bd62b67fefc3e72518515ef344e55b350a26d7f..d39c2cb2b96bea55fee864691b89ba63b5a73dd9 100644 --- a/deploy/saneUrl/index.js +++ b/deploy/saneUrl/index.js @@ -28,9 +28,21 @@ const redisProto = REDIS_PROTO || REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP const redisAddr = REDIS_ADDR || REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_ADDR || null const redisPort = REDIS_PORT || REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_PORT || 6379 -const userPass = `${REDIS_USERNAME || ''}${( REDIS_PASSWORD && (':' + REDIS_PASSWORD)) || ''}${ (REDIS_USERNAME || REDIS_PASSWORD) && '@'}` - -const redisURL = redisAddr && `${redisProto}://${userPass}${redisAddr}:${redisPort}` +/** + * nb this way to set username and pswd can be risky, but given that site adnimistrator sets the username and pswd via env var + * it should not be a security concern + */ +const userPass = (() => { + let outstring = '' + if (!REDIS_USERNAME && !REDIS_PASSWORD) return outstring + if (REDIS_USERNAME) outstring += REDIS_USERNAME + if (outstring.length > 0) outstring += ':' + if (REDIS_PASSWORD) outstring += REDIS_PASSWORD + if (outstring.length > 0) outstring += '@' + return outstring +})() + +const redisURL = redisAddr && `${redisProto}://${userPass || ''}${redisAddr}:${redisPort}` const limiter = new RateLimit({ windowMs: 1e3 * 5,