mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Add test basic-auth
This commit is contained in:
parent
1c235aa761
commit
ceb4ef2642
@ -38,6 +38,7 @@
|
||||
"grunt-markdownlint": "^1.0.13",
|
||||
"grunt-stylelint": "latest",
|
||||
"grunt-yamllint": "latest",
|
||||
"http-auth": "^3.1.3",
|
||||
"mocha": "^3.2.0",
|
||||
"spectron": "^3.4.1",
|
||||
"stylelint-config-standard": "latest",
|
||||
|
42
tests/configs/modules/calendar/basic-auth.js
Normal file
42
tests/configs/modules/calendar/basic-auth.js
Normal file
@ -0,0 +1,42 @@
|
||||
/* Magic Mirror Test config default calendar
|
||||
*
|
||||
* 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:8010/tests/configs/data/calendar_test.ics",
|
||||
auth: {
|
||||
user: "MagicMirror",
|
||||
pass: "CallMeADog",
|
||||
method: "basic"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {module.exports = config;}
|
@ -1,4 +1,5 @@
|
||||
const globalSetup = require("../global-setup");
|
||||
const serverBasicAuth = require("../../servers/basic-auth.js");
|
||||
const app = globalSetup.app;
|
||||
const chai = require("chai");
|
||||
const expect = chai.expect;
|
||||
@ -26,4 +27,19 @@ describe("Calendar module", function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Basic auth", function() {
|
||||
before(function() {
|
||||
serverBasicAuth.listen(8010);
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
|
||||
});
|
||||
|
||||
it("Should return TestEvents", function () {
|
||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
31
tests/servers/basic-auth.js
Normal file
31
tests/servers/basic-auth.js
Normal file
@ -0,0 +1,31 @@
|
||||
var http = require("http");
|
||||
var path = require("path");
|
||||
var auth = require("http-auth");
|
||||
var express = require("express")
|
||||
|
||||
var basic = auth.basic({
|
||||
realm: "MagicMirror Area restricted."
|
||||
}, (username, password, callback) => {
|
||||
callback(username === "MagicMirror" && password === "CallMeADog");
|
||||
}
|
||||
);
|
||||
|
||||
this.server = express();
|
||||
this.server.use(auth.connect(basic));
|
||||
|
||||
// Set directories availables
|
||||
var directories = ["/tests/configs"];
|
||||
var directory;
|
||||
root_path = path.resolve(__dirname + "/../../");
|
||||
for (i in directories) {
|
||||
directory = directories[i];
|
||||
this.server.use(directory, express.static(path.resolve(root_path + directory)));
|
||||
}
|
||||
|
||||
exports.listen = function () {
|
||||
this.server.listen.apply(this.server, arguments);
|
||||
};
|
||||
|
||||
exports.close = function (callback) {
|
||||
this.server.close(callback);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user