Wizard: handle dos scripts in first boot
Scripts in which lines are terminated by CRLF break the first boot service, so let's make sure the line termination is correct.
This commit is contained in:
parent
ba9546193e
commit
7b365dcb4d
3 changed files with 38 additions and 2 deletions
|
|
@ -73,7 +73,10 @@ const FirstBootStep = () => {
|
|||
isCopyEnabled
|
||||
isLanguageLabelVisible
|
||||
language={language}
|
||||
onCodeChange={(code) => dispatch(setFirstBootScript(code))}
|
||||
onCodeChange={(code) => {
|
||||
// In case the user is on windows
|
||||
dispatch(setFirstBootScript(code.replace('\r\n', '\n')));
|
||||
}}
|
||||
code={selectedScript}
|
||||
height="35vh"
|
||||
emptyStateButton={<span data-testid="firstboot_browse">Browse</span>}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
|
||||
import {
|
||||
SCRIPT,
|
||||
SCRIPT_DOS,
|
||||
SCRIPT_WITHOUT_SHEBANG,
|
||||
firstBootCreateBlueprintRequest,
|
||||
firstBootData,
|
||||
|
|
@ -199,6 +200,37 @@ describe('First boot request generated correctly', () => {
|
|||
expect(receivedRequest).toEqual(expectedRequest);
|
||||
});
|
||||
});
|
||||
|
||||
test('dos2unix', async () => {
|
||||
await renderCreateMode();
|
||||
await selectGuestImageTarget();
|
||||
await goToOscapStep();
|
||||
await selectSimplifiedOscapProfile();
|
||||
await goFromOscapToFirstBoot();
|
||||
await openCodeEditor();
|
||||
await uploadFile(SCRIPT_DOS);
|
||||
await goToReviewStep();
|
||||
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
|
||||
|
||||
// request created with both OpenSCAP and first boot customization
|
||||
const expectedRequest = {
|
||||
...blueprintRequest,
|
||||
customizations: {
|
||||
filesystem: [{ min_size: 10737418240, mountpoint: '/' }],
|
||||
openscap: {
|
||||
profile_id: 'xccdf_org.ssgproject.content_profile_standard',
|
||||
},
|
||||
files: firstBootData,
|
||||
// services need to contain both serviced included in the OpenSCAP profile
|
||||
// and the first boot script
|
||||
services: { enabled: ['crond', 'emacs-service', FIRST_BOOT_SERVICE] },
|
||||
},
|
||||
};
|
||||
|
||||
await waitFor(() => {
|
||||
expect(receivedRequest).toEqual(expectedRequest);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('First Boot edit mode', () => {
|
||||
|
|
|
|||
3
src/test/fixtures/editMode.ts
vendored
3
src/test/fixtures/editMode.ts
vendored
|
|
@ -114,7 +114,8 @@ export const expectedCustomRepositories: CustomRepository[] = [
|
|||
];
|
||||
|
||||
// First Boot
|
||||
export const SCRIPT = `#!/bin/bash
|
||||
export const SCRIPT_DOS = `#!/bin/bash\r\nsystemctl enable cockpit.socket`;
|
||||
export const SCRIPT = `#!/bin/bash
|
||||
systemctl enable cockpit.socket`;
|
||||
export const BASE64_SCRIPT = btoa(SCRIPT);
|
||||
export const SCRIPT_WITHOUT_SHEBANG = `echo "Hello, world!"`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue