Repository files, collaboration, releases and project activity.
archforge-external-status / tests/https-repair.test.jsmain
▤ tests/https-repair.test.js1260 bytes
30 lines · Select a line number for a permalink
1
'use strict';2
const test=require('node:test');3
const assert=require('node:assert/strict');4
const fs=require('node:fs');5
const path=require('node:path');6
const {spawnSync}=require('node:child_process');7
const main=path.resolve(__dirname,'../scripts/fix-https.sh');8
const wrapper=path.resolve(__dirname,'../fix-https.sh');9
test('HTTP-only Caddy recovery is bash-valid',()=>{10
for(const f of [main,wrapper]){11
const result=spawnSync('bash',['-n',f],{encoding:'utf8'});12
assert.equal(result.status,0, result.stderr);13
}14
});15
test('HTTPS repair checks backend and listener, and can roll back Caddy',()=>{16
const script=fs.readFileSync(main,'utf8');17
assert.match(script,/curl.*127\.0\.0\.1:3000\/healthz/);18
assert.match(script,/CADDYFILE=\/etc\/caddy\/Caddyfile/);19
assert.match(script,/BACKUP="\/root\/archforge-caddy-before-https-fix-/);20
assert.match(script,/--adapter caddyfile/);21
assert.match(script,/has_443/);22
assert.match(script,/rollback/);23
assert.match(script,/journalctl -u caddy/);24
assert.doesNotMatch(script,/sqlite3\b|npm install|apt-get/);25
});26
test('ArchForge wrapper invokes installed script without updating app itself',()=>{27
const script=fs.readFileSync(wrapper,'utf8');28
assert.match(script,/scripts\/fix-https\.sh/);29
});