Admin: Live-Konsole der Container und Live-Log der Docker-Hosts (nur lesen, Passwörter ausgeblendet)
This commit is contained in:
1 parent
fb96fb5d08
commit
ee9c488a7e
9 files changed
+328
-3
No files matched your search
@@ -690,3 +690,26 @@ test('Chat: Match-Chat für beide Teams und Organisator, Team-Chat nur fürs eig
|
||||
await close();
|
||||
}
|
||||
});
|
||||
test('Konsole: nur für Admins, Ausgabe kommt live, unbekannte Server 404', async () => {
|
||||
const { app, call, close } = await setup({ adminPassword: 'admin-geheim' });
|
||||
try {
|
||||
const token = (await call('POST', '/admin/login', { body: { password: 'admin-geheim' } })).body.token;
|
||||
const m = (await call('POST', '/matches', { body: { teamA: 'Alpha', teamB: 'Bravo', mode: 'wingman', format: 'bo1' } })).body;
|
||||
await waitFor(() => app.service.serverRow(m.id)?.handle, { label: 'Server gestartet' });
|
||||
const base = `http://127.0.0.1:${app.server.address().port}/api/admin/logs`;
|
||||
|
||||
assert.equal((await fetch(`${base}/match/${m.id}`)).status, 401);
|
||||
assert.equal((await fetch(`${base}/match/gibtsnicht`, { headers: { authorization: `Bearer ${token}` } })).status, 404);
|
||||
assert.equal((await fetch(`${base}/sonstwas/${m.id}`, { headers: { authorization: `Bearer ${token}` } })).status, 404);
|
||||
|
||||
const ctl = new AbortController();
|
||||
const res = await fetch(`${base}/match/${m.id}`, { headers: { authorization: `Bearer ${token}` }, signal: ctl.signal });
|
||||
assert.equal(res.status, 200);
|
||||
const reader = res.body.getReader();
|
||||
const { value } = await reader.read();
|
||||
assert.match(new TextDecoder().decode(value), /Demo-Adapter/);
|
||||
ctl.abort();
|
||||
} finally {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { formatDockerEvent } from '../src/servers/dockerAdapter.js';
|
||||
|
||||
const ev = (o) => JSON.stringify({ time: 1793549403, ...o });
|
||||
|
||||
test('Docker-Ereignisse werden lesbar, App-Container markiert', () => {
|
||||
const start = formatDockerEvent(ev({ Type: 'container', Action: 'start', Actor: { ID: 'abc', Attributes: { name: 'cs2mv-knife1', image: 'joedwards32/cs2:latest', 'cs2-mapveto': '1' } } }));
|
||||
assert.match(start, /Container cs2mv-knife1 \[Mapveto\] gestartet \(joedwards32\/cs2:latest\)$/);
|
||||
const die = formatDockerEvent(ev({ Type: 'container', Action: 'die', Actor: { ID: 'abc', Attributes: { name: 'gitea', exitCode: '137' } } }));
|
||||
assert.match(die, /Container gitea beendet \(Exit-Code 137\)$/);
|
||||
assert.match(formatDockerEvent(ev({ Type: 'image', Action: 'pull', Actor: { ID: 'joedwards32/cs2:latest', Attributes: { name: 'joedwards32/cs2' } } })), /Image joedwards32\/cs2 geladen/);
|
||||
});
|
||||
|
||||
test('Healthchecks, Mounts und kaputte Zeilen fallen weg', () => {
|
||||
assert.equal(formatDockerEvent(ev({ Type: 'container', Action: 'exec_start: /bin/sh -c mysql --password=geheim', Actor: { Attributes: {} } })), null);
|
||||
assert.equal(formatDockerEvent(ev({ Type: 'volume', Action: 'mount', Actor: { Attributes: {} } })), null);
|
||||
assert.equal(formatDockerEvent('kein json'), null);
|
||||
});
|
||||
Reference in new issue
Block a user