mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
4f9b72ff43
- This is a minor bugbare, but it will affect some configuration I'm about to do for c8 - I've been wanting to do it for ages, middleware is plural all on it's own so it's an odd affectation in our codebase - This also only exists in 2 places, everywhere else we use "middleware" - Sadly it did result in a lot of churn as I did a full find and replace, but consistency is king!
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const brute = require('../../../../../../core/server/web/shared/middleware/brute');
|
|
|
|
describe('brute middleware', function () {
|
|
after(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
it('exports a contentApiKey method', function () {
|
|
should.equal(typeof brute.contentApiKey, 'function');
|
|
});
|
|
|
|
describe('contentApiKey', function () {
|
|
it('calls the contentApiKey method of spam prevention', function () {
|
|
const spamPrevention = require('../../../../../../core/server/web/shared/middleware/api/spam-prevention');
|
|
const contentApiKeyStub = sinon.stub(spamPrevention, 'contentApiKey');
|
|
|
|
// CASE: we don't care about what params it takes
|
|
// just whether it calls the spam prevention stuff
|
|
try {
|
|
brute.contentApiKey();
|
|
} catch (err) {
|
|
// I don't care
|
|
} finally {
|
|
should.equal(contentApiKeyStub.called, true);
|
|
}
|
|
});
|
|
});
|
|
});
|