mocks: add oscap fixtures and handlers
In order to test the oscap customization profiles, let's declare new msw data that can be used in unit testing. HMS-2077
This commit is contained in:
parent
273aa52711
commit
1587ead4d9
2 changed files with 43 additions and 0 deletions
27
src/test/fixtures/oscap.ts
vendored
Normal file
27
src/test/fixtures/oscap.ts
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import {
|
||||
GetOscapProfilesApiResponse,
|
||||
GetOscapCustomizationsApiResponse,
|
||||
} from '../../store/imageBuilderApi';
|
||||
|
||||
export const distributionOscapProfiles = (
|
||||
_distribution: string
|
||||
): GetOscapProfilesApiResponse => {
|
||||
return ['xccdf_org.ssgproject.content_profile_cis_workstation_l1'];
|
||||
};
|
||||
|
||||
export const oscapCustomizations = (
|
||||
_distribution: string,
|
||||
_profile: string
|
||||
): GetOscapCustomizationsApiResponse => {
|
||||
return {
|
||||
filesystem: [{ min_size: 1073741824, mountpoint: '/tmp' }],
|
||||
packages: [
|
||||
'aide',
|
||||
'sudo',
|
||||
'rsyslog',
|
||||
'firewalld',
|
||||
'nftables',
|
||||
'libselinux',
|
||||
],
|
||||
};
|
||||
};
|
||||
|
|
@ -18,6 +18,10 @@ import {
|
|||
mockComposes,
|
||||
mockStatus,
|
||||
} from '../fixtures/composes';
|
||||
import {
|
||||
distributionOscapProfiles,
|
||||
oscapCustomizations,
|
||||
} from '../fixtures/oscap';
|
||||
import {
|
||||
mockPackagesResults,
|
||||
mockSourcesPackagesResults,
|
||||
|
|
@ -91,4 +95,16 @@ export const handlers = [
|
|||
rest.post(`${IMAGE_BUILDER_API}/compose`, (req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json({}));
|
||||
}),
|
||||
rest.get(
|
||||
`${IMAGE_BUILDER_API}/oscap/:distribution/profiles`,
|
||||
(req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json(distributionOscapProfiles(req)));
|
||||
}
|
||||
),
|
||||
rest.get(
|
||||
`${IMAGE_BUILDER_API}/oscap/:distribution/:profile/customizations`,
|
||||
(req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json(oscapCustomizations(req)));
|
||||
}
|
||||
),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue