test(02-01): add failing test stubs for all four generators
- rclone-conf.test.ts: azureblob/s3/s3-compatible fixtures, error cases - intune-install.test.ts: configPath, includeInstall, UTF-8 write, credential safety - intune-detection.test.ts: configPath, exit codes, stdout only (no STDERR contamination) - rmm-script.test.ts: configPath, includeInstall, ErrorActionPreference=Stop
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
// src/generators/intune-install.test.ts
|
||||
// Tests for buildIntuneInstall — Intune PowerShell install script generator.
|
||||
// RED: imports will fail until Plan 02-02 creates intune-install.ts.
|
||||
|
||||
import { buildIntuneInstall } from './intune-install';
|
||||
import { INITIAL_STATE } from '../store/types';
|
||||
import type { WizardState } from '../store/types';
|
||||
|
||||
// --- Fixtures ---
|
||||
|
||||
const machineWideState: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: {
|
||||
name: 'my-azure',
|
||||
backendType: 'azureblob',
|
||||
params: { account: 'mystorageaccount', key: 'BASE64KEY', sas_url: '' },
|
||||
},
|
||||
deployment: {
|
||||
...INITIAL_STATE.deployment,
|
||||
configPath: 'machine-wide',
|
||||
includeInstall: false,
|
||||
},
|
||||
};
|
||||
|
||||
const userProfileState: WizardState = {
|
||||
...machineWideState,
|
||||
deployment: {
|
||||
...machineWideState.deployment,
|
||||
configPath: 'user-profile',
|
||||
},
|
||||
};
|
||||
|
||||
const withInstallState: WizardState = {
|
||||
...machineWideState,
|
||||
deployment: {
|
||||
...machineWideState.deployment,
|
||||
includeInstall: true,
|
||||
},
|
||||
};
|
||||
|
||||
const withoutInstallState: WizardState = {
|
||||
...machineWideState,
|
||||
deployment: {
|
||||
...machineWideState.deployment,
|
||||
includeInstall: false,
|
||||
},
|
||||
};
|
||||
|
||||
// --- Tests ---
|
||||
|
||||
describe('buildIntuneInstall — config path', () => {
|
||||
it('machine-wide: contains C:\\ProgramData\\rclone', () => {
|
||||
const output = buildIntuneInstall(machineWideState);
|
||||
expect(output).toContain('C:\\ProgramData\\rclone');
|
||||
});
|
||||
|
||||
it('user-profile: contains %APPDATA%\\rclone', () => {
|
||||
const output = buildIntuneInstall(userProfileState);
|
||||
expect(output).toContain('%APPDATA%\\rclone');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildIntuneInstall — rclone install download', () => {
|
||||
it('includeInstall=true: output contains rclone download URL', () => {
|
||||
const output = buildIntuneInstall(withInstallState);
|
||||
expect(output).toContain('https://downloads.rclone.org/rclone-current-windows-amd64.zip');
|
||||
});
|
||||
|
||||
it('includeInstall=false: output does NOT contain downloads.rclone.org', () => {
|
||||
const output = buildIntuneInstall(withoutInstallState);
|
||||
expect(output).not.toContain('downloads.rclone.org');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildIntuneInstall — script structure', () => {
|
||||
it('uses [System.IO.File]::WriteAllText for UTF-8 no-BOM write', () => {
|
||||
const output = buildIntuneInstall(machineWideState);
|
||||
expect(output).toContain('[System.IO.File]::WriteAllText');
|
||||
});
|
||||
|
||||
it('exits with exit 0 on success', () => {
|
||||
const output = buildIntuneInstall(machineWideState);
|
||||
expect(output).toContain('exit 0');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildIntuneInstall — credential safety', () => {
|
||||
it('does NOT interpolate credential variables inside config content (no $account inside here-string)', () => {
|
||||
const output = buildIntuneInstall(machineWideState);
|
||||
// The config content block should contain literal values, not PS variable interpolation
|
||||
// Find the WriteAllText call and verify the content arg has no $account or $key variables
|
||||
// We check that there is no $account or $key inside the config block
|
||||
expect(output).not.toMatch(/\$account\b/);
|
||||
expect(output).not.toMatch(/\$key\b/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user