Compare commits

...

9 commits

Author SHA1 Message Date
PoleTransformer
7beb0e7857
Merge 1a98012cbd into b45dc6787d 2025-02-18 04:00:20 +00:00
Your Name
1a98012cbd skip insecure test on CI 2025-02-17 20:03:00 -08:00
Your Name
2d46a32431 skip insecure test except generic arm64 2025-02-17 19:54:48 -08:00
Your Name
2beb6274e7 windows skip insecure test 2025-02-17 19:40:50 -08:00
Your Name
b0fb6ab568 linux skip insecure test 2025-02-17 19:28:48 -08:00
PoleTransformer
425c78c8fa
Merge branch 'louislam:master' into websocket_test 2025-02-18 03:20:16 +00:00
Your Name
3a61b2f6ab macos skip insecure test 2025-02-17 19:06:10 -08:00
Your Name
dcb07a5e2e update tests 2025-02-17 18:01:33 -08:00
Zaid Hafeez
b45dc6787d
Use GitHub's new "GitHub Hosted" Ubuntu ARM runner (#5587)
Some checks failed
Auto Test / e2e-test (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2025-02-16 21:06:19 +01:00
2 changed files with 92 additions and 69 deletions

View file

@ -78,7 +78,7 @@ jobs:
e2e-test:
needs: [ ]
runs-on: ARM64
runs-on: ubuntu-24.04-arm
steps:
- run: git config --global core.autocrlf false # Mainly for Windows
- uses: actions/checkout@v4

View file

@ -1,76 +1,99 @@
const test = require("node:test");
const { describe, test } = require("node:test");
const assert = require("node:assert");
const { websocket } = require("../../server/monitor-types/websocket");
const { UP, DOWN, PENDING } = require("../../src/util");
test("Test Websocket TLS", async () => {
const websocketMonitor = new websocket();
describe("Websocket Test", {
}, () => {
test("Non Websocket Server", {}, async () => {
const websocketMonitor = new websocket();
const monitor = {
wsurl: "wss://echo.websocket.org",
wsIgnoreHeaders: false,
};
const monitor = {
wsurl: "wss://example.org",
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");
});
test("Test Websocket non TLS", async () => {
const websocketMonitor = new websocket();
const monitor = {
wsurl: "ws://ws.ifelse.io",
wsIgnoreHeaders: false,
};
const heartbeat = {
msg: "",
status: PENDING,
};
await websocketMonitor.check(monitor, heartbeat, {});
assert.strictEqual(heartbeat.status, UP);
assert.strictEqual(heartbeat.msg, "101 - OK");
});
test("Test a non compliant WS server without ignore", async () => {
const websocketMonitor = new websocket();
const monitor = {
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
wsIgnoreHeaders: false,
};
const heartbeat = {
msg: "",
status: PENDING,
};
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");
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 monitor = {
wsurl: "wss://echo.websocket.org",
wsIgnoreHeaders: false,
};
const heartbeat = {
msg: "",
status: PENDING,
};
await websocketMonitor.check(monitor, heartbeat, {});
assert.strictEqual(heartbeat.status, UP);
assert.strictEqual(heartbeat.msg, "101 - OK");
});
test("Insecure Websocket", {
skip: !!process.env.CI,
}, async () => {
const websocketMonitor = new websocket();
const monitor = {
wsurl: "ws://ws.ifelse.io",
wsIgnoreHeaders: false,
};
const heartbeat = {
msg: "",
status: PENDING,
};
await websocketMonitor.check(monitor, heartbeat, {});
assert.strictEqual(heartbeat.status, UP);
assert.strictEqual(heartbeat.msg, "101 - OK");
});
test("Test a non compliant WS server without ignore", async () => {
const websocketMonitor = new websocket();
const monitor = {
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
wsIgnoreHeaders: false,
};
const heartbeat = {
msg: "",
status: PENDING,
};
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");
});
});