Enhancement: Add bearer authentication to whatsupdocker widget (#7134)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled

This commit is contained in:
Ben Belov
2026-09-11 23:24:08 -07:00
committed by GitHub
parent eacc205249
commit fcd9a715d9
4 changed files with 23 additions and 3 deletions
@@ -35,6 +35,7 @@ vi.mock("widgets/widgets", () => ({
proxmox: { api: "{url}/api2/json/{endpoint}" },
truenas: { api: "{url}/api/v2.0/{endpoint}" },
ntfy: { api: "{url}/{endpoint}" },
whatsupdocker: { api: "{url}/{endpoint}" },
proxmoxbackupserver: { api: "{url}/api2/json/{endpoint}" },
checkmk: { api: "{url}/{endpoint}" },
stocks: { api: "{url}/{endpoint}" },
@@ -186,6 +187,24 @@ describe("utils/proxy/handlers/credentialed", () => {
expect(params.headers.Authorization).toBe("Bearer k");
});
it.each([
["Bearer", { key: "token" }, "Bearer token"],
["Basic", { username: "u", password: "p" }, `Basic ${Buffer.from("u:p").toString("base64")}`],
["no", {}, undefined],
["Bearer over Basic", { key: "token", username: "u", password: "p" }, "Bearer token"],
])("uses %s auth for whatsupdocker", async (_mode, credentials, authorization) => {
getServiceWidget.mockResolvedValue({ type: "whatsupdocker", url: "http://whatsupdocker", ...credentials });
httpProxy.mockResolvedValue([200, "application/json", []]);
const req = { method: "GET", query: { group: "g", service: "s", endpoint: "api/containers", index: 0 } };
const res = createMockRes();
await credentialedProxyHandler(req, res);
const [, params] = httpProxy.mock.calls.at(-1);
expect(params.headers.Authorization).toBe(authorization);
});
it("uses Bearer auth for ntfy when key is provided", async () => {
getServiceWidget.mockResolvedValue({ type: "ntfy", url: "http://ntfy", topic: "alerts", key: "tk_test" });
httpProxy.mockResolvedValue([200, "application/json", { ok: true }]);