2017-07-24 22:08:12 +02:00
|
|
|
const helpers = require("./global-setup");
|
2021-03-02 21:26:25 +01:00
|
|
|
const fetch = require("node-fetch");
|
2017-07-24 22:08:12 +02:00
|
|
|
const expect = require("chai").expect;
|
|
|
|
|
|
|
|
const describe = global.describe;
|
|
|
|
const it = global.it;
|
|
|
|
const beforeEach = global.beforeEach;
|
|
|
|
const afterEach = global.afterEach;
|
2017-03-07 16:21:15 -03:00
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
describe("ipWhitelist directive configuration", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
helpers.setupTimeout(this);
|
2017-03-07 16:21:15 -03:00
|
|
|
|
2021-04-08 21:12:56 +02:00
|
|
|
let app = null;
|
2017-03-07 16:21:15 -03:00
|
|
|
|
2017-07-24 22:08:12 +02:00
|
|
|
beforeEach(function () {
|
2020-05-11 22:22:32 +02:00
|
|
|
return helpers
|
|
|
|
.startApplication({
|
|
|
|
args: ["js/electron.js"]
|
|
|
|
})
|
|
|
|
.then(function (startedApp) {
|
|
|
|
app = startedApp;
|
|
|
|
});
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|
|
|
|
|
2017-07-24 22:08:12 +02:00
|
|
|
afterEach(function () {
|
|
|
|
return helpers.stopApplication(app);
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
describe("Set ipWhitelist without access", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
before(function () {
|
2017-03-07 21:22:27 -03:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
|
|
|
});
|
2021-04-08 21:12:56 +02:00
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
it("should return 403", function (done) {
|
2021-03-02 21:26:25 +01:00
|
|
|
fetch("http://localhost:8080").then((res) => {
|
|
|
|
expect(res.status).to.equal(403);
|
2017-03-07 21:22:27 -03:00
|
|
|
done();
|
|
|
|
});
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|
|
|
|
});
|
2017-03-07 21:22:27 -03:00
|
|
|
|
|
|
|
describe("Set ipWhitelist []", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
before(function () {
|
2017-03-07 21:22:27 -03:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
|
|
|
});
|
2021-04-08 21:12:56 +02:00
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
it("should return 200", function (done) {
|
2021-03-02 21:26:25 +01:00
|
|
|
fetch("http://localhost:8080").then((res) => {
|
|
|
|
expect(res.status).to.equal(200);
|
2017-03-07 21:22:27 -03:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|