mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Fixed error "swallowing"
no issue - I've discovered the "IncorrectUsageError" error was silently swallowed and the method returned a false positibe when an allowlist limit type was called with incorrect parameters - In cases like this it's best to surface the real error early otherwise the logic might produce unsafe results!
This commit is contained in:
parent
9632e98dd2
commit
f0a5fc975c
@ -69,6 +69,8 @@ class LimitService {
|
||||
if (error instanceof this.errors.HostLimitError) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +86,8 @@ class LimitService {
|
||||
if (error instanceof this.errors.HostLimitError) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,5 +303,25 @@ describe('Limit Service', function () {
|
||||
|
||||
(await limitService.checkIfAnyOverLimit()).should.be.false();
|
||||
});
|
||||
|
||||
it('Throws an error when an allowlist limit is checked', async function () {
|
||||
const limitService = new LimitService();
|
||||
|
||||
let limits = {
|
||||
// TODO: allowlist type of limits doesn't have "checkIsOverLimit" implemented yet!
|
||||
customThemes: {
|
||||
allowlist: ['casper', 'dawn', 'lyra']
|
||||
}
|
||||
};
|
||||
|
||||
limitService.loadLimits({limits, errors});
|
||||
|
||||
try {
|
||||
await limitService.checkIfAnyOverLimit();
|
||||
should.fail(limitService, 'Should have errored');
|
||||
} catch (err) {
|
||||
err.message.should.eql(`Cannot read property 'value' of undefined`);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user