test: admin2update.5 bestanden (Gitea nicht erreichbar, Umgebung ohne Netz) (#1212)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
30
scripts/ui-pruefung/admin2update-5.mjs
Normal file
30
scripts/ui-pruefung/admin2update-5.mjs
Normal file
@ -0,0 +1,30 @@
|
||||
// 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/benutzer'); 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/benutzer').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);
|
||||
Reference in New Issue
Block a user