Add test without access by ipWhistelist

This test set a invalid IP address for not have access to MagicMirror.
Creates a request to localhost and port added in configuration and check if
gets 403 HTTP code.
This commit is contained in:
Rodrigo Ramírez Norambuena 2017-03-07 16:21:15 -03:00
parent 6ea1732630
commit a15b8077a3
2 changed files with 55 additions and 0 deletions

View File

@ -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;}

View File

@ -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();
});
});
});