mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-23 12:05:56 +00:00
update tests
This commit is contained in:
parent
587699d7b3
commit
dcb07a5e2e
1 changed files with 89 additions and 68 deletions
|
@ -1,9 +1,29 @@
|
||||||
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", {
|
||||||
|
}, () => {
|
||||||
|
test("Non Websocket Server", async () => {
|
||||||
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
|
const monitor = {
|
||||||
|
wsurl: "wss://example.org",
|
||||||
|
wsIgnoreHeaders: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const heartbeat = {
|
||||||
|
msg: "",
|
||||||
|
status: PENDING,
|
||||||
|
};
|
||||||
|
|
||||||
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
|
assert.strictEqual(heartbeat.status, DOWN);
|
||||||
|
assert.strictEqual(heartbeat.msg, "Unexpected server response: 200");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Secure Websocket", async () => {
|
||||||
const websocketMonitor = new websocket();
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
|
@ -19,9 +39,9 @@ test("Test Websocket TLS", async () => {
|
||||||
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 Websocket non TLS", async () => {
|
test("Insecure Websocket", async () => {
|
||||||
const websocketMonitor = new websocket();
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
|
@ -37,9 +57,9 @@ test("Test Websocket non TLS", async () => {
|
||||||
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("Test a non compliant WS server without ignore", async () => {
|
||||||
const websocketMonitor = new websocket();
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
|
@ -55,9 +75,9 @@ test("Test a non compliant WS server without ignore", async () => {
|
||||||
await websocketMonitor.check(monitor, heartbeat, {});
|
await websocketMonitor.check(monitor, heartbeat, {});
|
||||||
assert.strictEqual(heartbeat.status, DOWN);
|
assert.strictEqual(heartbeat.status, DOWN);
|
||||||
assert.strictEqual(heartbeat.msg, "Invalid Sec-WebSocket-Accept header");
|
assert.strictEqual(heartbeat.msg, "Invalid Sec-WebSocket-Accept header");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test a non compliant WS server with ignore", async () => {
|
test("Test a non compliant WS server with ignore", async () => {
|
||||||
const websocketMonitor = new websocket();
|
const websocketMonitor = new websocket();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
|
@ -73,4 +93,5 @@ test("Test a non compliant WS server with ignore", async () => {
|
||||||
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue