Files
nexus/scripts/ui-pruefung/admin2update-5.mjs

31 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// admin2update.5 (#1212): Gitea nicht erreichbar. Läuft nur in einer Umgebung ohne Netz (unshare -rn),
// siehe Bericht. Aufruf: node admin2update-5.mjs <Admin-Passwort> <Ausgabeordner>. NEXUS_BASE, NEXUS_DB wie in admin2update.mjs.
import * as cdp from './lib.mjs';
import fs from 'node:fs';
import { DatabaseSync } from 'node:sqlite';
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18119', DB = process.env.NEXUS_DB;
const [pw, out] = process.argv.slice(2);
fs.mkdirSync(out, { recursive: true });
const sleep = ms => new Promise(r => setTimeout(r, ms));
const res = []; const ok = (n, c, d = '') => { res.push(!!c); console.log((c ? 'ok ' : 'FEHLER') + ' ' + n + (d ? ' – ' + d : '')); };
const b = await cdp.start({ port: 9379 });
try {
await b.login(BASE, 'claude', pw);
await b.goto(BASE + '/ui/system'); await sleep(800);
await b.eval(`document.querySelector('button[name="kanal"][value="regulaer"]').click()`);
await sleep(6000);
const url = await b.eval(`location.href`);
const text = await b.eval(`document.body.textContent`);
ok('Hinweis zur fehlgeschlagenen Prüfung', url.includes('update_fehler') && text.includes('Die Prüfung auf Gitea ist fehlgeschlagen'), url);
ok('Dienst antwortet danach weiter', (await b.eval(`fetch('/ui/system').then(r => r.status)`)) === 200);
if (DB) {
const db = new DatabaseSync(DB, { readOnly: true });
const z = db.prepare(`SELECT ziel FROM audit WHERE aktion = 'system.update_check' ORDER BY id DESC LIMIT 1`).get();
db.close();
ok('Audit: regulaer: fehler', z && z.ziel === 'regulaer: fehler', JSON.stringify(z));
}
} finally { b.close(); }
const alle = res.every(Boolean);
console.log(alle ? 'ERGEBNIS: alle ' + res.length + ' Prüfungen ok' : 'ERGEBNIS: ' + res.filter(x => !x).length + ' von ' + res.length + ' fehlgeschlagen');
process.exit(alle ? 0 : 1);