25 lines
902 B
JavaScript
25 lines
902 B
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
const test = require("node:test");
|
|
|
|
const root = path.join(__dirname, "..");
|
|
const probe = fs.readFileSync(path.join(root, "probe.sh"), "utf8");
|
|
const timer = fs.readFileSync(path.join(root, "guanghu-personal-node-probe.timer"), "utf8");
|
|
|
|
test("probe uses a private SSH alias and fixed read-only command", () => {
|
|
assert.match(probe, /NODE_ALIAS/);
|
|
assert.match(probe, /systemctl is-active nginx/);
|
|
assert.match(probe, /df --output=pcent/);
|
|
assert.doesNotMatch(probe, /(?:\d{1,3}\.){3}\d{1,3}/);
|
|
assert.doesNotMatch(probe, /token|password|private[_ -]?key/i);
|
|
});
|
|
|
|
test("probe writes a latest receipt and runs periodically", () => {
|
|
assert.match(probe, /RECEIPT_FILE/);
|
|
assert.match(timer, /OnUnitActiveSec=5min/);
|
|
assert.match(timer, /Persistent=true/);
|
|
});
|