test: Add a test for combination of OpenSCAP and first boot

This adds a test to check that blueprint request includes enabled services from both OpenSCAP profile and first boot script.
This commit is contained in:
regexowl 2024-09-30 11:59:52 +02:00 committed by Klara Simickova
parent ec96df5527
commit 7692445572
4 changed files with 80 additions and 13 deletions

View file

@ -15,6 +15,7 @@ import {
import {
clickNext,
clickReviewAndFinish,
goToOscapStep,
//getNextButton,
} from '../../wizardTestUtils';
import {
@ -44,6 +45,25 @@ const goToFirstBootStep = async (): Promise<void> => {
await clickNext(); // First Boot
};
const selectSimplifiedOscapProfile = async () => {
const user = userEvent.setup();
const selectProfileDropdown = await screen.findByRole('textbox', {
name: /select a profile/i,
});
await waitFor(() => user.click(selectProfileDropdown));
const simplifiedProfile = await screen.findByText(/Simplified profile/i);
await waitFor(() => user.click(simplifiedProfile));
};
const goFromOscapToFirstBoot = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};
const openCodeEditor = async (): Promise<void> => {
const user = userEvent.setup();
const startBtn = await screen.findByRole('button', {
@ -147,6 +167,36 @@ describe('First boot request generated correctly', () => {
expect(receivedRequest).toEqual(expectedRequest);
});
});
test('with an OpenSCAP profile', async () => {
await renderCreateMode();
await goToOscapStep();
await selectSimplifiedOscapProfile();
await goFromOscapToFirstBoot();
await openCodeEditor();
await uploadFile();
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', () => {

View file

@ -13,9 +13,12 @@ import {
expectedServicesCisL2,
oscapCreateBlueprintRequest,
} from '../../../../fixtures/editMode';
import { clickNext, clickReviewAndFinish } from '../../wizardTestUtils';
import {
clickRegisterLater,
clickNext,
clickReviewAndFinish,
goToOscapStep,
} from '../../wizardTestUtils';
import {
enterBlueprintName,
interceptBlueprintRequest,
interceptEditBlueprintRequest,
@ -24,17 +27,6 @@ import {
renderEditMode,
} from '../../wizardTestUtils';
const goToOscapStep = async () => {
const user = userEvent.setup();
const guestImageCheckBox = await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
});
await waitFor(() => user.click(guestImageCheckBox));
await clickNext(); // Registration
await clickRegisterLater();
await clickNext(); // OpenSCAP
};
const selectProfile = async () => {
const user = userEvent.setup();
const selectProfileDropdown = await screen.findByRole('textbox', {

View file

@ -107,6 +107,17 @@ export const clickRegisterLater = async () => {
await waitFor(() => user.click(registrationCheckbox));
};
export const goToOscapStep = async () => {
const user = userEvent.setup();
const guestImageCheckBox = await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
});
await waitFor(() => user.click(guestImageCheckBox));
await clickNext(); // Registration
await clickRegisterLater();
await clickNext(); // OpenSCAP
};
export const selectCustomRepo = async () => {
const user = userEvent.setup();
await clickBack();