Skip to content

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';
2const test=require('node:test');
3const assert=require('node:assert/strict');
4const fs=require('node:fs');
5const path=require('node:path');
6const {spawnSync}=require('node:child_process');
7const main=path.resolve(__dirname,'../scripts/fix-https.sh');
8const wrapper=path.resolve(__dirname,'../fix-https.sh');
9test('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});
15test('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});
26test('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});