2019-05-28 11:04:48 +03:00
|
|
|
require('should');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const configUtils = require('../../../utils/configUtils');
|
2020-03-30 18:26:47 +03:00
|
|
|
const controller = require('../../../../core/server/web/admin/controller');
|
2019-05-28 11:04:48 +03:00
|
|
|
|
|
|
|
describe('Admin App', function () {
|
2019-08-19 14:41:09 +03:00
|
|
|
describe('controller', function () {
|
2019-05-28 11:04:48 +03:00
|
|
|
const req = {};
|
|
|
|
let res;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
res = {
|
|
|
|
sendFile: sinon.spy()
|
|
|
|
};
|
|
|
|
|
|
|
|
configUtils.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('adds x-frame-options header when adminFrameProtection is enabled (default)', function () {
|
|
|
|
// default config: configUtils.set('adminFrameProtection', true);
|
|
|
|
controller(req, res);
|
|
|
|
|
|
|
|
res.sendFile.called.should.be.true();
|
|
|
|
res.sendFile.calledWith(
|
|
|
|
sinon.match.string,
|
|
|
|
sinon.match.hasNested('headers.X-Frame-Options', sinon.match('sameorigin'))
|
|
|
|
).should.be.true();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('doesn\'t add x-frame-options header when adminFrameProtection is disabled', function () {
|
|
|
|
configUtils.set('adminFrameProtection', false);
|
|
|
|
controller(req, res);
|
|
|
|
|
|
|
|
res.sendFile.called.should.be.true();
|
|
|
|
res.sendFile.calledWith(
|
|
|
|
sinon.match.string,
|
|
|
|
sinon.match.hasNested('headers.X-Frame-Options')
|
|
|
|
).should.be.false();
|
|
|
|
});
|
2019-08-19 14:41:09 +03:00
|
|
|
});
|
2019-05-28 11:04:48 +03:00
|
|
|
});
|