Skip to content

Commit

Permalink
feat(middleware): add rate limit on sessions endpoint only
Browse files Browse the repository at this point in the history
  • Loading branch information
aprendendofelipe authored and filipedeschamps committed Aug 16, 2022
1 parent 62d28ef commit daafb3d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion middleware.public.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import rateLimit from 'infra/rate-limit.js';
import snakeize from 'snakeize';

export const config = {
matcher: ['/api/:path*'],
matcher: ['/api/v1/sessions'],
};

export async function middleware(request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ describe('PATCH /api/v1/contents/[username]/[slug]', () => {
expect(responseBody.error_location_code).toEqual('MODEL:VALIDATOR:FINAL_SCHEMA');
});

test('Content with "body" containing more than 16.000 characters', async () => {
test('Content with "body" containing more than 20.000 characters', async () => {
const defaultUser = await orchestrator.createUser();
await orchestrator.activateUser(defaultUser);
const sessionObject = await orchestrator.createSession(defaultUser);
Expand Down Expand Up @@ -535,7 +535,7 @@ describe('PATCH /api/v1/contents/[username]/[slug]', () => {
expect(response.status).toEqual(400);
expect(responseBody.status_code).toEqual(400);
expect(responseBody.name).toEqual('ValidationError');
expect(responseBody.message).toEqual('"body" deve conter no máximo 16000 caracteres.');
expect(responseBody.message).toEqual('"body" deve conter no máximo 20000 caracteres.');
expect(responseBody.action).toEqual('Ajuste os dados enviados e tente novamente.');
expect(uuidVersion(responseBody.error_id)).toEqual(4);
expect(uuidVersion(responseBody.request_id)).toEqual(4);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/api/v1/contents/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('POST /api/v1/contents', () => {
expect(responseBody.error_location_code).toEqual('MODEL:VALIDATOR:FINAL_SCHEMA');
});

test('Content with "body" containing more than 16.000 characters', async () => {
test('Content with "body" containing more than 20.000 characters', async () => {
const defaultUser = await orchestrator.createUser();
await orchestrator.activateUser(defaultUser);
const sessionObject = await orchestrator.createSession(defaultUser);
Expand All @@ -291,7 +291,7 @@ describe('POST /api/v1/contents', () => {
expect(response.status).toEqual(400);
expect(responseBody.status_code).toEqual(400);
expect(responseBody.name).toEqual('ValidationError');
expect(responseBody.message).toEqual('"body" deve conter no máximo 16000 caracteres.');
expect(responseBody.message).toEqual('"body" deve conter no máximo 20000 caracteres.');
expect(responseBody.action).toEqual('Ajuste os dados enviados e tente novamente.');
expect(uuidVersion(responseBody.error_id)).toEqual(4);
expect(uuidVersion(responseBody.request_id)).toEqual(4);
Expand Down

0 comments on commit daafb3d

Please sign in to comment.