Skip to content

Commit

Permalink
test: remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli authored and psychobunny committed Apr 19, 2021
1 parent 2ea468d commit 435067a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/middleware/uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const meta = require('../meta');
const helpers = require('./helpers');
const user = require('../user');

console.log('----cooldown', meta.config.uploadRateLimitCooldown * 1000, new Error('a').stack);
const cache = new LRU({
maxAge: meta.config.uploadRateLimitCooldown * 1000,
});
Expand All @@ -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;
console.log('req.ip', req.ip, count, req.files.files.length, meta.config.uploadRateLimitThreshold);
if (count > meta.config.uploadRateLimitThreshold) {
return next(new Error(['[[error:upload-ratelimit-reached]]']));
}
Expand Down
1 change: 0 additions & 1 deletion test/mocks/databasemock.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ async function setupMockDefaults() {
meta.config.initialPostDelay = 0;
meta.config.newbiePostDelay = 0;
meta.config.autoDetectLang = 0;
// meta.config.uploadRateLimitCooldown = 1;

await enableDefaultPlugins();

Expand Down
3 changes: 0 additions & 3 deletions test/uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,9 @@ describe('Upload Controllers', () => {
meta.config.allowedFileExtensions = 'png,jpg,bmp,html';
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.
console.log('times', (meta.config.uploadRateLimitThreshold / 2) + 1);
const times = (meta.config.uploadRateLimitThreshold / 2) + 1;
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) => {
console.log('limit upload', i, res.statusCode, meta.config.uploadRateLimitThreshold, i + 1 > meta.config.uploadRateLimitThreshold / 2, Date.now());

if (i + 1 >= times) {
assert.strictEqual(res.statusCode, 500);
assert.strictEqual(body.error, '[[error:upload-ratelimit-reached]]');
Expand Down

0 comments on commit 435067a

Please sign in to comment.