feat: deploy cloud-only RMM and verify audited APT diagnostics
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-13 13:49:11 +01:00
parent 6c3203d725
commit fbef0e4e2f
48 changed files with 3125 additions and 34 deletions
+22
View File
@@ -0,0 +1,22 @@
import { defineConfig } from '../../web/node_modules/@playwright/test/index.js';
import { resolve } from 'node:path';
import { readdirSync, existsSync } from 'node:fs';
const root = resolve(__dirname, '../..');
const browsers = resolve(root, 'web/node_modules/.cache/playwright-browsers');
const version = readdirSync(browsers).find(x => /^chromium-/.test(x));
if (!version) throw new Error('Installed Chromium required');
const executablePath = ['chrome-linux/chrome', 'chrome-linux64/chrome']
.map(x => resolve(browsers, version, x)).find(x => existsSync(x));
if (!executablePath) throw new Error('Installed Chromium required');
export default defineConfig({
testDir: '../../tests/browser', testMatch: 'mvp-actions.spec.ts', workers: 1,
fullyParallel: false, retries: 0, timeout: 120000,
reporter: [['../../tests/browser/safe-reporter.ts']],
outputDir: '../../web/node_modules/.cache/cloud-acceptance/results',
use: { browserName: 'chromium', baseURL: 'https://localhost:18443',
actionTimeout: 15000, navigationTimeout: 20000,
ignoreHTTPSErrors: false, timezoneId: 'UTC', trace: 'off', screenshot: 'off', video: 'off',
launchOptions: { executablePath, env: { ...process.env,
HOME: resolve(root, 'web/node_modules/.cache/cloud-acceptance/home') } } },
});
+59
View File
@@ -0,0 +1,59 @@
// Actual UI only. No page.request, fetch injection, approval API or DB access.
const fs = require('node:fs');
const path = require('node:path');
const crypto = require('node:crypto');
const { chromium } = require('../../web/node_modules/playwright');
const root = path.resolve(__dirname, '../..');
const assert = (value) => { if (!value) throw new Error('UI contract mismatch'); };
(async () => {
const file = path.resolve(process.argv[2]);
const stat = fs.lstatSync(file);
assert(stat.isFile() && !stat.isSymbolicLink() && stat.uid === process.getuid() && (stat.mode & 0o777) === 0o600);
const expected = JSON.parse(fs.readFileSync(file, 'utf8'));
assert(expected.profile === 'dev/test' && ['hello', 'refresh_inventory', 'cancel_queued'].includes(expected.case));
assert(expected.expected_principal === 'simulated-testprincipal-a');
const loginFile = path.join(root, 'credentials/server-browser-login.json');
const loginStat = fs.lstatSync(loginFile);
assert(loginStat.isFile() && !loginStat.isSymbolicLink() && loginStat.uid === process.getuid() && (loginStat.mode & 0o777) === 0o600);
const login = JSON.parse(fs.readFileSync(loginFile, 'utf8'));
const cache = path.join(root, 'web/node_modules/.cache/cloud-acceptance');
const browserRoot = path.join(root, 'web/node_modules/.cache/playwright-browsers');
const version = fs.readdirSync(browserRoot).find(x => /^chromium-/.test(x));
const candidates = ['chrome-linux/chrome', 'chrome-linux64/chrome'].map(x => path.join(browserRoot, version, x));
const browser = await chromium.launch({ headless: true, executablePath: candidates.find(x => fs.existsSync(x)),
env: { ...process.env, HOME: path.join(cache, 'home') } });
try {
const page = await browser.newPage({ ignoreHTTPSErrors: false });
await page.goto('https://localhost:18443/');
await page.getByLabel('Benutzername').fill(login.username);
await page.getByLabel('Passwort', { exact: true }).fill(login.password);
const sessionResponse = page.waitForResponse(r => new URL(r.url()).pathname === '/auth/session' && r.status() === 200);
await page.getByRole('button', { name: 'Anmelden', exact: true }).click();
const session = await (await sessionResponse).json();
assert(session.testsimulation === true && session.approval_origin === 'dev_test_browser_simulation' && session.principal === expected.expected_principal);
await page.getByRole('status').filter({ hasText: 'SIMULIERT' }).waitFor();
await page.getByRole('button', { name: expected.operation_id, exact: true }).click();
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Antrag / Ausführung ' + expected.operation_id, exact: true }) });
const pending = JSON.parse(await op.locator('pre').first().innerText());
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
const rendered = JSON.parse(await detail.locator('pre').first().innerText());
assert(rendered.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(rendered.plan_payload_bytes)).digest('hex') === expected.plan.plan_hash);
assert(JSON.stringify(rendered.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
assert(rendered.jobs.length === 1 && rendered.resolved_targets.length === 1);
const job = rendered.jobs[0]; const payload = job.payload;
assert(job.job_payload_hash === expected.job.job_payload_hash && JSON.stringify(payload) === JSON.stringify(expected.job.payload));
assert(payload.agent_id === expected.agent_id && payload.asset_id === expected.asset_id && payload.tenant_id === expected.tenant_id);
assert(payload.execution_identity === 'agent_service' && payload.max_runtime_seconds === 60 && payload.max_output_bytes <= 65536);
assert(Date.parse(payload.start_before) > Date.now());
if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
else assert(payload.action.action === 'refresh_inventory' && payload.action.scope === 'linux.base');
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
assert(await approve.isDisabled());
await detail.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check();
await approve.click();
await op.locator('p.warning').filter({ hasText: 'Antrag: approved' }).waitFor();
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
} finally { await browser.close(); }
})().catch(error => { console.log('CLOUD_UI_INCOMPLETE:' + error.constructor.name); process.exitCode = 1; });
+94
View File
@@ -0,0 +1,94 @@
// Actual UI interactions only; credentials remain in the protected login file.
const fs = require('node:fs');
const path = require('node:path');
const crypto = require('node:crypto');
const { isDeepStrictEqual } = require('node:util');
const { chromium } = require('../../web/node_modules/playwright');
const root = path.resolve(__dirname, '../..');
const assert = value => { if (!value) throw new Error('Diagnostic UI contract mismatch'); };
function readPrivate(file) {
const s = fs.lstatSync(file);
assert(s.isFile() && !s.isSymbolicLink() && s.uid === process.getuid() && (s.mode & 0o777) === 0o600 && s.size < 1048576);
return JSON.parse(fs.readFileSync(file, 'utf8'));
}
(async () => {
const file = path.resolve(process.argv[2]); const expected = readPrivate(file);
assert(expected.profile === 'dev/test' && expected.case === 'apt_diagnostic_v1' && expected.expected_principal === 'simulated-testprincipal-a');
const source = fs.readFileSync(path.join(root, 'deploy/linux/apt-diagnostic.py'), 'utf8');
const script = "exec /usr/bin/python3 -I - <<'RMM_APT_DIAGNOSTIC'\n" + source + '\nRMM_APT_DIAGNOSTIC\n';
const login = readPrivate(path.join(root, 'credentials/server-browser-login.json'));
const browsers = path.join(root, 'web/node_modules/.cache/playwright-browsers');
const version = fs.readdirSync(browsers).find(x => /^chromium-/.test(x));
const executablePath = ['chrome-linux/chrome', 'chrome-linux64/chrome'].map(x => path.join(browsers, version, x)).find(x => fs.existsSync(x));
const browser = await chromium.launch({ headless: true, executablePath,
env: { ...process.env, HOME: path.join(root, 'web/node_modules/.cache/cloud-acceptance/home') } });
try {
const page = await browser.newPage({ ignoreHTTPSErrors: false, timezoneId: 'UTC' });
page.setDefaultTimeout(15000);
let approvals = 0;
page.on('request', r => { if (new URL(r.url()).pathname.endsWith('/authorizations')) approvals++; });
await page.goto('https://localhost:18443/');
await page.getByLabel('Benutzername').fill(login.username);
await page.getByLabel('Passwort', { exact: true }).fill(login.password);
const response = page.waitForResponse(r => new URL(r.url()).pathname === '/auth/session' && r.status() === 200);
await page.getByRole('button', { name: 'Anmelden', exact: true }).click();
const session = await (await response).json();
assert(session.testsimulation === true && session.approval_origin === 'dev_test_browser_simulation' && session.principal === expected.expected_principal);
await page.getByRole('status').filter({ hasText: 'SIMULIERT' }).waitFor();
if (expected.phase === 'prepare') {
assert(expected.request.parameters.variants[0].script_utf8 === script && expected.request.parameters.expected_stdout === null);
await page.getByRole('checkbox', { name: 'Ziel ' + expected.asset_id, exact: true }).check();
await page.getByLabel('Aktion', { exact: true }).selectOption('run_script');
await page.getByRole('combobox', { name: 'Interpreter', exact: true }).selectOption('posix_sh');
await page.getByLabel('Exakte UTF-8 Skriptbytes', { exact: false }).fill(script);
await page.getByLabel('Erwartete stdout-Ausgabe', { exact: false }).fill('');
await page.getByLabel('Ausführungsidentität', { exact: true }).selectOption('root');
await page.getByLabel('Laufzeitlimit (s)', { exact: true }).fill('90');
await page.getByLabel('Ausgabelimit (Bytes)', { exact: true }).fill('16384');
const start = new Date(Math.ceil(Date.now() / 60000) * 60000);
await page.getByLabel('Frühester Start (lokale Zeit)', { exact: true }).fill(start.toISOString().slice(0, 16));
await page.getByLabel('Startfrist / Ablauf (lokale Zeit)', { exact: true }).fill(new Date(start.getTime() + 15 * 60000).toISOString().slice(0, 16));
await page.getByLabel('Maximal parallel', { exact: true }).fill('1');
await page.getByLabel('Stopp nach Fehlern', { exact: true }).fill('1');
await page.getByLabel('Begründung', { exact: true }).fill(expected.request.reason);
await page.getByRole('button', { name: 'Plan erstellen · noch keine Ausführung' }).click();
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
const plan = JSON.parse(await detail.locator('pre').innerText());
assert(crypto.createHash('sha256').update(Buffer.from(plan.plan_payload_bytes)).digest('hex') === plan.plan_hash);
await detail.getByRole('button', { name: 'Antrag absenden · pending_approval' }).click();
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: /^Antrag \/ Ausführung / }) });
await op.locator('pre').first().filter({ hasText: '"job_count": 0' }).waitFor();
const operation = JSON.parse(await op.locator('pre').first().innerText());
assert(operation.approval_state === 'pending_approval' && operation.execution_state === null && approvals === 0);
assert(path.dirname(path.resolve(expected.output_file)) === path.dirname(file));
fs.writeFileSync(expected.output_file, JSON.stringify({ plan, operation }), { flag: 'wx', mode: 0o600 });
} else {
assert(expected.phase === 'approve');
await page.getByRole('button', { name: expected.operation_id, exact: true }).click();
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Antrag / Ausführung ' + expected.operation_id, exact: true }) });
const pending = JSON.parse(await op.locator('pre').first().innerText());
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen' }).click();
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
const plan = JSON.parse(await detail.locator('pre').innerText());
assert(plan.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(plan.plan_payload_bytes)).digest('hex') === plan.plan_hash);
assert(JSON.stringify(plan.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
assert(plan.jobs.length === 1 && plan.resolved_targets.length === 1);
const job = plan.jobs[0]; const p = job.payload;
assert(isDeepStrictEqual(job, expected.plan.jobs[0]));
assert(p.agent_id === expected.agent_id && p.asset_id === expected.asset_id && p.tenant_id === expected.tenant_id);
assert(p.execution_identity === 'root' && p.max_runtime_seconds === 90 && p.max_output_bytes === 16384 && Date.parse(p.start_before) > Date.now());
assert(isDeepStrictEqual(p.action, { action: 'run_script', interpreter: 'posix_sh', script_utf8: script, arguments: [], expected_stdout: null }));
const button = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
assert(await button.isDisabled());
await detail.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check();
await button.click();
await op.locator('p.warning').filter({ hasText: 'Antrag: approved' }).waitFor();
}
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
} finally { await browser.close(); }
})().catch(error => {
const line = error.stack?.match(/cloud_apt_diagnostic\.cjs:(\d+):\d+/)?.[1] || 'unknown';
console.log('CLOUD_APT_DIAGNOSTIC_UI_INCOMPLETE:' + error.constructor.name + ':source_line=' + line);
process.exitCode = 1;
});
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
"""Cloud-only existing UI contracts; never starts a server, agent or fixture."""
import argparse
import os
import re
from pathlib import Path
import subprocess
import sys
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
import cloud_mvp_acceptance as cloud
CASES=('service_setup','service_start','service_stop','apt_native_install','apt_native_update','ensure_package','apply_updates')
def run(file,prepare=False):
value=cloud.contract.protected_json(file)
cloud.require(value.get('profile')=='dev/test' and value.get('case') in CASES and
value.get('expected_principal')=='simulated-testprincipal-a','fixed cloud root cases only')
if prepare:
cloud.require(value.get('phase')=='prepare' and value['request']['parameters']['execution_identity']=='root','root preparation only')
cloud.prepare_browser()
env={k:v for k,v in os.environ.items() if k not in ('DEBUG','PWDEBUG','NODE_DEBUG')}
env.update(RMM_E2E_PROFILE='dev/test',RMM_E2E_MODE='mvp-prepare' if prepare else 'mvp-actions',
RMM_E2E_CASE_FILE=str(Path(file).resolve()),RMM_E2E_LOGIN_FILE=str(cloud.ROOT/'credentials/server-browser-login.json'),TZ='UTC')
result=subprocess.run(['node',str(cloud.ROOT/'web/node_modules/@playwright/test/cli.js'),'test',
'--config',str(cloud.ROOT/'deploy/browser/cloud-root.config.ts')],cwd=cloud.ROOT,env=env,
capture_output=True,timeout=150)
# The dedicated reporter emits only generic statuses. Never publish raw
# browser failures, request headers, page state or entered credentials.
if result.returncode!=0:
lines=re.findall(rb'Cloud/root UI failure source_line=(\d+)',result.stdout)
raise cloud.contract.GuardError('cloud_root_UI_incomplete_no_automatic_repeat; source_lines='+','.join(x.decode('ascii') for x in lines))
if __name__=='__main__':
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--case-file',required=True)
parser.add_argument('--prepare-only',action='store_true');args=parser.parse_args()
try:run(args.case_file,args.prepare_only)
except Exception:
print('CLOUD_ROOT_UI_INCOMPLETE; no automatic repeat');raise SystemExit(2) from None