You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Tools: Fixed tests
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
// We don't want the tests to fail due to timeout, especially on CI, and certain
|
// We don't want the tests to fail due to timeout, especially on CI, and certain
|
||||||
// tests can take more time since we do integration testing too.
|
// tests can take more time since we do integration testing too.
|
||||||
jest.setTimeout(30 * 1000);
|
jest.setTimeout(30 * 1000);
|
||||||
|
|
||||||
|
process.env.JOPLIN_IS_TESTING = '1';
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default async function(ctx: AppContext) {
|
|||||||
|
|
||||||
const responseFormat = routeResponseFormat(ctx);
|
const responseFormat = routeResponseFormat(ctx);
|
||||||
|
|
||||||
if (error.retryAfterMs) ctx.set('Retry-After', Math.ceil(error.retryAfterMs / 1000).toString());
|
if (error.retryAfterMs) ctx.response.set('Retry-After', Math.ceil(error.retryAfterMs / 1000).toString());
|
||||||
|
|
||||||
if (error.code === 'invalidOrigin') {
|
if (error.code === 'invalidOrigin') {
|
||||||
ctx.response.body = error.message;
|
ctx.response.body = error.message;
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ import { RateLimiterMemory, RateLimiterRes } from 'rate-limiter-flexible';
|
|||||||
import { ErrorTooManyRequests } from '../errors';
|
import { ErrorTooManyRequests } from '../errors';
|
||||||
|
|
||||||
const limiterSlowBruteByIP = new RateLimiterMemory({
|
const limiterSlowBruteByIP = new RateLimiterMemory({
|
||||||
points: 3, // Up to 3 request per IP
|
points: 3, // Up to 3 requests per IP
|
||||||
duration: 30, // Per 30 seconds
|
duration: 30, // Per 30 seconds
|
||||||
});
|
});
|
||||||
|
|
||||||
export default async function(ip: string) {
|
export default async function(ip: string) {
|
||||||
|
// Tests need to make many requests quickly so we disable it in this case.
|
||||||
|
if (process.env.JOPLIN_IS_TESTING === '1') return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await limiterSlowBruteByIP.consume(ip);
|
await limiterSlowBruteByIP.consume(ip);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user