Plan device actions exclusively as approved scripts and provide reboot library revisions

This commit is contained in:
2026-11-18 12:04:58 +01:00
parent adc04f0148
commit cd80bfc704
31 changed files with 1014 additions and 779 deletions
+4 -1
View File
@@ -138,7 +138,9 @@ test('removes the confirmed historical installation and keeps its successor', as
await page.route(origin + '/api/v1/**', async r => {
const req = r.request(), url = new URL(req.url());
const historical = { ...device, agent_id: old, lifecycle: revoked ? 'revoked' : 'replaced', status: 'offline' };
const successor = { ...device, agent_id: active, lifecycle: 'current', status: 'online' };
const successor = { ...device, agent_id: active, lifecycle: 'current', status: 'online', source_id: 'windows.base',
capabilities: ['windows.base/1', 'rmm.sync.v1', 'run_script', 'script.powershell/1', 'script.powershell.process_remote_signed/1',
'script.full_maintenance/1', 'helper.system.v1', 'system:run_script'] };
if (url.pathname === '/api/v1/tenants') return r.fulfill({ json: listing([customer]) });
if (url.pathname === '/api/v1/devices' || url.pathname === path.slice(0, path.lastIndexOf('/'))) {
return r.fulfill({ json: listing(url.searchParams.get('view') === 'history' ? (deleted ? [] : [historical]) : [successor]) });
@@ -191,6 +193,7 @@ test('removes the confirmed historical installation and keeps its successor', as
await page.getByRole('button', { name: 'Bestand' }).click();
await page.getByRole('button', { name: 'NORD-PC' }).click();
await expect(page).toHaveURL(new RegExp(active + '$'));
await expect(page.getByText('PowerShell als Dienstkonto und als Administrator (SYSTEM)')).toBeVisible();
await page.getByText('Gerät verwalten', { exact: true }).click();
await expect(page.getByRole('button', { name: 'Kopplung löschen' })).toHaveCount(0);
await expect(page.getByText('Geräteidentität widerrufen', { exact: true })).toBeVisible();
+4 -5
View File
@@ -15,11 +15,10 @@ test('real dev browser membership/catalog read and administrative controls stay
await test.step('management:membership-heading', async () => { await expect(page.getByRole('heading', { name: 'Mitgliedschaft und Ausführungsstopp' })).toBeVisible(); });
await test.step('management:stop-status', async () => { await expect(page.getByRole('status', { name: 'Ausführungsstatus' })).toHaveText(/Neue Starts sind (freigegeben|gestoppt)/); });
await page.getByRole('link', {name:'Erweitert',exact:true}).click();
await page.getByRole('link', { name: 'Wartungsauftrag planen', exact: true }).click();
await test.step('management:action-option', async () => { await expect(page.getByLabel('Aktion', { exact: true }).locator('option[value="apt_native_acceptance"]')).toHaveCount(1); });
await test.step('management:select-native', async () => { await page.getByLabel('Aktion', { exact: true }).selectOption('apt_native_acceptance'); });
await test.step('management:native-hint', async () => { await expect(page.getByText('NUR SIMULIERTE DEV/TEST-NATIVABNAHME.', { exact: false })).toBeVisible(); });
await test.step('management:identity-unchanged', async () => { await expect(page.getByLabel('Ausführungsidentität', { exact: true })).toHaveValue('agent_service'); });
await expect(page.getByRole('link', { name: 'Wartungsauftrag planen' })).toHaveCount(0);
await page.getByRole('link', { name: 'Aufträge', exact: true }).click();
await page.getByRole('link', { name: 'Neuer Auftrag', exact: true }).click();
await expect(page.getByRole('heading', { name: 'Geräte auswählen' })).toBeVisible();
await test.step('management:inert-controls', async () => { expect(mutations).toBe(0); });
await test.step('management:logout', async () => { await page.getByRole('button', { name: 'Abmelden', exact: true }).click(); await expect(page.getByRole('button', { name: 'Anmelden', exact: true })).toBeVisible(); });
});
+26 -30
View File
@@ -26,7 +26,7 @@ test('simulated human prepares root request through UI only, without approving',
const request = object(expected.request), params = object(request.parameters);
expect(params.execution_identity).toBe('root');
expect(object(request.targets).asset_ids).toEqual([expected.asset_id]);
expect(['run_script', 'query_logs', 'set_service_state', 'apt_native_acceptance', 'ensure_package', 'apply_updates', 'reboot']).toContain(request.action);
if (request.action !== 'run_script') throw new Error('Retired device action. Supply a run_script request for this preparation.');
let authorizationRequests = 0;
page.on('request', r => { if (new URL(r.url()).pathname.endsWith('/authorizations')) authorizationRequests++; });
const sessionResponse = page.waitForResponse(r => new URL(r.url()).pathname === '/auth/session' && r.status() === 200);
@@ -38,39 +38,30 @@ test('simulated human prepares root request through UI only, without approving',
await page.getByRole('checkbox', { name: `Ziel ${text(expected.asset_id)}`, exact: true }).check();
await page.getByRole('link', { name: 'Aufträge', exact: true }).click();
await page.getByRole('link', { name: 'Neuer Auftrag', exact: true }).click();
await page.getByRole('link', { name: 'Verwaltung', exact: true }).click();
await page.getByRole('link', { name: 'Erweitert', exact: true }).click();
await page.getByRole('link', { name: 'Wartungsauftrag planen', exact: true }).click();
await page.getByLabel('Aktion', { exact: true }).selectOption(text(request.action));
if (request.action === 'run_script') {
const variants = params.variants;
if (!Array.isArray(variants) || variants.length !== 1) throw new Error('One exact script variant required');
const variant = object(variants[0]);
await page.getByRole('combobox', { name: 'Interpreter', exact: true }).selectOption(text(variant.interpreter));
await page.getByLabel('Exakte UTF-8 Skriptbytes', { exact: false }).fill(text(variant.script_utf8));
await page.getByLabel('Erwartete stdout-Ausgabe', { exact: false }).fill(text(params.expected_stdout));
} else {
await page.getByLabel('Aktionsparameter', { exact: true }).fill(JSON.stringify(params));
}
await page.getByLabel('Ausführungsidentität', { exact: true }).selectOption('root');
await page.getByLabel('Laufzeitlimit (s)', { exact: true }).fill(String(params.timeout_seconds));
await page.getByLabel('Ausgabelimit (Bytes)', { exact: true }).fill(String(params.max_output_bytes));
// Runner fixes browser/Node TZ to UTC. The actual UI's minute-precision form
// selects an explicit future minute; all resulting exact bytes are reviewed
// again in the separate approval test before any executable job can exist.
await page.getByRole('button', { name: 'Weiter zum Skript', exact: true }).click();
await page.getByRole('radio', { name: 'Einmaliges Skript' }).check();
const variants = params.variants;
if (!Array.isArray(variants) || variants.length !== 1) throw new Error('One exact script variant required');
const variant = object(variants[0]);
await page.getByLabel('Plattform und Interpreter').selectOption(text(variant.interpreter));
await page.getByLabel('Skriptinhalt', { exact: true }).fill(text(variant.script_utf8));
await page.getByLabel('Ausführen als', { exact: true }).selectOption('root');
await page.getByText('Zeitfenster und Ausführungsoptionen', { exact: true }).click();
await page.getByLabel('Erwartete Standardausgabe (optional)').fill(params.expected_stdout == null ? '' : text(params.expected_stdout));
await page.getByLabel('Laufzeit je Gerät in Sekunden').fill(String(params.timeout_seconds));
await page.getByLabel('Ausgabelimit in Byte').fill(String(params.max_output_bytes));
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('Frühester Start', { exact: true }).fill(start.toISOString().slice(0, 16));
await page.getByLabel('Startfrist', { exact: true }).fill(new Date(start.getTime() + 15 * 60000).toISOString().slice(0, 16));
await page.getByLabel('Geräte gleichzeitig').fill('1');
await page.getByLabel('Stopp nach Fehlern', { exact: true }).fill('1');
await page.getByLabel('Begründung', { exact: true }).fill(text(request.reason));
await page.getByRole('button', { name: 'Plan erstellen · noch keine Ausführung' }).click();
const detail = page.locator('section[data-plan-id]');
await detail.getByText('Technische Plandaten', { exact: true }).click();
await expect(detail.getByLabel('Technische Plandaten', { exact: true })).toBeVisible();
const plan = object(JSON.parse(await detail.getByLabel('Technische Plandaten', { exact: true }).innerText()));
const prepared = page.waitForResponse(r => r.request().method() === 'POST' && new URL(r.url()).pathname.endsWith('/operation-plans') && r.ok());
await page.getByRole('button', { name: 'Zusammenfassung ansehen' }).click();
await expect(page.getByRole('heading', { name: 'Zusammenfassung' })).toBeVisible();
const plan = object(await (await prepared).json());
expect(createHash('sha256').update(bytes(plan.plan_payload_bytes)).digest('hex')).toBe(plan.plan_hash);
await detail.getByRole('button', { name: 'Zur Genehmigung einreichen' }).click();
await page.getByRole('button', { name: 'Zur Genehmigung einreichen' }).click();
const op = page.locator('section[data-operation-id]');
await op.getByText('Technische Auftragsdaten', { exact: true }).click();
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"job_count": 0');
@@ -186,6 +177,11 @@ test('one opted-in immutable dev/test action: inspect all fixed bytes → UI cli
const approve = detail.getByRole('button', { name: 'SIMULIERT: Genehmigen', exact: true });
await expect(approve).toBeDisabled();
await detail.getByRole('checkbox', { name: 'Ich habe die Geräte, den Inhalt und die Ausführungsrechte geprüft.', exact: false }).check();
if (action.action !== 'run_script') {
await expect(approve).toBeDisabled();
await expect(detail.getByRole('alert')).toContainText('frühere Aktionsart');
return;
}
await expect(approve).toBeEnabled();
await approve.click(); // Deliberately no API client, injected fetch, route or direct approval request.
await op.getByText('Technische Auftragsdaten', { exact: true }).click();
+129 -37
View File
@@ -96,10 +96,14 @@ test('applies order filters from the first page and clears them on reset', async
expect(requests.at(-1)?.searchParams.has('device')).toBe(false);
});
test('uses the execution stop status and blocks restart planning until the device reports support', async ({ page }) => {
test('shows the execution stop and prepares the Windows restart through a versioned administrator script', async ({ page }) => {
const api = '/api/v1/tenants/' + tenantId;
const permissions = [...auth.permissions, 'tenant:stop', 'system:execute'];
let stopped = false, ready = false;
let stopped = false, scopeDenied = false;
const restart = {
...script, name: 'Windows neu starten', revision_id: randomUUID(), version: 2,
interpreter: 'powershell', execution_identity: 'system', script_utf8: "Write-Output 'Neustart-Test'\n"
};
const writes: unknown[] = [];
await page.route(origin + '/auth/config', r => r.fulfill({ json: {
dev_login_enabled: false, local_login_enabled: true, oidc_configured: false, oidc_login_url: null
@@ -113,12 +117,16 @@ test('uses the execution stop status and blocks restart planning until the devic
return r.fulfill({ json: { tenant_id: tenantId, changes_stopped: stopped } });
}
if (pathname === api + '/devices') return r.fulfill({ json: listing([windows]) });
if (pathname === api + '/devices/' + windows.asset_id) return r.fulfill({ json: {
...windows, tenant_id: tenantId,
capabilities: ready ? ['reboot', 'rmm.sync.v1', 'windows.reboot/1', 'helper.system.v1', 'system:reboot'] : []
} });
if (req.method() !== 'GET') writes.push(req.postDataJSON());
return r.fulfill({ status: 409, json: { code: 'UNSUPPORTED_CAPABILITY' } });
if (pathname === api + '/script-revisions') return r.fulfill({ json: listing([
{ ...restart, script_sha256: hash(restart.script_utf8) }
]) });
if (req.method() !== 'GET') {
expect(req.headers()['x-csrf-token']).toBe(auth.csrf_token);
writes.push({ pathname, body: req.postDataJSON() });
}
return scopeDenied
? r.fulfill({ status: 403, json: { code: 'SCRIPT_HELPER_SCOPE_DENIED' } })
: r.fulfill({ status: 409, json: { code: 'UNSUPPORTED_CAPABILITY' } });
});
await page.goto(origin + '/#verwaltung/rechte');
@@ -132,23 +140,96 @@ test('uses the execution stop status and blocks restart planning until the devic
await expect(page.getByText('Mandantenausführung wieder zulassen', { exact: true })).toBeVisible();
expect(writes).toHaveLength(0);
await page.goto(origin + '/#auftraege/neu');
await page.goto(origin + '/#auftraege/wartung');
await page.getByRole('checkbox', { name: /test-windows/ }).check();
await page.getByRole('button', { name: 'Weiter zur Aktion' }).click();
await page.getByRole('radio', { name: 'Gerät neu starten' }).check();
await page.getByRole('button', { name: 'Weiter zum Skript' }).click();
await page.getByRole('button', { name: 'Neustartskript auswählen' }).click();
await expect(page.getByRole('combobox', { name: 'Bibliotheksskript', exact: true })).toHaveValue(restart.name);
await expect(page.getByRole('combobox', { name: 'Version', exact: true })).toHaveValue(restart.revision_id);
await expect(page.getByRole('combobox', { name: 'Ausführen als', exact: true })).toHaveValue('system');
await page.getByText('Skriptinhalt anzeigen').click();
await expect(page.locator('pre')).toHaveText(restart.script_utf8.trim());
await page.getByLabel('Begründung', { exact: true }).fill('Neustart prüfen');
const plan = page.getByRole('button', { name: 'Zusammenfassung ansehen' });
await expect(page.getByRole('alert')).toContainText('keine Neustartfähigkeit');
await expect(plan).toBeDisabled();
expect(writes).toHaveLength(0);
ready = true;
await expect(plan).toBeEnabled({ timeout: 8000 });
await plan.click();
await expect(page.getByRole('alert')).toContainText('unterstützt die ausgewählte Ausführung noch nicht');
expect(writes).toEqual([expect.objectContaining({
action: 'reboot', targets: { asset_ids: [windows.asset_id] },
parameters: expect.objectContaining({ execution_identity: 'system', reconnect_timeout_seconds: 180 })
})]);
await page.getByRole('button', { name: 'Zusammenfassung ansehen' }).click();
await expect(page.getByRole('alert')).toContainText('Skript-Helper für SYSTEM noch nicht als betriebsbereit gemeldet');
expect(writes).toEqual([{
pathname: api + '/script-revisions/' + restart.revision_id + '/plan',
body: expect.objectContaining({
reason: 'Neustart prüfen', targets: { asset_ids: [windows.asset_id] }, max_runtime_seconds: 120, max_output_bytes: 65536
})
}]);
scopeDenied = true;
await page.getByRole('button', { name: 'Zusammenfassung ansehen' }).click();
await expect(page.getByRole('alert')).toContainText('zentrale Richtlinie erlaubt dieses Administratorskript');
expect(writes).toHaveLength(2);
});
test('offers local admin opt-in on both installer commands and keeps the one-time code outside commands', async ({ page }) => {
const token = 'f'.repeat(64), api = '/api/v1/tenants/' + tenantId;
const requests: string[] = [];
await page.route(origin + '/auth/config', r => r.fulfill({ json: { dev_login_enabled: true, oidc_configured: false, oidc_login_url: null } }));
await page.route(origin + '/auth/session', r => r.fulfill({ json: { ...auth, permissions: [...auth.permissions, 'devices:enroll'] } }));
await page.route(origin + '/api/v1/**', r => {
const req = r.request(), url = new URL(req.url());
if (req.method() !== 'GET') requests.push(url.pathname);
if (url.pathname === '/api/v1/tenants') return r.fulfill({ json: listing(auth.tenants) });
if (url.pathname === api + '/enrollment-tokens') return r.fulfill({ json: {
token, expires_at: new Date(Date.now() + 900000).toISOString(), bootstrap_origin: 'https://bootstrap.example',
release_platforms: ['x86_64-unknown-linux-gnu', 'x86_64-pc-windows-gnu']
} });
return r.fulfill({ json: { ...listing([]), pending_count: 0 } });
});
await page.goto(origin + '/#verwaltung/aufnahme');
const enroll = page.getByRole('region', { name: 'Gerät aufnehmen' });
const option = enroll.getByRole('checkbox', { name: /Administratorskripte/ });
await expect(option).not.toBeChecked();
await enroll.getByRole('button', { name: 'Einmalcode erstellen' }).click();
const commands = enroll.locator('pre');
await expect(commands).toHaveCount(2);
expect((await commands.allTextContents()).join(' ')).not.toMatch(/enable-admin-scripts|EnableAdministratorScripts/);
await option.check();
await expect(commands.nth(0)).toContainText('--enable-admin-scripts');
await expect(commands.nth(1)).toContainText('-EnableAdministratorScripts');
await expect(enroll.getByText(/Für jeden Auftrag gelten zusätzlich/)).toBeVisible();
expect((await commands.allTextContents()).join(' ')).not.toContain(token);
expect(requests).toEqual([api + '/enrollment-tokens']);
});
test('keeps an old pending device action readable and prevents approval', async ({ page }) => {
const golden = JSON.parse(readFileSync(resolve(__dirname, '../script_console/codec-golden.json'), 'utf8'));
const fixed = JSON.parse(Buffer.from(golden[0].plan_payload_bytes).toString('utf8'));
fixed.plan_id = randomUUID();
fixed.tenant_id = tenantId;
const job = fixed.jobs[0];
const end = new Date(Date.now() + 600000).toISOString();
job.payload = { ...job.payload, tenant_id: tenantId, asset_id: linux.asset_id, agent_id: linux.agent_id,
action: { action: 'refresh_inventory', scope: 'linux.base' }, execution_identity: 'agent_service', start_before: end };
delete job.script_sha256;
job.job_payload_hash = hash(JSON.stringify(job.payload));
const bytes = JSON.stringify(fixed);
const plan = { plan_id: fixed.plan_id, plan_hash: hash(bytes), plan_payload_bytes: [...Buffer.from(bytes)],
plan_payload: fixed, jobs: fixed.jobs, targets: [linux], resolved_targets: [{ asset_id: linux.asset_id, agent_id: linux.agent_id }],
excluded_targets: [], expires_at: end, approval_state: 'pending_approval' };
const writes: string[] = [];
await page.route(origin + '/auth/config', r => r.fulfill({ json: {
dev_login_enabled: true, oidc_configured: false, oidc_login_url: null
} }));
await page.route(origin + '/auth/session', r => r.fulfill({ json: { ...auth, permissions: [...auth.permissions, 'plans:approve'] } }));
await page.route(origin + '/api/v1/**', r => {
const url = new URL(r.request().url());
if (r.request().method() !== 'GET') writes.push(url.pathname);
if (url.pathname.endsWith('/operation-plans/' + fixed.plan_id)) return r.fulfill({ json: plan });
if (url.pathname === '/api/v1/tenants') return r.fulfill({ json: listing(auth.tenants) });
return r.fulfill({ json: { ...listing([]), pending_count: 0 } });
});
await page.goto(origin + '/#genehmigungen/pruefen/' + tenantId + '/' + fixed.plan_id);
await expect(page.locator('.review-targets').getByText('test-linux', { exact: true })).toBeVisible();
await expect(page.getByRole('alert')).toHaveText(/frühere Aktionsart/);
await page.getByRole('checkbox', { name: /Ich habe die Geräte/ }).check();
await expect(page.getByRole('button', { name: 'SIMULIERT: Genehmigen' })).toBeDisabled();
await expect(page.getByRole('button', { name: 'SIMULIERT: Ablehnen' })).toBeEnabled();
expect(writes).toEqual([]);
});
test('shows the bound script text alongside single and per-device results', async ({ page }) => {
@@ -266,11 +347,17 @@ test('shows the bound script text alongside single and per-device results', asyn
await expect(source.getByLabel('Gespeicherter Skripttext')).toHaveCount(0);
});
for (const library of [true, false]) {
test(
library
? 'pins a revision, blocks an incompatible target and finds the submitted order after a lost response'
: 'submits a one-time script without publishing a library revision',
for (const scenario of ['library', 'once', 'restart'] as const) {
const library = scenario !== 'once';
const restart = scenario === 'restart';
const revision = restart ? { ...script, name: 'Linux neu starten', execution_identity: 'root', script_utf8: "printf 'Neustart-Test\n'\n" } : script;
const session = restart ? { ...auth, permissions: [...auth.permissions, 'root:execute'] } : auth;
const title = {
library: 'pins a revision, blocks an incompatible target and finds the submitted order after a lost response',
once: 'submits a one-time script without publishing a library revision',
restart: 'submits the versioned Linux restart through the ordinary script plan with root identity'
}[scenario];
test(title,
async ({ page }) => {
let operationId: string | null = null;
let plan: Record<string, unknown> | null = null;
@@ -283,7 +370,7 @@ for (const library of [true, false]) {
import React from '/node_modules/.vite/deps/react.js';
import ReactDOM from '/node_modules/.vite/deps/react-dom_client.js';
import {OrderComposer} from '/src/order-composer.tsx';
ReactDOM.createRoot(document.querySelector('#root')).render(React.createElement(OrderComposer,{tenantId:'${tenantId}',auth:${JSON.stringify(auth)},initialAssetIds:['${linux.asset_id}'],onSubmitted:id=>document.body.setAttribute('data-operation',id)}));
ReactDOM.createRoot(document.querySelector('#root')).render(React.createElement(OrderComposer,{tenantId:'${tenantId}',auth:${JSON.stringify(session)},initialAssetIds:['${linux.asset_id}'],onSubmitted:id=>document.body.setAttribute('data-operation',id)}));
</script>`
})
);
@@ -297,7 +384,7 @@ for (const library of [true, false]) {
return r.fulfill({ json: suffix.endsWith(linux.asset_id) ? linux : windows });
if (suffix === '/script-revisions')
return r.fulfill({
json: listing([{ ...script, script_sha256: hash(script.script_utf8), version: issuedVersion }])
json: listing([{ ...revision, script_sha256: hash(revision.script_utf8), version: issuedVersion }])
});
if (suffix === '/operation-plans/' + plan?.plan_id)
return r.fulfill({ json: { ...plan, operation_id: operationId } });
@@ -305,16 +392,17 @@ for (const library of [true, false]) {
posted.push(suffix);
const body = req.postDataJSON();
expect(req.headers()['x-csrf-token']).toBe(auth.csrf_token);
if (suffix === (library ? '/script-revisions/' + script.revision_id + '/plan' : '/operation-plans')) {
if (suffix === (library ? '/script-revisions/' + revision.revision_id + '/plan' : '/operation-plans')) {
expect(body.targets.asset_ids).toEqual([linux.asset_id]);
expect(body.reason).toBe('Abnahme');
const content = library ? script.script_utf8 : body.parameters.variants[0].script_utf8;
const content = library ? revision.script_utf8 : body.parameters.variants[0].script_utf8;
const action = {
action: 'run_script',
interpreter: 'posix_sh',
script_utf8: content,
arguments: [],
expected_stdout: null
expected_stdout: null,
...(restart ? { privileged_script_profile: 'full_maintenance_v1' } : {})
};
const payload = {
schema_version: 1,
@@ -326,7 +414,7 @@ for (const library of [true, false]) {
job_id: randomUUID(),
attempt_id: randomUUID(),
action,
execution_identity: 'agent_service',
execution_identity: revision.execution_identity,
not_before: body.schedule.not_before,
start_before: body.schedule.start_before,
max_runtime_seconds: library ? body.max_runtime_seconds : body.parameters.timeout_seconds,
@@ -345,8 +433,8 @@ for (const library of [true, false]) {
...(library
? {
script_revision: {
revision_id: script.revision_id,
name: script.name,
revision_id: revision.revision_id,
name: revision.name,
version: 1,
script_sha256: job.script_sha256
}
@@ -383,12 +471,16 @@ for (const library of [true, false]) {
if (library) await page.getByRole('checkbox', { name: /test-windows/ }).check();
await page.getByRole('button', { name: 'Weiter zum Skript' }).click();
if (library) {
await page.getByLabel('Bibliotheksskript').selectOption(script.name);
await page.getByLabel('Bibliotheksskript').selectOption(revision.name);
await expect(page.getByRole('alert')).toContainText('test-windows');
await expect(page.getByRole('button', { name: 'Zusammenfassung ansehen' })).toBeDisabled();
await page.getByRole('button', { name: 'Zurück zu Geräten' }).click();
await page.getByRole('checkbox', { name: /test-windows/ }).uncheck();
await page.getByRole('button', { name: 'Weiter zum Skript' }).click();
if (restart) {
await page.getByRole('button', { name: 'Neustartskript auswählen' }).click();
await expect(page.getByRole('combobox', { name: 'Ausführen als', exact: true })).toHaveValue('root');
}
} else {
await page.getByRole('radio', { name: 'Einmaliges Skript' }).check();
await page.getByLabel('Skriptinhalt').fill('uname\n');
@@ -409,7 +501,7 @@ for (const library of [true, false]) {
await expect(page.locator('body')).toHaveAttribute('data-operation', /^[a-f0-9-]{36}$/);
expect(await page.locator('body').getAttribute('data-operation')).toBe(operationId);
expect(posted).toEqual([
library ? '/script-revisions/' + script.revision_id + '/plan' : '/operation-plans',
library ? '/script-revisions/' + revision.revision_id + '/plan' : '/operation-plans',
'/operation-plans/' + plan!.plan_id + '/submit'
]);
expect(await page.evaluate(() => sessionStorage.length)).toBe(0);
+14
View File
@@ -157,6 +157,20 @@ class ScriptHelperInstallation(unittest.TestCase):
self.assertIn(b'lifecycle.py run-helper',files[self.unit])
self.assertIn(str(self.previous).encode(),self.unit.read_bytes())
def test_service_environment_cannot_replace_restrictive_operator_pin_or_claim_a_release(self):
lifecycle.save(self.root / 'config.json', {'gateway':'https://127.0.0.1','tenant':self.previous})
lifecycle.save(self.folder / 'script-pin.json',self.pin)
self.state.return_value = 'enabled'
environment = {'RMM_FULL_MAINTENANCE_POLICY_FILE':'/etc/site/restricted.json',
'RMM_SCRIPT_HELPER_RELEASE':self.previous}
with patch.dict(lifecycle.os.environ,environment,clear=True), patch.object(lifecycle.os,'execv'):
lifecycle.run_agent()
self.assertEqual(lifecycle.os.environ['RMM_FULL_MAINTENANCE_POLICY_FILE'],'/etc/site/restricted.json')
self.assertNotIn('RMM_SCRIPT_HELPER_RELEASE',lifecycle.os.environ)
with patch.dict(lifecycle.os.environ,{},clear=True), patch.object(lifecycle.os,'execv'):
lifecycle.run_agent()
self.assertEqual(lifecycle.os.environ['RMM_SCRIPT_HELPER_RELEASE'],self.release)
def test_rejected_pair_does_not_run_candidate_and_altered_policy_stays_intact(self):
with patch.object(lifecycle.subprocess,'check_output',side_effect=subprocess.CalledProcessError(1,'verify')) as run:
with self.assertRaises(subprocess.CalledProcessError):