diff --git a/tests/configs/noIpWhiteList.js b/tests/configs/noIpWhiteList.js new file mode 100644 index 00000000..79366e09 --- /dev/null +++ b/tests/configs/noIpWhiteList.js @@ -0,0 +1,25 @@ +/* Magic Mirror Test config sample ipWhitelist + * + * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com + * MIT Licensed. + */ + +var config = { + port: 8080, + ipWhitelist: ["x.x.x.x"], + + language: "en", + timeFormat: 24, + units: "metric", + electronOptions: { + webPreferences: { + nodeIntegration: true, + }, + }, + + modules: [ + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") {module.exports = config;} diff --git a/tests/e2e/ipWhistlist_spec.js b/tests/e2e/ipWhistlist_spec.js new file mode 100644 index 00000000..01ab6787 --- /dev/null +++ b/tests/e2e/ipWhistlist_spec.js @@ -0,0 +1,30 @@ +const globalSetup = require("./global-setup"); +const app = globalSetup.app; +const request = require("request"); +const chai = require("chai"); +const expect = chai.expect; + +describe("Set ipWhitelist without access", function () { + + this.timeout(20000); + + before(function() { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js"; + }); + + beforeEach(function (done) { + app.start().then(function() { done(); } ); + }); + + afterEach(function (done) { + app.stop().then(function() { done(); }); + }); + + it("should return 403", function (done) { + request.get("http://localhost:8080", function (err, res, body) { + expect(res.statusCode).to.equal(403); + done(); + }); + }); +});