mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-05-17 08:26:56 +03:00
Co-authored-by: sofia.fernandez <sofia.fernandez@six-group.com>
This commit is contained in:
committed by
GitHub
parent
7d7f12b5b1
commit
2f45b46315
@@ -380,4 +380,47 @@ describe("WebSocket Monitor", {}, () => {
|
||||
await websocketMonitor.check(monitor, heartbeat, {});
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("buildWsOptions() includes custom headers", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const options = await websocketMonitor.buildWsOptions({
|
||||
headers: JSON.stringify({
|
||||
"X-Test": "test-value",
|
||||
}),
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(options.headers, {
|
||||
"X-Test": "test-value",
|
||||
});
|
||||
});
|
||||
|
||||
test("buildWsOptions() ignores invalid custom headers JSON", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const options = await websocketMonitor.buildWsOptions({
|
||||
headers: "{ invalid-json",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(options.headers, {});
|
||||
});
|
||||
|
||||
test("buildWsOptions() authentication header overrides custom Authorization header", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const options = await websocketMonitor.buildWsOptions({
|
||||
headers: JSON.stringify({
|
||||
Authorization: "Bearer custom-token",
|
||||
"X-Test": "test-value",
|
||||
}),
|
||||
authMethod: "basic",
|
||||
basic_auth_user: "user",
|
||||
basic_auth_pass: "pass",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(options.headers, {
|
||||
Authorization: "Basic dXNlcjpwYXNz",
|
||||
"X-Test": "test-value",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user