2021-03-02 21:26:25 +01:00
|
|
|
const fetch = require("node-fetch");
|
2021-09-13 23:55:41 +02:00
|
|
|
const app = require("app.js");
|
2017-07-24 22:08:12 +02:00
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
describe("ipWhitelist directive configuration", function () {
|
2021-09-13 22:28:27 +02:00
|
|
|
beforeAll(function () {
|
|
|
|
app.start();
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|
|
|
|
|
2021-09-13 22:28:27 +02:00
|
|
|
afterAll(function () {
|
|
|
|
app.stop();
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|
|
|
|
|
2017-03-07 21:22:27 -03:00
|
|
|
describe("Set ipWhitelist without access", function () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(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) => {
|
2021-06-09 00:19:43 +02:00
|
|
|
expect(res.status).toBe(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 () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(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) => {
|
2021-06-09 00:19:43 +02:00
|
|
|
expect(res.status).toBe(200);
|
2017-03-07 21:22:27 -03:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-03-07 16:21:15 -03:00
|
|
|
});
|