test: add mocks and fixtures for compliance
This commit is contained in:
parent
70635c8445
commit
5d2525b7eb
5 changed files with 91 additions and 1 deletions
|
|
@ -271,7 +271,7 @@ describe('Blueprints', () => {
|
|||
user.click(button);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByRole('checkbox')).toHaveLength(8);
|
||||
expect(screen.getAllByRole('checkbox')).toHaveLength(9);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
10
src/test/fixtures/blueprints.ts
vendored
10
src/test/fixtures/blueprints.ts
vendored
|
|
@ -35,6 +35,7 @@ export const mockBlueprintIds = {
|
|||
packages: 'b3437c4e-f6f8-4270-8d32-323ac60bc929',
|
||||
firstBoot: 'd0a8376e-e44e-47b3-845d-30f5199a35b6',
|
||||
details: '58991b91-4b98-47e0-b26d-8d908678ddb3',
|
||||
compliance: '21571945-fe23-45e9-8afb-4aa073b8d735',
|
||||
};
|
||||
|
||||
export const mockBlueprintNames = {
|
||||
|
|
@ -55,6 +56,7 @@ export const mockBlueprintNames = {
|
|||
packages: 'packages',
|
||||
firstBoot: 'firstBoot',
|
||||
details: 'details',
|
||||
compliance: 'compliance',
|
||||
};
|
||||
|
||||
export const mockBlueprintDescriptions = {
|
||||
|
|
@ -75,6 +77,7 @@ export const mockBlueprintDescriptions = {
|
|||
packages: '',
|
||||
firstBoot: '',
|
||||
details: 'This is a test description for the Details step.',
|
||||
compliance: '',
|
||||
};
|
||||
|
||||
export const mockGetBlueprints: GetBlueprintsApiResponse = {
|
||||
|
|
@ -277,6 +280,13 @@ export const mockGetBlueprints: GetBlueprintsApiResponse = {
|
|||
version: 1,
|
||||
last_modified_at: '2021-09-08T21:00:00.000Z',
|
||||
},
|
||||
{
|
||||
id: mockBlueprintIds['compliance'],
|
||||
name: mockBlueprintNames['compliance'],
|
||||
description: mockBlueprintDescriptions['compliance'],
|
||||
version: 1,
|
||||
last_modified_at: '2021-09-08T21:00:00.000Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
|||
43
src/test/fixtures/compliance.ts
vendored
Normal file
43
src/test/fixtures/compliance.ts
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
export const mockPolicies = {
|
||||
data: [
|
||||
{
|
||||
id: '393bca7e-5d2b-4646-a86c-373fc5c50d8b',
|
||||
title: 'CIS workstation l1',
|
||||
description: 'Fancy description',
|
||||
business_objective: null,
|
||||
compliance_threshold: 100,
|
||||
total_system_count: 0,
|
||||
type: 'policy',
|
||||
os_major_version: 8,
|
||||
profile_title:
|
||||
'CIS Red Hat Enterprise Linux 8 Benchmark for Level 1 - Workstation',
|
||||
ref_id: 'xccdf_org.ssgproject.content_profile_cis_workstation_l1',
|
||||
},
|
||||
{
|
||||
id: '0ee9a781-b53f-4d9e-91e1-d75aed088c44',
|
||||
title: 'CIS workstation l2',
|
||||
description: 'Fancy description',
|
||||
compliance_threshold: 100,
|
||||
total_system_count: 100,
|
||||
type: 'policy',
|
||||
os_major_version: 8,
|
||||
profile_title:
|
||||
'CIS Red Hat Enterprise Linux 8 Benchmark for Level 2 - Workstation',
|
||||
ref_id: 'xccdf_org.ssgproject.content_profile_cis_workstation_l2',
|
||||
},
|
||||
{
|
||||
id: '88359aa5-ba7e-44d9-9048-02c7918ff58c',
|
||||
title: 'STIG GUI',
|
||||
description: 'Fancy description',
|
||||
compliance_threshold: 100,
|
||||
total_system_count: 30,
|
||||
type: 'policy',
|
||||
os_major_version: 8,
|
||||
profile_title: 'DISA STIG with GUI for Red Hat Enterprise Linux 8',
|
||||
ref_id: 'xccdf_org.ssgproject.content_profile_stig_gui',
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
total: 3,
|
||||
},
|
||||
};
|
||||
23
src/test/fixtures/editMode.ts
vendored
23
src/test/fixtures/editMode.ts
vendored
|
|
@ -447,6 +447,27 @@ export const detailsBlueprintResponse: BlueprintResponse = {
|
|||
description: mockBlueprintDescriptions['details'],
|
||||
};
|
||||
|
||||
export const complianceCreateBlueprintRequest: CreateBlueprintRequest = {
|
||||
...baseCreateBlueprintRequest,
|
||||
name: mockBlueprintNames['compliance'],
|
||||
description: mockBlueprintDescriptions['compliance'],
|
||||
customizations: {
|
||||
packages: expectedPackagesCisL2,
|
||||
openscap: {
|
||||
policy_id: '0ee9a781-b53f-4d9e-91e1-d75aed088c44',
|
||||
},
|
||||
services: expectedServicesCisL2,
|
||||
kernel: expectedKernelCisL2,
|
||||
filesystem: expectedFilesystemCisL2,
|
||||
},
|
||||
};
|
||||
|
||||
export const complianceBlueprintResponse: BlueprintResponse = {
|
||||
...complianceCreateBlueprintRequest,
|
||||
id: mockBlueprintIds['compliance'],
|
||||
description: mockBlueprintDescriptions['compliance'],
|
||||
};
|
||||
|
||||
export const getMockBlueprintResponse = (id: string) => {
|
||||
switch (id) {
|
||||
case mockBlueprintIds['darkChocolate']:
|
||||
|
|
@ -485,6 +506,8 @@ export const getMockBlueprintResponse = (id: string) => {
|
|||
return firstBootBlueprintResponse;
|
||||
case mockBlueprintIds['details']:
|
||||
return detailsBlueprintResponse;
|
||||
case mockBlueprintIds['compliance']:
|
||||
return complianceBlueprintResponse;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
import {
|
||||
COMPLIANCE_API,
|
||||
CONTENT_SOURCES_API,
|
||||
CREATE_BLUEPRINT,
|
||||
IMAGE_BUILDER_API,
|
||||
|
|
@ -19,6 +20,7 @@ import {
|
|||
mockEmptyBlueprintsComposes,
|
||||
mockGetBlueprints,
|
||||
} from '../fixtures/blueprints';
|
||||
import { mockPolicies } from '../fixtures/compliance';
|
||||
import {
|
||||
composesEndpoint,
|
||||
mockClones,
|
||||
|
|
@ -212,4 +214,16 @@ export const handlers = [
|
|||
http.post(`${IMAGE_BUILDER_API}/experimental/recommendations`, () => {
|
||||
return HttpResponse.json(mockPkgRecommendations);
|
||||
}),
|
||||
http.get(`${COMPLIANCE_API}/policies`, () => {
|
||||
return HttpResponse.json(mockPolicies);
|
||||
}),
|
||||
http.get(`${COMPLIANCE_API}/policies/:id`, ({ params }) => {
|
||||
const id = params['id'];
|
||||
for (const p of mockPolicies.data) {
|
||||
if (p.id === id) {
|
||||
return HttpResponse.json({ data: p });
|
||||
}
|
||||
}
|
||||
return HttpResponse.error();
|
||||
}),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue