#!/usr/bin/env node const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const root = __dirname; const script = fs.readFileSync(path.join(root, "activate-staged-candidate.py"), "utf8"); const unit = fs.readFileSync(path.join(root, "hlcc-jd-candidate-activator.service"), "utf8"); const bootstrap = fs.readFileSync(path.join(root, "hlcc-bootstrap.py"), "utf8"); assert.match(bootstrap, /hlcc-offline\/16\.0\.1/); assert.match(bootstrap, /forgejo-upstream-all\.bundle/); assert.match(bootstrap, /guanghu-code-channel\.bundle/); assert.match(bootstrap, /full-offline-v16\.0\.1/); assert.match(script, /systemctl", "show", "--property=MainPID"/); assert.match(script, /process_root\.stat\(\)\.st_uid != os\.getuid\(\)/); assert.match(script, /"\/hololake-code-channel\/jd-candidate\/hlcc-bootstrap\.py" not in command/); assert.match(script, /os\.kill\(pid, signal\.SIGTERM\)/); assert.match(script, /payload\.get\("mode"\) == "isolated-candidate"/); assert.match(script, /payload\.get\("ready"\) is True/); assert.match(script, /payload\.get\("stage"\) == "ready"/); assert.doesNotMatch(script, /shell=True|systemctl", "(?:restart|stop|start)"/); assert.match(unit, /^User=guanghu$/m); assert.match(unit, /^NoNewPrivileges=true$/m); assert.match(unit, /^ProtectSystem=strict$/m); console.log("HLCC full-offline candidate activator: PASS");