Skip to content

Commit 059bdd2

Browse files
committed
Add coverage for dockhand token auth
1 parent c323b5b commit 059bdd2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/widgets/dockhand/proxy.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,27 @@ describe("widgets/dockhand/proxy", () => {
7979
expect(res.body.error.message).toBe("HTTP Error");
8080
expect(res.body.error.url).toContain("token=***");
8181
});
82+
83+
it("supports token auth", async () => {
84+
getServiceWidget.mockResolvedValue({
85+
type: "dockhand",
86+
url: "http://dockhand",
87+
key: "abc",
88+
});
89+
90+
httpProxy.mockResolvedValueOnce([200, "application/json", Buffer.from("ok")]);
91+
92+
const req = {
93+
method: "GET",
94+
query: { group: "g", service: "svc", endpoint: "api/v1/status", index: "0" },
95+
};
96+
const res = createMockRes();
97+
98+
await dockhandProxyHandler(req, res);
99+
100+
expect(httpProxy).toHaveBeenCalledWith(
101+
new URL("http://dockhand/api/v1/status"),
102+
expect.objectContaining({ method: "GET", headers: { Authorization: "Bearer abc" } }),
103+
);
104+
});
82105
});

0 commit comments

Comments
 (0)