MagicMirror/tests/e2e/modules/basic-auth.js

30 lines
663 B
JavaScript
Raw Normal View History

2020-04-19 08:18:11 +02:00
const path = require("path");
const auth = require("express-basic-auth");
2020-04-19 08:18:11 +02:00
const express = require("express");
const app = express();
2017-03-10 04:33:27 -03:00
2021-03-15 12:36:52 +01:00
const basicAuth = auth({
2022-01-26 23:47:51 +01:00
realm: "MagicMirror² Area restricted.",
users: { MagicMirror: "CallMeADog" }
});
app.use(basicAuth);
2017-03-10 04:33:27 -03:00
2019-06-05 09:46:59 +02:00
// Set available directories
2021-03-15 12:36:52 +01:00
const directories = ["/tests/configs"];
2021-09-17 20:03:57 +02:00
const rootPath = path.resolve(__dirname + "/../../../");
2020-05-02 10:39:09 +02:00
2021-03-15 12:36:52 +01:00
for (let directory of directories) {
app.use(directory, express.static(path.resolve(rootPath + directory)));
2017-03-10 04:33:27 -03:00
}
2021-03-15 12:36:52 +01:00
let server;
exports.listen = function () {
server = app.listen.apply(app, arguments);
2017-03-10 04:33:27 -03:00
};
exports.close = function (callback) {
server.close(callback);
2017-03-10 04:33:27 -03:00
};