Enhancement: support qBittorrent apikey (#6791)
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

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
John Reiner
2026-06-20 22:51:56 +00:00
committed by GitHub
co-authored by shamoon
parent 7c5e34503d
commit 9b014e43b5
3 changed files with 31 additions and 2 deletions
+20
View File
@@ -83,4 +83,24 @@ describe("widgets/qbittorrent/proxy", () => {
expect(res.statusCode).toBe(401);
expect(res.body).toEqual(Buffer.from("Denied"));
});
it("supports API keys by including them in the Authorization header and not the body", async () => {
getServiceWidget.mockResolvedValue({ url: "http://qb", key: "abc123" });
httpProxy
.mockResolvedValueOnce([403, "application/json", Buffer.from("nope")])
.mockResolvedValueOnce([200, "text/plain", Buffer.from("Ok.")])
.mockResolvedValueOnce([200, "application/json", Buffer.from("data")]);
const req = { query: { group: "g", service: "svc", endpoint: "torrents/info", index: "0" } };
const res = createMockRes();
await qbittorrentProxyHandler(req, res);
expect(httpProxy).toHaveBeenCalledTimes(3);
expect(httpProxy.mock.calls[1][0]).toBe("http://qb/api/v2/auth/login");
expect(httpProxy.mock.calls[1][1].headers.Authorization).toBe("Bearer abc123");
expect(res.statusCode).toBe(200);
expect(res.body).toEqual(Buffer.from("data"));
});
});