2019-01-07 21:25:19 +07:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
2021-10-06 11:12:21 +01:00
|
|
|
const brute = require('../../../../../../core/server/web/shared/middlewares/brute');
|
2019-01-07 21:25:19 +07:00
|
|
|
|
|
|
|
describe('brute middleware', function () {
|
2019-08-06 10:04:00 +01:00
|
|
|
after(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
2019-01-07 21:25:19 +07:00
|
|
|
it('exports a contentApiKey method', function () {
|
|
|
|
should.equal(typeof brute.contentApiKey, 'function');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('contentApiKey', function () {
|
|
|
|
it('calls the contentApiKey method of spam prevention', function () {
|
2021-10-06 11:12:21 +01:00
|
|
|
const spamPrevention = require('../../../../../../core/server/web/shared/middlewares/api/spam-prevention');
|
2019-01-07 21:25:19 +07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|