mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
test: remove logs
This commit is contained in:
committed by
Andrew Rodrigues
parent
2ea468daa3
commit
435067aa5f
@@ -5,7 +5,6 @@ const meta = require('../meta');
|
|||||||
const helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
|
|
||||||
console.log('----cooldown', meta.config.uploadRateLimitCooldown * 1000, new Error('a').stack);
|
|
||||||
const cache = new LRU({
|
const cache = new LRU({
|
||||||
maxAge: meta.config.uploadRateLimitCooldown * 1000,
|
maxAge: meta.config.uploadRateLimitCooldown * 1000,
|
||||||
});
|
});
|
||||||
@@ -21,7 +20,6 @@ exports.ratelimit = helpers.try(async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const count = (cache.peek(`${req.ip}:uploaded_file_count`) || 0) + req.files.files.length;
|
const count = (cache.peek(`${req.ip}:uploaded_file_count`) || 0) + req.files.files.length;
|
||||||
console.log('req.ip', req.ip, count, req.files.files.length, meta.config.uploadRateLimitThreshold);
|
|
||||||
if (count > meta.config.uploadRateLimitThreshold) {
|
if (count > meta.config.uploadRateLimitThreshold) {
|
||||||
return next(new Error(['[[error:upload-ratelimit-reached]]']));
|
return next(new Error(['[[error:upload-ratelimit-reached]]']));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ async function setupMockDefaults() {
|
|||||||
meta.config.initialPostDelay = 0;
|
meta.config.initialPostDelay = 0;
|
||||||
meta.config.newbiePostDelay = 0;
|
meta.config.newbiePostDelay = 0;
|
||||||
meta.config.autoDetectLang = 0;
|
meta.config.autoDetectLang = 0;
|
||||||
// meta.config.uploadRateLimitCooldown = 1;
|
|
||||||
|
|
||||||
await enableDefaultPlugins();
|
await enableDefaultPlugins();
|
||||||
|
|
||||||
|
|||||||
@@ -81,12 +81,9 @@ describe('Upload Controllers', () => {
|
|||||||
meta.config.allowedFileExtensions = 'png,jpg,bmp,html';
|
meta.config.allowedFileExtensions = 'png,jpg,bmp,html';
|
||||||
require('../src/middleware/uploads').clearCache();
|
require('../src/middleware/uploads').clearCache();
|
||||||
// why / 2? see: helpers.uploadFile for a weird quirk where we actually upload 2 files per upload in our tests.
|
// why / 2? see: helpers.uploadFile for a weird quirk where we actually upload 2 files per upload in our tests.
|
||||||
console.log('times', (meta.config.uploadRateLimitThreshold / 2) + 1);
|
|
||||||
const times = (meta.config.uploadRateLimitThreshold / 2) + 1;
|
const times = (meta.config.uploadRateLimitThreshold / 2) + 1;
|
||||||
async.timesSeries(times, (i, next) => {
|
async.timesSeries(times, (i, next) => {
|
||||||
helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/503.html'), {}, jar, csrf_token, (err, res, body) => {
|
helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/503.html'), {}, jar, csrf_token, (err, res, body) => {
|
||||||
console.log('limit upload', i, res.statusCode, meta.config.uploadRateLimitThreshold, i + 1 > meta.config.uploadRateLimitThreshold / 2, Date.now());
|
|
||||||
|
|
||||||
if (i + 1 >= times) {
|
if (i + 1 >= times) {
|
||||||
assert.strictEqual(res.statusCode, 500);
|
assert.strictEqual(res.statusCode, 500);
|
||||||
assert.strictEqual(body.error, '[[error:upload-ratelimit-reached]]');
|
assert.strictEqual(body.error, '[[error:upload-ratelimit-reached]]');
|
||||||
|
|||||||
Reference in New Issue
Block a user