mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-12 20:34:46 +00:00
Compare commits
8 commits
587699d7b3
...
1a98012cbd
Author | SHA1 | Date | |
---|---|---|---|
|
1a98012cbd | ||
|
2d46a32431 | ||
|
2beb6274e7 | ||
|
b0fb6ab568 | ||
|
425c78c8fa | ||
|
3a61b2f6ab | ||
|
dcb07a5e2e | ||
|
b45dc6787d |
2 changed files with 92 additions and 69 deletions
2
.github/workflows/auto-test.yml
vendored
2
.github/workflows/auto-test.yml
vendored
|
@ -78,7 +78,7 @@ jobs:
|
||||||
|
|
||||||
e2e-test:
|
e2e-test:
|
||||||
needs: [ ]
|
needs: [ ]
|
||||||
runs-on: ARM64
|
runs-on: ubuntu-24.04-arm
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
|
@ -1,76 +1,99 @@
|
||||||
const test = require("node:test");
|
const { describe, test } = require("node:test");
|
||||||
const assert = require("node:assert");
|
const assert = require("node:assert");
|
||||||
const { websocket } = require("../../server/monitor-types/websocket");
|
const { websocket } = require("../../server/monitor-types/websocket");
|
||||||
const { UP, DOWN, PENDING } = require("../../src/util");
|
const { UP, DOWN, PENDING } = require("../../src/util");
|
||||||
|
|
||||||
test("Test Websocket TLS", async () => {
|
describe("Websocket Test", {
|
||||||
const websocketMonitor = new websocket();
|
}, () => {
|
||||||
|
test("Non Websocket Server", {}, async () => {
|
||||||
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "wss://echo.websocket.org",
|
wsurl: "wss://example.org",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const heartbeat = {
|
const heartbeat = {
|
||||||
msg: "",
|
msg: "",
|
||||||
status: PENDING,
|
status: PENDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
await websocketMonitor.check(monitor, heartbeat, {});
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
assert.strictEqual(heartbeat.status, UP);
|
assert.strictEqual(heartbeat.status, DOWN);
|
||||||
assert.strictEqual(heartbeat.msg, "101 - OK");
|
assert.strictEqual(heartbeat.msg, "Unexpected server response: 200");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test Websocket non TLS", async () => {
|
test("Secure Websocket", async () => {
|
||||||
const websocketMonitor = new websocket();
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "ws://ws.ifelse.io",
|
wsurl: "wss://echo.websocket.org",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const heartbeat = {
|
const heartbeat = {
|
||||||
msg: "",
|
msg: "",
|
||||||
status: PENDING,
|
status: PENDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
await websocketMonitor.check(monitor, heartbeat, {});
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
assert.strictEqual(heartbeat.status, UP);
|
assert.strictEqual(heartbeat.status, UP);
|
||||||
assert.strictEqual(heartbeat.msg, "101 - OK");
|
assert.strictEqual(heartbeat.msg, "101 - OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test a non compliant WS server without ignore", async () => {
|
test("Insecure Websocket", {
|
||||||
const websocketMonitor = new websocket();
|
skip: !!process.env.CI,
|
||||||
|
}, async () => {
|
||||||
const monitor = {
|
const websocketMonitor = new websocket();
|
||||||
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
|
||||||
wsIgnoreHeaders: false,
|
const monitor = {
|
||||||
};
|
wsurl: "ws://ws.ifelse.io",
|
||||||
|
wsIgnoreHeaders: false,
|
||||||
const heartbeat = {
|
};
|
||||||
msg: "",
|
|
||||||
status: PENDING,
|
const heartbeat = {
|
||||||
};
|
msg: "",
|
||||||
|
status: PENDING,
|
||||||
await websocketMonitor.check(monitor, heartbeat, {});
|
};
|
||||||
assert.strictEqual(heartbeat.status, DOWN);
|
|
||||||
assert.strictEqual(heartbeat.msg, "Invalid Sec-WebSocket-Accept header");
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
});
|
assert.strictEqual(heartbeat.status, UP);
|
||||||
|
assert.strictEqual(heartbeat.msg, "101 - OK");
|
||||||
test("Test a non compliant WS server with ignore", async () => {
|
});
|
||||||
const websocketMonitor = new websocket();
|
|
||||||
|
test("Test a non compliant WS server without ignore", async () => {
|
||||||
const monitor = {
|
const websocketMonitor = new websocket();
|
||||||
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
|
||||||
wsIgnoreHeaders: true,
|
const monitor = {
|
||||||
};
|
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||||
|
wsIgnoreHeaders: false,
|
||||||
const heartbeat = {
|
};
|
||||||
msg: "",
|
|
||||||
status: PENDING,
|
const heartbeat = {
|
||||||
};
|
msg: "",
|
||||||
|
status: PENDING,
|
||||||
await websocketMonitor.check(monitor, heartbeat, {});
|
};
|
||||||
assert.strictEqual(heartbeat.status, UP);
|
|
||||||
assert.strictEqual(heartbeat.msg, "101 - OK");
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
|
assert.strictEqual(heartbeat.status, DOWN);
|
||||||
|
assert.strictEqual(heartbeat.msg, "Invalid Sec-WebSocket-Accept header");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Test a non compliant WS server with ignore", async () => {
|
||||||
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
|
const monitor = {
|
||||||
|
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||||
|
wsIgnoreHeaders: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const heartbeat = {
|
||||||
|
msg: "",
|
||||||
|
status: PENDING,
|
||||||
|
};
|
||||||
|
|
||||||
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
|
assert.strictEqual(heartbeat.status, UP);
|
||||||
|
assert.strictEqual(heartbeat.msg, "101 - OK");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue