Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
"Reis",
"rejas",
"relativehumidity",
"resultstring",
"Resig",
"roboto",
"rohitdharavath",
Expand Down Expand Up @@ -288,6 +289,7 @@
"TESTMODE",
"testpass",
"testuser",
"teststring",
"thomasrockhu",
"thumbslider",
"timeformat",
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import stylistic from "@stylistic/eslint-plugin";
import vitest from "@vitest/eslint-plugin";

export default defineConfig([
globalIgnores(["config/**", "modules/**/*", "js/positions.js", "tests/configs/port_variable.js"]),
globalIgnores(["config/**", "modules/**/*", "js/positions.js", "tests/configs/config_variables.js"]),
{
files: ["**/*.js"],
languageOptions: {
Expand Down
7 changes: 7 additions & 0 deletions tests/configs/config_variables.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MM_LANGUAGE=de
MM_TIME_FORMAT=12
MM_LOG_INFO=INFO
MM_LOG_ERROR=ERROR
SECRET_IP1="127.0.0.1"
SECRET_IP2="::ffff:127.0.0.1"
SECRET_IP3=1
12 changes: 12 additions & 0 deletions tests/configs/config_variables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let config = require(`${process.cwd()}/tests/configs/default.js`).configFactory({
language: "${MM_LANGUAGE}",
logLevel: ["${MM_LOG_ERROR}", "LOG", "WARN", "${MM_LOG_INFO}"],
timeFormat: ${MM_TIME_FORMAT},
hideConfigSecrets: true,
ipWhitelist: ["${SECRET_IP2}", "::${SECRET_IP3}", "${SECRET_IP1}"]
});

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
1 change: 0 additions & 1 deletion tests/configs/port_variable.env

This file was deleted.

8 changes: 0 additions & 8 deletions tests/configs/port_variable.js

This file was deleted.

34 changes: 34 additions & 0 deletions tests/e2e/config_variables_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const helpers = require("./helpers/global-setup");

describe("config with variables and secrets", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/config_variables.js");
});

afterAll(async () => {
await helpers.stopApplication();
});

it("config.language should be \"de\"", async () => {
expect(config.language).toBe("de");
});

it("config.loglevel should be [\"ERROR\", \"LOG\", \"WARN\", \"INFO\"]", async () => {
expect(config.logLevel).toStrictEqual(["ERROR", "LOG", "WARN", "INFO"]);
});

it("config.ipWhitelist should be [\"::ffff:127.0.0.1\", \"::1\", \"127.0.0.1\"]", async () => {
expect(config.ipWhitelist).toStrictEqual(["::ffff:127.0.0.1", "::1", "127.0.0.1"]);
});

it("config.timeFormat should be 12", async () => {
expect(config.timeFormat).toBe(12); // default is 24
});

it("/config endpoint should show redacted secrets", async () => {
const res = await fetch(`http://localhost:${config.port}/config`);
expect(res.status).toBe(200);
const cfg = await res.json();
expect(cfg.ipWhitelist).toStrictEqual(["**SECRET_IP2**", "::**SECRET_IP3**", "**SECRET_IP1**"]);
});
});
23 changes: 0 additions & 23 deletions tests/e2e/template_spec.js

This file was deleted.