mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
IP Blocking (#12015)
* start implementing an ip blocker * fix comments and add to list of middlewares * fix code, comment code and improve response * wip tests * fix order * fixes and tests
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
CustomError,
|
||||
NotAuthorized,
|
||||
BadRequest,
|
||||
Forbidden,
|
||||
InternalServerError,
|
||||
NotFound,
|
||||
NotificationNotFound,
|
||||
@@ -113,6 +114,32 @@ describe('Custom Errors', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Forbidden', () => {
|
||||
it('is an instance of CustomError', () => {
|
||||
const forbiddenError = new Forbidden();
|
||||
|
||||
expect(forbiddenError).to.be.an.instanceOf(CustomError);
|
||||
});
|
||||
|
||||
it('it returns an http code of 401', () => {
|
||||
const forbiddenError = new Forbidden();
|
||||
|
||||
expect(forbiddenError.httpCode).to.eql(403);
|
||||
});
|
||||
|
||||
it('returns a default message', () => {
|
||||
const forbiddenError = new Forbidden();
|
||||
|
||||
expect(forbiddenError.message).to.eql('Access forbidden.');
|
||||
});
|
||||
|
||||
it('allows a custom message', () => {
|
||||
const forbiddenError = new Forbidden('Custom Error Message');
|
||||
|
||||
expect(forbiddenError.message).to.eql('Custom Error Message');
|
||||
});
|
||||
});
|
||||
|
||||
describe('InternalServerError', () => {
|
||||
it('is an instance of CustomError', () => {
|
||||
const internalServerError = new InternalServerError();
|
||||
|
||||
Reference in New Issue
Block a user