From b129fe908c6ade3adf9e06ddd50372caa830b2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Fri, 10 Mar 2017 04:40:59 -0300 Subject: [PATCH] Test check backward backward compatibility authentication method basic on calendar module Fix travis basic-auth server --- .../modules/calendar/old-basic-auth.js | 39 +++++++++++++++++++ tests/e2e/modules/calendar_spec.js | 13 +++++++ tests/servers/basic-auth.js | 15 ++++--- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/configs/modules/calendar/old-basic-auth.js diff --git a/tests/configs/modules/calendar/old-basic-auth.js b/tests/configs/modules/calendar/old-basic-auth.js new file mode 100644 index 00000000..76e2df3a --- /dev/null +++ b/tests/configs/modules/calendar/old-basic-auth.js @@ -0,0 +1,39 @@ +/* Magic Mirror Test config default calendar + * with authenticacion old config + * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com + * MIT Licensed. + */ + +var config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 12, + units: "metric", + electronOptions: { + webPreferences: { + nodeIntegration: true, + }, + }, + + modules: [ + { + module: "calendar", + position: "bottom_bar", + config: { + calendars: [ + { + maximumNumberOfDays: 10000, + url: "http://localhost:8012/tests/configs/data/calendar_test.ics", + user: "MagicMirror", + pass: "CallMeADog" + } + ] + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") {module.exports = config;} diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index 9bb68baa..21939f06 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -53,5 +53,18 @@ describe("Calendar module", function () { }); }); + describe("Basic auth backward compatibilty configuration", function() { + before(function() { + serverBasicAuth.listen(8012); + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js"; + }); + + it("Should return TestEvents", function () { + return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); + }); + }); + + }); diff --git a/tests/servers/basic-auth.js b/tests/servers/basic-auth.js index 6077cf8c..238bdc26 100644 --- a/tests/servers/basic-auth.js +++ b/tests/servers/basic-auth.js @@ -5,10 +5,9 @@ var express = require("express") var basic = auth.basic({ realm: "MagicMirror Area restricted." - }, (username, password, callback) => { - callback(username === "MagicMirror" && password === "CallMeADog"); - } -); +}, (username, password, callback) => { + callback(username === "MagicMirror" && password === "CallMeADog"); +}); this.server = express(); this.server.use(auth.connect(basic)); @@ -16,16 +15,16 @@ this.server.use(auth.connect(basic)); // Set directories availables var directories = ["/tests/configs"]; var directory; -root_path = path.resolve(__dirname + "/../../"); +rootPath = path.resolve(__dirname + "/../../"); for (i in directories) { directory = directories[i]; - this.server.use(directory, express.static(path.resolve(root_path + directory))); + this.server.use(directory, express.static(path.resolve(rootPath + directory))); } exports.listen = function () { - this.server.listen.apply(this.server, arguments); + this.server.listen.apply(this.server, arguments); }; exports.close = function (callback) { - this.server.close(callback); + this.server.close(callback); };