mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-22 14:52:35 +02:00
fix: linter
This commit is contained in:
parent
0584d949c0
commit
8646f287ff
3 changed files with 28 additions and 4 deletions
|
@ -4,7 +4,7 @@ const { Prometheus } = require("../prometheus");
|
|||
const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND,
|
||||
SQL_DATETIME_FORMAT, evaluateJsonQuery
|
||||
} = require("../../src/util");
|
||||
const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery,
|
||||
const { ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery,
|
||||
redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal
|
||||
} = require("../util-server");
|
||||
const { R } = require("redbean-node");
|
||||
|
@ -24,7 +24,6 @@ const { CookieJar } = require("tough-cookie");
|
|||
const { HttpsCookieAgent } = require("http-cookie-agent/http");
|
||||
const https = require("https");
|
||||
const http = require("http");
|
||||
const tls = require("tls");
|
||||
|
||||
const rootCertificates = rootCertificatesFingerprints();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { MonitorType } = require("./monitor-type");
|
||||
const { UP, DOWN, log, evaluateJsonQuery } = require("../../src/util");
|
||||
const { UP, DOWN } = require("../../src/util");
|
||||
const { tcping, checkCertificate } = require("../util-server");
|
||||
const tls = require("tls");
|
||||
|
||||
|
|
|
@ -4,7 +4,17 @@ const { TCPMonitorType } = require("../../server/monitor-types/tcp");
|
|||
const { UP, DOWN, PENDING } = require("../../src/util");
|
||||
const net = require("net");
|
||||
|
||||
/**
|
||||
* Test suite for TCP Monitor functionality
|
||||
* This test suite checks the behavior of the TCPMonitorType class
|
||||
* under different network connection scenarios.
|
||||
*/
|
||||
describe("TCP Monitor", () => {
|
||||
/**
|
||||
* Creates a TCP server on a specified port
|
||||
* @param {number} port - The port number to listen on
|
||||
* @returns {Promise<net.Server>} A promise that resolves with the created server
|
||||
*/
|
||||
async function createTCPServer(port) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = net.createServer();
|
||||
|
@ -19,12 +29,17 @@ describe("TCP Monitor", () => {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case to verify TCP monitor works when a server is running
|
||||
* Checks that the monitor correctly identifies an active TCP server
|
||||
*/
|
||||
test("TCP server is running", async () => {
|
||||
const port = 12345;
|
||||
const server = await createTCPServer(port);
|
||||
|
||||
try {
|
||||
const tcpMonitor = new TCPMonitorType();
|
||||
|
||||
const monitor = {
|
||||
hostname: "localhost",
|
||||
port: port,
|
||||
|
@ -45,8 +60,13 @@ describe("TCP Monitor", () => {
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Test case to verify TCP monitor handles non-running servers
|
||||
* Checks that the monitor correctly identifies an inactive TCP server
|
||||
*/
|
||||
test("TCP server is not running", async () => {
|
||||
const tcpMonitor = new TCPMonitorType();
|
||||
|
||||
const monitor = {
|
||||
hostname: "localhost",
|
||||
port: 54321,
|
||||
|
@ -63,8 +83,13 @@ describe("TCP Monitor", () => {
|
|||
assert.strictEqual(heartbeat.status, DOWN);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test case to verify TCP monitor handles servers with expired or invalid TLS certificates
|
||||
* Checks that the monitor correctly identifies TLS certificate issues
|
||||
*/
|
||||
test("TCP server with expired or invalid TLS certificate", async (t) => {
|
||||
const tcpMonitor = new TCPMonitorType();
|
||||
|
||||
const monitor = {
|
||||
hostname: "expired.badssl.com",
|
||||
port: 443,
|
||||
|
|
Loading…
Add table
Reference in a new issue