Files
MagicMirror/tests/e2e/helpers/basic-auth.js
T

30 lines
628 B
JavaScript
Raw Normal View History

const path = require("node:path");
const auth = require("express-basic-auth");
2020-04-19 08:18:11 +02:00
const express = require("express");
2024-01-01 15:38:08 +01:00
2020-04-19 08:18:11 +02:00
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" }
});
2017-07-22 15:40:35 +02:00
app.use(basicAuth);
2017-03-10 04:33:27 -03:00
2019-06-05 09:46:59 +02:00
// Set available directories
2023-01-01 18:09:08 +01:00
const directories = ["/tests/configs", "/tests/mocks"];
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(`${global.root_path}/${directory}`)));
2017-03-10 04:33:27 -03:00
}
2021-03-15 12:36:52 +01:00
let server;
2023-01-01 18:09:08 +01:00
exports.listen = (...args) => {
server = app.listen.apply(app, args);
2017-03-10 04:33:27 -03:00
};
2023-01-01 18:09:08 +01:00
exports.close = async () => {
await server.close();
2017-03-10 04:33:27 -03:00
};