Enhancement: handle OMV v8 auth response (#6886)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Tests / vitest (4) (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

This commit is contained in:
shamoon
2026-07-19 07:55:06 -07:00
committed by GitHub
parent fc696a1b89
commit 0addba0d63
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ async function tryLogin(widget) {
}
const json = JSON.parse(resp.data.toString());
if (json.response.authenticated !== true) {
if (json.response.authenticated !== true && json.response.status !== "authenticated") {
logger.error("Login error in OpenMediaVault. Data: %s", resp.data);
resp.status = 401;
return [false, resp];
+33
View File
@@ -145,6 +145,39 @@ describe("widgets/openmediavault/proxy", () => {
expect(res.body).toEqual(Buffer.from(JSON.stringify({ response: { ok: true } })));
});
it("accepts the OpenMediaVault 8 authenticated status after login", async () => {
getServiceWidget.mockResolvedValue({
type: "openmediavault",
url: "http://omv",
username: "u",
password: "p",
method: "foo.bar",
});
httpProxy
// initial rpc unauthorized
.mockResolvedValueOnce([401, "application/json", Buffer.from(JSON.stringify({ response: {} })), {}])
// OMV 8 login rpc
.mockResolvedValueOnce([
200,
"application/json",
Buffer.from(JSON.stringify({ response: { status: "authenticated" } })),
{ "set-cookie": ["sid=1"] },
])
// retry rpc
.mockResolvedValueOnce([200, "application/json", Buffer.from(JSON.stringify({ response: { ok: true } })), {}]);
const req = { query: { group: "g", service: "svc", index: "0" } };
const res = createMockRes();
await openmediavaultProxyHandler(req, res);
expect(cookieJar.addCookieToJar).toHaveBeenCalled();
expect(httpProxy).toHaveBeenCalledTimes(3);
expect(res.statusCode).toBe(200);
expect(res.body).toEqual(Buffer.from(JSON.stringify({ response: { ok: true } })));
});
it("returns after a failed login attempt (non-200 response)", async () => {
getServiceWidget.mockResolvedValue({
type: "openmediavault",