mirror of
https://github.com/Lissy93/dashy.git
synced 2026-07-31 19:46:02 -04:00
* feat: add ICMP ping check support to item * Replaced ping package with pingman package to be compliant with Dashy CI NodeJS version (20). Fixed a behavior bug in status indicator component which didn't changed icon to yellow when checking. Made otherStatusText a computed field to make it reflecting dynamically a new check request. Added more examples to default conf.yml * Removed a forgotten trace to console * Made changes requested by Lissy after review of the PR. Corrected tests using localhost which is not a valid host for pingman. Added a Validator.js file in src/utils with function to check validity of hosts. Reverted conf.yml file to the original version. * Fixed a problem in configuration of pingman call after adding support of IPV6 addresses. * Updated Dockerfile to pass Docker smoke tests in CI * Revert to latest version of `user-data/conf.yml` from `master` * Removed the duplicated feature line for ping check and just added `hosts` to the existing one * Removed the unused `shouldEnabledPingCheck` function * Add the ping system package and give rights to use to the node user so the pingman module can work in Docker container * Remove `src/utils/Validator.js` file. Rely on `pingman` internal validation of hostname instead to avoid command injection.
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
// @vitest-environment node
|
|
import fs from 'fs';
|
|
import os from 'os';
|
|
import path from 'path';
|
|
import { describe, it, expect } from 'vitest';
|
|
import request from 'supertest';
|
|
|
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'dashy-status-test-'));
|
|
process.env.USER_DATA_DIR = tmpDir;
|
|
|
|
const app = require('../../services/app');
|
|
|
|
describe('Status check', () => {
|
|
it('returns error for missing URL param', async () => {
|
|
const res = await request(app).get('/status-check/');
|
|
const body = JSON.parse(res.text);
|
|
expect(body.successStatus).toBe(false);
|
|
});
|
|
|
|
it('returns error for empty URL param', async () => {
|
|
const res = await request(app).get('/status-check/?&url=');
|
|
const body = JSON.parse(res.text);
|
|
expect(body.successStatus).toBe(false);
|
|
});
|
|
|
|
it('ignores POST requests', async () => {
|
|
const res = await request(app).post('/status-check/?&url=x');
|
|
expect(res.status).toBeLessThan(500);
|
|
});
|
|
});
|
|
|
|
describe('Ping check', () => {
|
|
it('returns error for missing URL param', async () => {
|
|
const res = await request(app).get('/ping-check/');
|
|
const body = JSON.parse(res.text);
|
|
expect(body.successStatus).toBe(false);
|
|
});
|
|
|
|
it('returns error for empty URL param', async () => {
|
|
const res = await request(app).get('/ping-check/?&host=');
|
|
const body = JSON.parse(res.text);
|
|
expect(body.successStatus).toBe(false);
|
|
});
|
|
|
|
it('ignores POST requests', async () => {
|
|
const res = await request(app).post('/ping-check/?&host=localhost');
|
|
expect(res.status).toBeLessThan(500);
|
|
});
|
|
});
|