Initial
This commit is contained in:
@@ -2,7 +2,8 @@ import { db, load } from './setup.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const { getSetting, getBooleanSetting, updateSettings, effectiveTrustedOrigins } = await load('../models/settingsModel.js');
|
||||
const { getSetting, getBooleanSetting, getStringSetting, updateSettings, effectiveTrustedOrigins } = await load('../models/settingsModel.js');
|
||||
const { resolvePowerShellExecutable, powerShellSpawnFailureLines } = await load('../services/powershellRunner.js');
|
||||
|
||||
test('unpinned settings seed as editable defaults', () => {
|
||||
// No SERVER_FQDN env var is set in the test environment, so server_fqdn is a
|
||||
@@ -30,6 +31,19 @@ test('allow_script_execution is readable as an effective boolean', () => {
|
||||
assert.equal(getBooleanSetting('allow_script_execution', false), true);
|
||||
});
|
||||
|
||||
test('powershell_bin config is used by the runner at execution time', () => {
|
||||
updateSettings({ powershell_bin: 'powershell.exe' });
|
||||
assert.equal(getStringSetting('powershell_bin', 'pwsh'), 'powershell.exe');
|
||||
assert.equal(resolvePowerShellExecutable(), 'powershell.exe');
|
||||
});
|
||||
|
||||
test('PowerShell spawn failures include operator guidance', () => {
|
||||
const lines = powerShellSpawnFailureLines({ code: 'ENOENT', message: 'spawn pwsh ENOENT' }, 'pwsh');
|
||||
assert.ok(lines.some((line) => line.includes('configured PowerShell executable "pwsh"')));
|
||||
assert.ok(lines.some((line) => line.includes('Config > PowerShell Binary')));
|
||||
assert.ok(lines.some((line) => line.includes('powershell.exe')));
|
||||
});
|
||||
|
||||
test('effectiveTrustedOrigins merges admin edits with built-in defaults', () => {
|
||||
updateSettings({ trusted_origins: 'https://ops.example.com' });
|
||||
const origins = effectiveTrustedOrigins();
|
||||
|
||||
Reference in New Issue
Block a user