mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-20 15:46:02 -04:00
variable renaming + update translation keys + additional unit tests
This commit is contained in:
parent
5bc9a0d64a
commit
e3e019ce37
@ -2,14 +2,14 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema
|
||||
.alterTable("monitor", function (table) {
|
||||
table.boolean("ws_ignore_headers").notNullable().defaultTo(false);
|
||||
table.string("subprotocol", 255).notNullable().defaultTo("");
|
||||
table.boolean("ws_ignore_sec_websocket_accept_header").notNullable().defaultTo(false);
|
||||
table.string("ws_subprotocol", 255).notNullable().defaultTo("");
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.alterTable("monitor", function (table) {
|
||||
table.dropColumn("ws_ignore_headers");
|
||||
table.dropColumn("subprotocol");
|
||||
table.dropColumn("ws_ignore_sec_websocket_accept_header");
|
||||
table.dropColumn("ws_subprotocol");
|
||||
});
|
||||
};
|
||||
|
@ -96,8 +96,8 @@ class Monitor extends BeanModel {
|
||||
parent: this.parent,
|
||||
childrenIDs: preloadData.childrenIDs.get(this.id) || [],
|
||||
url: this.url,
|
||||
wsIgnoreHeaders: this.getWsIgnoreHeaders(),
|
||||
subprotocol: this.subprotocol,
|
||||
wsIgnoreSecWebsocketAcceptHeader: this.getWsIgnoreSecWebsocketAcceptHeader(),
|
||||
wsSubprotocol: this.wsSubprotocol,
|
||||
method: this.method,
|
||||
hostname: this.hostname,
|
||||
port: this.port,
|
||||
@ -261,8 +261,8 @@ class Monitor extends BeanModel {
|
||||
* Parse to boolean
|
||||
* @returns {boolean} Should WS headers be ignored?
|
||||
*/
|
||||
getWsIgnoreHeaders() {
|
||||
return Boolean(this.wsIgnoreHeaders);
|
||||
getWsIgnoreSecWebsocketAcceptHeader() {
|
||||
return Boolean(this.wsIgnoreSecWebsocketAcceptHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class WebSocketMonitorType extends MonitorType {
|
||||
return new Promise((resolve) => {
|
||||
let ws;
|
||||
//If user selected a subprotocol, sets Sec-WebSocket-Protocol header. Subprotocol Identifier column: https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name
|
||||
ws = monitor.subprotocol === "" ? new WebSocket(monitor.url) : new WebSocket(monitor.url, monitor.subprotocol);
|
||||
ws = monitor.wsSubprotocol === "" ? new WebSocket(monitor.url) : new WebSocket(monitor.url, monitor.wsSubprotocol);
|
||||
|
||||
ws.addEventListener("open", (event) => {
|
||||
// Immediately close the connection
|
||||
@ -32,7 +32,7 @@ class WebSocketMonitorType extends MonitorType {
|
||||
|
||||
ws.onerror = (error) => {
|
||||
// Give user the choice to ignore Sec-WebSocket-Accept header
|
||||
if (monitor.wsIgnoreHeaders && error.message === "Invalid Sec-WebSocket-Accept header") {
|
||||
if (monitor.wsIgnoreSecWebsocketAcceptHeader && error.message === "Invalid Sec-WebSocket-Accept header") {
|
||||
resolve([ "101 - OK", 1000 ]);
|
||||
}
|
||||
// Upgrade failed, return message to user
|
||||
|
@ -790,8 +790,8 @@ let needSetup = false;
|
||||
bean.parent = monitor.parent;
|
||||
bean.type = monitor.type;
|
||||
bean.url = monitor.url;
|
||||
bean.wsIgnoreHeaders = monitor.wsIgnoreHeaders;
|
||||
bean.subprotocol = monitor.subprotocol;
|
||||
bean.wsIgnoreSecWebsocketAcceptHeader = monitor.wsIgnoreSecWebsocketAcceptHeader;
|
||||
bean.wsSubprotocol = monitor.wsSubprotocol;
|
||||
bean.method = monitor.method;
|
||||
bean.body = monitor.body;
|
||||
bean.headers = monitor.headers;
|
||||
|
@ -86,39 +86,39 @@
|
||||
"ignoreTLSError": "Ignore TLS/SSL errors for HTTPS websites",
|
||||
"ignoreTLSErrorGeneral": "Ignore TLS/SSL error for connection",
|
||||
"upsideDownModeDescription": "Flip the status upside down. If the service is reachable, it is DOWN.",
|
||||
"wsIgnoreHeadersDescription": "The websocket upgrade succeeds, but the server does not reply with Sec-WebSocket-Accept header.",
|
||||
"Ignore Sec-WebSocket-Accept header": "Ignore Sec-WebSocket-Accept header",
|
||||
"wamp": "WAMP (The WebSocket Application Messaging Protocol)",
|
||||
"sip": "WebSocket Transport for SIP (Session Initiation Protocol)",
|
||||
"notificationchannel-netapi-rest.openmobilealliance.org": "OMA RESTful Network API for Notification Channel",
|
||||
"wpcp": "Web Process Control Protocol (WPCP)",
|
||||
"amqp": "Advanced Message Queuing Protocol (AMQP) 1.0+",
|
||||
"jsflow": "jsFlow pubsub/queue protocol",
|
||||
"rwpcp": "Reverse Web Process Control Protocol (RWPCP)",
|
||||
"xmpp": "WebSocket Transport for the Extensible Messaging and Presence Protocol (XMPP)",
|
||||
"ship": "SHIP - Smart Home IP",
|
||||
"mielecloudconnect": "Miele Cloud Connect Protocol",
|
||||
"v10.pcp.sap.com": "Push Channel Protocol",
|
||||
"msrp": "WebSocket Transport for MSRP (Message Session Relay Protocol)",
|
||||
"bfcp": "WebSocket Transport for BFCP (Binary Floor Control Protocol)",
|
||||
"sldp.softvelum.com": "Softvelum Low Delay Protocol",
|
||||
"opcua+uacp": "OPC UA Connection Protocol",
|
||||
"opcua+uajson": "OPC UA JSON Encoding",
|
||||
"v1.swindon-lattice+json": "Swindon Web Server Protocol (JSON encoding)",
|
||||
"v1.usp": "USP (Broadband Forum User Services Platform)",
|
||||
"coap": "Constrained Application Protocol (CoAP)",
|
||||
"webrtc.softvelum.com": "Softvelum WebSocket signaling protocol",
|
||||
"cobra.v2.json": "Cobra Real Time Messaging Protocol",
|
||||
"drp": "Declarative Resource Protocol",
|
||||
"hub.bsc.bacnet.org": "BACnet Secure Connect Hub Connection",
|
||||
"dc.bsc.bacnet.org": "BACnet Secure Connect Direct Connection",
|
||||
"jmap": "WebSocket Transport for JMAP (JSON Meta Application Protocol)",
|
||||
"t140": "ITU-T T.140 Real-Time Text",
|
||||
"done": "Done.best IoT Protocol",
|
||||
"collection-update": "The Collection Update Websocket Subprotocol",
|
||||
"text.ircv3.net": "Text IRC Protocol",
|
||||
"binary.ircv3.net": "Binary IRC Protocol",
|
||||
"v3.penguin-stats.live+proto": "Penguin Statistics Live Protocol v3 (Protobuf encoding)",
|
||||
"ignoreSecWebsocketAcceptHeaderDescription": "Allows the server to not reply with Sec-WebSocket-Accept header, if the websocket upgrade succeeds.",
|
||||
"Ignore Sec-WebSocket-Accept header": "Ignore {0} header",
|
||||
"WebSocket Application Messaging Protocol": "WAMP (The WebSocket Application Messaging Protocol)",
|
||||
"Session Initiation Protocol": "WebSocket Transport for SIP (Session Initiation Protocol)",
|
||||
"Network API for Notification Channel": "OMA RESTful Network API for Notification Channel",
|
||||
"Web Process Control Protocol": "Web Process Control Protocol (WPCP)",
|
||||
"Advanced Message Queuing Protocol": "Advanced Message Queuing Protocol (AMQP) 1.0+",
|
||||
"jsflow": "jsFlow pubsub/queue Protocol",
|
||||
"Reverse Web Process Control": "Reverse Web Process Control Protocol (RWPCP)",
|
||||
"Extensible Messaging and Presence Protocol": "WebSocket Transport for the Extensible Messaging and Presence Protocol (XMPP)",
|
||||
"Smart Home IP": "SHIP - Smart Home IP",
|
||||
"Miele Cloud Connect Protocol": "Miele Cloud Connect Protocol",
|
||||
"Push Channel Protocol": "Push Channel Protocol",
|
||||
"Message Session Relay Protocol": "WebSocket Transport for MSRP (Message Session Relay Protocol)",
|
||||
"Binary Floor Control Protocol": "WebSocket Transport for BFCP (Binary Floor Control Protocol)",
|
||||
"Softvelum Low Delay Protocol": "Softvelum Low Delay Protocol",
|
||||
"OPC UA Connection Protocol": "OPC UA Connection Protocol",
|
||||
"OPC UA JSON Encoding": "OPC UA JSON Encoding",
|
||||
"Swindon Web Server Protocol": "Swindon Web Server Protocol (JSON encoding)",
|
||||
"Broadband Forum User Services Platform": "USP (Broadband Forum User Services Platform)",
|
||||
"Constrained Application Protocol": "Constrained Application Protocol (CoAP)",
|
||||
"Softvelum WebSocket signaling protocol": "Softvelum WebSocket Signaling Protocol",
|
||||
"Cobra Real Time Messaging Protocol": "Cobra Real Time Messaging Protocol",
|
||||
"Declarative Resource Protocol": "Declarative Resource Protocol",
|
||||
"BACnet Secure Connect Hub Connection": "BACnet Secure Connect Hub Connection",
|
||||
"BACnet Secure Connect Direct Connection": "BACnet Secure Connect Direct Connection",
|
||||
"WebSocket Transport for JMAP": "WebSocket Transport for JMAP (JSON Meta Application Protocol)",
|
||||
"ITU-T T.140 Real-Time Text": "ITU-T T.140 Real-Time Text",
|
||||
"Done.best IoT Protocol": "Done.best IoT Protocol",
|
||||
"Collection Update": "The Collection Update Websocket Subprotocol",
|
||||
"Text IRC Protocol": "Text IRC Protocol",
|
||||
"Binary IRC Protocol": "Binary IRC Protocol",
|
||||
"Penguin Statistics Live Protocol v3": "Penguin Statistics Live Protocol v3 (Protobuf encoding)",
|
||||
"maxRedirectDescription": "Maximum number of redirects to follow. Set to 0 to disable redirects.",
|
||||
"Upside Down Mode": "Upside Down Mode",
|
||||
"Max. Redirects": "Max. Redirects",
|
||||
|
@ -122,15 +122,15 @@
|
||||
<input id="url" v-model="monitor.url" type="url" class="form-control" :pattern="monitor.type !== 'websocket-upgrade' ? 'https?://.+' : 'wss?://.+'" required data-testid="url-input">
|
||||
</div>
|
||||
|
||||
<!-- Websocket Subprotocol -->
|
||||
<!-- Websocket Subprotocol Docs: https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name -->
|
||||
<div v-if="monitor.type === 'websocket-upgrade'" class="my-3">
|
||||
<label for="type" class="form-label">{{ $t("Subprotocol") }}</label>
|
||||
<select id="type" v-model="monitor.subprotocol" class="form-select">
|
||||
<label for="ws_subprotocol" class="form-label">{{ $t("Subprotocol") }}</label>
|
||||
<select id="ws_subprotocol" v-model="monitor.wsSubprotocol" class="form-select">
|
||||
<option value="" selected>{{ $t("None") }}</option>
|
||||
<option value="MBWS.huawei.com">MBWS</option>
|
||||
<option value="MBLWS.huawei.com">MBLWS</option>
|
||||
<option value="soap">soap</option>
|
||||
<option value="wamp">{{ $t("wamp") }}</option>
|
||||
<option value="wamp">{{ $t("WebSocket Application Messaging Protocol") }}</option>
|
||||
<option value="v10.stomp">STOMP 1.0</option>
|
||||
<option value="v11.stomp">STOMP 1.1</option>
|
||||
<option value="v12.stomp">STOMP 1.2</option>
|
||||
@ -141,28 +141,28 @@
|
||||
<option value="ocpp2.0.1">OCPP 2.0.1</option>
|
||||
<option value="ocpp2.1">OCPP 2.1</option>
|
||||
<option value="rfb">RFB</option>
|
||||
<option value="sip">{{ $t("sip") }}</option>
|
||||
<option value="notificationchannel-netapi-rest.openmobilealliance.org">{{ $t("notificationchannel-netapi-rest.openmobilealliance.org") }}</option>
|
||||
<option value="wpcp">{{ $t("wpcp") }}</option>
|
||||
<option value="amqp">{{ $t("amqp") }}</option>
|
||||
<option value="sip">{{ $t("Session Initiation Protocol") }}</option>
|
||||
<option value="notificationchannel-netapi-rest.openmobilealliance.org">{{ $t("Network API for Notification Channel") }}</option>
|
||||
<option value="wpcp">{{ $t("Web Process Control Protocol") }}</option>
|
||||
<option value="amqp">{{ $t("Advanced Message Queuing Protocol") }}</option>
|
||||
<option value="mqtt">MQTT</option>
|
||||
<option value="jsflow">{{ $t("jsflow") }}</option>
|
||||
<option value="rwpcp">{{ $t("rwpcp") }}</option>
|
||||
<option value="xmpp">{{ $t("xmpp") }}</option>
|
||||
<option value="ship">{{ $t("ship") }}</option>
|
||||
<option value="mielecloudconnect">{{ $t("mielecloudconnect") }}</option>
|
||||
<option value="v10.pcp.sap.com">{{ $t("v10.pcp.sap.com") }}</option>
|
||||
<option value="msrp">{{ $t("msrp") }}</option>
|
||||
<option value="rwpcp">{{ $t("Reverse Web Process Control") }}</option>
|
||||
<option value="xmpp">{{ $t("Extensible Messaging and Presence Protocol") }}</option>
|
||||
<option value="ship">{{ $t("Smart Home IP") }}</option>
|
||||
<option value="mielecloudconnect">{{ $t("Miele Cloud Connect Protocol") }}</option>
|
||||
<option value="v10.pcp.sap.com">{{ $t("Push Channel Protocol") }}</option>
|
||||
<option value="msrp">{{ $t("Message Session Relay Protocol") }}</option>
|
||||
<option value="v1.saltyrtc.org">SaltyRTC 1.0</option>
|
||||
<option value="TLCP-2.0.0.lightstreamer.com">TLCP 2.0.0</option>
|
||||
<option value="bfcp">{{ $t("bfcp") }}</option>
|
||||
<option value="sldp.softvelum.com">{{ $t("sldp.softvelum.com") }}</option>
|
||||
<option value="opcua+uacp">{{ $t("opcua+uacp") }}</option>
|
||||
<option value="opcua+uajson">{{ $t("opcua+uajson") }}</option>
|
||||
<option value="v1.swindon-lattice+json">{{ $t("v1.swindon-lattice+json") }}</option>
|
||||
<option value="v1.usp">{{ $t("v1.usp") }}</option>
|
||||
<option value="bfcp">{{ $t("Binary Floor Control Protocol") }}</option>
|
||||
<option value="sldp.softvelum.com">{{ $t("Softvelum Low Delay Protocol") }}</option>
|
||||
<option value="opcua+uacp">{{ $t("OPC UA Connection Protocol") }}</option>
|
||||
<option value="opcua+uajson">{{ $t("OPC UA JSON Encoding") }}</option>
|
||||
<option value="v1.swindon-lattice+json">{{ $t("Swindon Web Server Protocol") }}</option>
|
||||
<option value="v1.usp">{{ $t("Broadband Forum User Services Platform") }}</option>
|
||||
<option value="mles-websocket">mles-websocket</option>
|
||||
<option value="coap">{{ $t("coap") }}</option>
|
||||
<option value="coap">{{ $t("Constrained Application Protocol") }}</option>
|
||||
<option value="TLCP-2.1.0.lightstreamer.com">TLCP 2.1.0</option>
|
||||
<option value="sqlnet.oracle.com">sqlnet</option>
|
||||
<option value="oneM2M.R2.0.json">oneM2M R2.0 JSON</option>
|
||||
@ -172,20 +172,20 @@
|
||||
<option value="2016.serverpush.dash.mpeg.org">MPEG-DASH-ServerPush-23009-6-2017</option>
|
||||
<option value="2018.mmt.mpeg.org">MPEG-MMT-23008-1-2018</option>
|
||||
<option value="clue">clue</option>
|
||||
<option value="webrtc.softvelum.com">{{ $t("webrtc.softvelum.com") }}</option>
|
||||
<option value="cobra.v2.json">{{ $t("cobra.v2.json") }}</option>
|
||||
<option value="drp">{{ $t("drp") }}</option>
|
||||
<option value="hub.bsc.bacnet.org">{{ $t("hub.bsc.bacnet.org") }}</option>
|
||||
<option value="dc.bsc.bacnet.org">{{ $t("dc.bsc.bacnet.org") }}</option>
|
||||
<option value="jmap">{{ $t("jmap") }}</option>
|
||||
<option value="t140">{{ $t("t140") }}</option>
|
||||
<option value="done">{{ $t("done") }}</option>
|
||||
<option value="webrtc.softvelum.com">{{ $t("Softvelum WebSocket signaling protocol") }}</option>
|
||||
<option value="cobra.v2.json">{{ $t("Cobra Real Time Messaging Protocol") }}</option>
|
||||
<option value="drp">{{ $t("Declarative Resource Protocol") }}</option>
|
||||
<option value="hub.bsc.bacnet.org">{{ $t("BACnet Secure Connect Hub Connection") }}</option>
|
||||
<option value="dc.bsc.bacnet.org">{{ $t("BACnet Secure Connect Direct Connection") }}</option>
|
||||
<option value="jmap">{{ $t("WebSocket Transport for JMAP") }}</option>
|
||||
<option value="t140">{{ $t("ITU-T T.140 Real-Time Text") }}</option>
|
||||
<option value="done">{{ $t("Done.best IoT Protocol") }}</option>
|
||||
<option value="TLCP-2.2.0.lightstreamer.com">TLCP 2.2.0</option>
|
||||
<option value="collection-update">{{ $t("collection-update") }}</option>
|
||||
<option value="collection-update">{{ $t("Collection Update") }}</option>
|
||||
<option value="TLCP-2.3.0.lightstreamer.com">TLCP 2.3.0</option>
|
||||
<option value="text.ircv3.net">{{ $t("text.ircv3.net") }}</option>
|
||||
<option value="binary.ircv3.net">{{ $t("binary.ircv3.net") }}</option>
|
||||
<option value="v3.penguin-stats.live+proto">{{ $t("v3.penguin-stats.live+proto") }}</option>
|
||||
<option value="text.ircv3.net">{{ $t("Text IRC Protocol") }}</option>
|
||||
<option value="binary.ircv3.net">{{ $t("Binary IRC Protocol") }}</option>
|
||||
<option value="v3.penguin-stats.live+proto">{{ $t("Penguin Statistics Live Protocol v3") }}</option>
|
||||
<option value="TLCP-2.4.0.lightstreamer.com">TLCP 2.4.0</option>
|
||||
<option value="TLCP-2.5.0.lightstreamer.com">TLCP 2.5.0</option>
|
||||
<option value="Redfish">Redfish DSP0266</option>
|
||||
@ -697,12 +697,12 @@
|
||||
</div>
|
||||
|
||||
<div v-if="monitor.type === 'websocket-upgrade' " class="my-3 form-check">
|
||||
<input id="ws-ignore-headers" v-model="monitor.wsIgnoreHeaders" class="form-check-input" type="checkbox">
|
||||
<label class="form-check-label" for="ws-ignore-headers">
|
||||
{{ $t("Ignore Sec-WebSocket-Accept header") }}
|
||||
</label>
|
||||
<input id="wsIgnoreSecWebsocketAcceptHeader" v-model="monitor.wsIgnoreSecWebsocketAcceptHeader" class="form-check-input" type="checkbox">
|
||||
<i18n-t tag="label" keypath="Ignore Sec-WebSocket-Accept header" class="form-check-label" for="wsIgnoreSecWebsocketAcceptHeader">
|
||||
<code>Sec-Websocket-Accept</code>
|
||||
</i18n-t>
|
||||
<div class="form-text">
|
||||
{{ $t("wsIgnoreHeadersDescription") }}
|
||||
{{ $t("ignoreSecWebsocketAcceptHeaderDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1159,7 +1159,7 @@ const monitorDefaults = {
|
||||
name: "",
|
||||
parent: null,
|
||||
url: "https://",
|
||||
wsIgnoreHeaders: false,
|
||||
wsSubprotocol: "",
|
||||
method: "GET",
|
||||
interval: 60,
|
||||
retryInterval: 60,
|
||||
|
@ -11,7 +11,7 @@ describe("Websocket Test", {
|
||||
|
||||
const monitor = {
|
||||
url: "wss://example.org",
|
||||
wsIgnoreHeaders: false,
|
||||
wsIgnoreSecWebsocketAcceptHeader: false,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
@ -33,7 +33,7 @@ describe("Websocket Test", {
|
||||
|
||||
const monitor = {
|
||||
url: "wss://echo.websocket.org",
|
||||
wsIgnoreHeaders: false,
|
||||
wsIgnoreSecWebsocketAcceptHeader: false,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
@ -57,7 +57,7 @@ describe("Websocket Test", {
|
||||
|
||||
const monitor = {
|
||||
url: "ws://localhost:8080",
|
||||
wsIgnoreHeaders: false,
|
||||
wsIgnoreSecWebsocketAcceptHeader: false,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
@ -74,12 +74,12 @@ describe("Websocket Test", {
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("Test a non compliant WS server without ignore", async () => {
|
||||
test("Non compliant WS server without IgnoreSecWebsocket", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const monitor = {
|
||||
url: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||
wsIgnoreHeaders: false,
|
||||
wsIgnoreSecWebsocketAcceptHeader: false,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
@ -96,12 +96,12 @@ describe("Websocket Test", {
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("Test a non compliant WS server with ignore", async () => {
|
||||
test("Non compliant WS server with IgnoreSecWebsocket", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const monitor = {
|
||||
url: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||
wsIgnoreHeaders: true,
|
||||
wsIgnoreSecWebsocketAcceptHeader: true,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
@ -117,4 +117,71 @@ describe("Websocket Test", {
|
||||
await websocketMonitor.check(monitor, heartbeat, {});
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("Compliant WS server with IgnoreSecWebsocket", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const monitor = {
|
||||
url: "wss://echo.websocket.org",
|
||||
wsIgnoreSecWebsocketAcceptHeader: true,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
msg: "101 - OK",
|
||||
status: UP,
|
||||
};
|
||||
|
||||
await websocketMonitor.check(monitor, heartbeat, {});
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("Non WS server with IgnoreSecWebsocket", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const monitor = {
|
||||
url: "wss://example.org",
|
||||
wsIgnoreSecWebsocketAcceptHeader: true,
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
msg: "Unexpected server response: 200",
|
||||
status: DOWN,
|
||||
};
|
||||
|
||||
await websocketMonitor.check(monitor, heartbeat, {});
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
|
||||
test("Secure Websocket with Subprotocol", async () => {
|
||||
const websocketMonitor = new WebSocketMonitorType();
|
||||
|
||||
const monitor = {
|
||||
url: "wss://echo.websocket.org",
|
||||
wsIgnoreSecWebsocketAcceptHeader: false,
|
||||
wsSubprotocol: "ocpp1.6",
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
msg: "Server sent no subprotocol",
|
||||
status: DOWN,
|
||||
};
|
||||
|
||||
await websocketMonitor.check(monitor, heartbeat, {});
|
||||
assert.deepStrictEqual(heartbeat, expected);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user