foreman_openscap 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/graphql/mutations/oval_contents/delete.rb +9 -0
- data/app/graphql/mutations/oval_policies/delete.rb +9 -0
- data/app/graphql/mutations/oval_policies/update.rb +15 -0
- data/app/graphql/types/oval_check.rb +11 -0
- data/app/graphql/types/oval_content.rb +2 -0
- data/app/graphql/types/oval_policy.rb +3 -0
- data/app/models/concerns/foreman_openscap/host_extensions.rb +0 -6
- data/app/models/concerns/foreman_openscap/oval_facet_hostgroup_extensions.rb +15 -0
- data/app/models/foreman_openscap/oval_content.rb +2 -0
- data/app/services/foreman_openscap/oval/configure.rb +1 -1
- data/app/services/foreman_openscap/oval/setup.rb +5 -5
- data/app/services/foreman_openscap/oval/setup_check.rb +5 -2
- data/db/migrate/20210819143316_drop_unused_tables.rb +6 -0
- data/lib/foreman_openscap/engine.rb +6 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/package.json +3 -6
- data/test/graphql/mutations/oval_policies/delete_mutation_test.rb +63 -0
- data/test/graphql/queries/oval_content_query_test.rb +29 -0
- data/test/unit/services/hostgroup_overrider_test.rb +1 -1
- data/test/unit/services/oval/setup_check_test.rb +37 -0
- data/webpack/components/ConfirmModal.js +63 -0
- data/webpack/components/ConfirmModal.scss +3 -0
- data/webpack/components/EditableInput.js +157 -0
- data/webpack/components/EditableInput.scss +3 -0
- data/webpack/components/EmptyState.js +4 -1
- data/webpack/components/IndexLayout.js +11 -4
- data/webpack/components/IndexTable/index.js +17 -17
- data/webpack/components/LinkButton.js +26 -0
- data/webpack/components/withDeleteModal.js +51 -0
- data/webpack/components/withLoading.js +21 -3
- data/webpack/graphql/mutations/deleteOvalContent.gql +9 -0
- data/webpack/graphql/mutations/deleteOvalPolicy.gql +9 -0
- data/webpack/graphql/mutations/updateOvalPolicy.gql +14 -0
- data/webpack/graphql/queries/hostgroups.gql +14 -0
- data/webpack/graphql/queries/ovalContent.gql +8 -0
- data/webpack/graphql/queries/ovalContents.gql +3 -0
- data/webpack/graphql/queries/ovalPolicies.gql +3 -0
- data/webpack/helpers/formFieldsHelper.js +63 -0
- data/webpack/helpers/mutationHelper.js +68 -0
- data/webpack/helpers/pathsHelper.js +5 -0
- data/webpack/helpers/toastHelper.js +3 -0
- data/webpack/routes/OvalContents/OvalContentsIndex/OvalContentsIndex.js +25 -0
- data/webpack/routes/OvalContents/OvalContentsIndex/OvalContentsTable.js +41 -4
- data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.fixtures.js +105 -0
- data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.test.js +124 -0
- data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.fixtures.js +61 -59
- data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.test.js +29 -8
- data/webpack/routes/OvalContents/OvalContentsIndex/index.js +7 -1
- data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.js +138 -0
- data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.scss +3 -0
- data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNewHelper.js +73 -0
- data/webpack/routes/OvalContents/OvalContentsNew/__tests__/OvalContentsNew.test.js +104 -0
- data/webpack/routes/OvalContents/OvalContentsNew/index.js +13 -0
- data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.js +62 -0
- data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.test.js +45 -0
- data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShowHelper.js +0 -0
- data/webpack/routes/OvalContents/OvalContentsShow/index.js +35 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesIndex.js +17 -2
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesTable.js +16 -3
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.fixtures.js +101 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.test.js +117 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.fixtures.js +57 -41
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.test.js +14 -2
- data/webpack/routes/OvalPolicies/OvalPoliciesIndex/index.js +7 -1
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/DetailsTab.js +85 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTab.js +49 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTable.js +38 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShow.js +15 -11
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShowHelper.js +77 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.fixtures.js +48 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.test.js +175 -0
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.fixtures.js +28 -1
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.test.js +47 -4
- data/webpack/routes/OvalPolicies/OvalPoliciesShow/index.js +3 -0
- data/webpack/routes/routes.js +14 -0
- data/webpack/testHelper.js +9 -1
- metadata +46 -3
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
|
|
7
|
+
import OvalPoliciesShow from '../';
|
|
8
|
+
import {
|
|
9
|
+
historyMock,
|
|
10
|
+
ovalPolicyId,
|
|
11
|
+
policyDetailMock,
|
|
12
|
+
ovalPolicy,
|
|
13
|
+
} from './OvalPoliciesShow.fixtures';
|
|
14
|
+
import {
|
|
15
|
+
policyUpdateMock,
|
|
16
|
+
policyUpdateErrorMock,
|
|
17
|
+
policyUpdateValidationMock,
|
|
18
|
+
updatedName,
|
|
19
|
+
} from './OvalPoliciesEdit.fixtures';
|
|
20
|
+
import { ovalPoliciesShowPath } from '../../../../helpers/pathsHelper';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
withMockedProvider,
|
|
24
|
+
tick,
|
|
25
|
+
withRouter,
|
|
26
|
+
withRedux,
|
|
27
|
+
} from '../../../../testHelper';
|
|
28
|
+
|
|
29
|
+
import * as toasts from '../../../../helpers/toastHelper';
|
|
30
|
+
|
|
31
|
+
const TestComponent = withRouter(
|
|
32
|
+
withRedux(withMockedProvider(OvalPoliciesShow))
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
describe('OvalPoliciesShow', () => {
|
|
36
|
+
it('should open and close inline edit for name', async () => {
|
|
37
|
+
render(
|
|
38
|
+
<TestComponent
|
|
39
|
+
history={historyMock}
|
|
40
|
+
match={{
|
|
41
|
+
params: { id: ovalPolicyId, tab: 'details' },
|
|
42
|
+
path: ovalPoliciesShowPath,
|
|
43
|
+
}}
|
|
44
|
+
mocks={policyDetailMock}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
await waitFor(tick);
|
|
48
|
+
userEvent.click(screen.getByRole('button', { name: 'edit name' }));
|
|
49
|
+
userEvent.clear(screen.getByLabelText(/name text input/));
|
|
50
|
+
userEvent.type(screen.getByLabelText(/name text input/), 'foo');
|
|
51
|
+
expect(screen.getByLabelText(/name text input/)).toHaveAttribute(
|
|
52
|
+
'value',
|
|
53
|
+
'foo'
|
|
54
|
+
);
|
|
55
|
+
userEvent.click(
|
|
56
|
+
screen.getByRole('button', { name: 'cancel editing name' })
|
|
57
|
+
);
|
|
58
|
+
expect(screen.queryByText('foo')).not.toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
it('should update policy name', async () => {
|
|
61
|
+
const showToast = jest.fn();
|
|
62
|
+
jest.spyOn(toasts, 'showToast').mockImplementation(() => showToast);
|
|
63
|
+
|
|
64
|
+
const { container } = render(
|
|
65
|
+
<TestComponent
|
|
66
|
+
history={historyMock}
|
|
67
|
+
match={{
|
|
68
|
+
params: { id: ovalPolicyId, tab: 'details' },
|
|
69
|
+
path: ovalPoliciesShowPath,
|
|
70
|
+
}}
|
|
71
|
+
mocks={policyDetailMock.concat(policyUpdateMock)}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
await waitFor(tick);
|
|
75
|
+
const editBtn = screen.getByRole('button', { name: 'edit name' });
|
|
76
|
+
expect(editBtn).toBeInTheDocument();
|
|
77
|
+
expect(
|
|
78
|
+
screen.queryByRole('button', { name: 'submit name' })
|
|
79
|
+
).not.toBeInTheDocument();
|
|
80
|
+
|
|
81
|
+
userEvent.click(editBtn);
|
|
82
|
+
expect(
|
|
83
|
+
screen.queryByRole('button', { name: 'edit name' })
|
|
84
|
+
).not.toBeInTheDocument();
|
|
85
|
+
const inputField = screen.getByLabelText(/name text input/);
|
|
86
|
+
const submitBtn = screen.getByRole('button', { name: 'submit name' });
|
|
87
|
+
const cancelBtn = screen.getByRole('button', {
|
|
88
|
+
name: 'cancel editing name',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
userEvent.clear(inputField);
|
|
92
|
+
userEvent.type(inputField, updatedName);
|
|
93
|
+
userEvent.click(submitBtn);
|
|
94
|
+
expect(inputField).toBeDisabled();
|
|
95
|
+
expect(submitBtn).toBeDisabled();
|
|
96
|
+
expect(cancelBtn).toBeDisabled();
|
|
97
|
+
const spinner = container.querySelector('#edit-name-spinner');
|
|
98
|
+
expect(spinner).toBeInTheDocument();
|
|
99
|
+
await waitFor(tick);
|
|
100
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
101
|
+
type: 'success',
|
|
102
|
+
message: 'OVAL policy was successfully updated.',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(inputField).not.toBeInTheDocument();
|
|
106
|
+
expect(editBtn).toBeInTheDocument();
|
|
107
|
+
expect(cancelBtn).not.toBeInTheDocument();
|
|
108
|
+
expect(
|
|
109
|
+
screen.queryByRole('button', { name: 'submit name' })
|
|
110
|
+
).not.toBeInTheDocument();
|
|
111
|
+
await waitFor(tick);
|
|
112
|
+
expect(screen.getAllByText(updatedName).pop()).toBeInTheDocument();
|
|
113
|
+
});
|
|
114
|
+
it('should show unexpected errors', async () => {
|
|
115
|
+
const showToast = jest.fn();
|
|
116
|
+
jest.spyOn(toasts, 'showToast').mockImplementation(() => showToast);
|
|
117
|
+
|
|
118
|
+
render(
|
|
119
|
+
<TestComponent
|
|
120
|
+
history={historyMock}
|
|
121
|
+
match={{
|
|
122
|
+
params: { id: ovalPolicyId, tab: 'details' },
|
|
123
|
+
path: ovalPoliciesShowPath,
|
|
124
|
+
}}
|
|
125
|
+
mocks={policyDetailMock.concat(policyUpdateErrorMock)}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
await waitFor(tick);
|
|
129
|
+
const editBtn = screen.getByRole('button', { name: 'edit name' });
|
|
130
|
+
userEvent.click(editBtn);
|
|
131
|
+
const inputField = screen.getByLabelText(/name text input/);
|
|
132
|
+
userEvent.clear(inputField);
|
|
133
|
+
userEvent.type(inputField, updatedName);
|
|
134
|
+
userEvent.click(screen.getByRole('button', { name: 'submit name' }));
|
|
135
|
+
await waitFor(tick);
|
|
136
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
137
|
+
type: 'error',
|
|
138
|
+
message:
|
|
139
|
+
'There was a following error when updating OVAL policy: This is an unexpected failure.',
|
|
140
|
+
});
|
|
141
|
+
expect(inputField).toBeInTheDocument();
|
|
142
|
+
expect(inputField).not.toBeDisabled();
|
|
143
|
+
expect(screen.getByText(ovalPolicy.name)).toBeInTheDocument();
|
|
144
|
+
});
|
|
145
|
+
it('should show validation errors', async () => {
|
|
146
|
+
const showToast = jest.fn();
|
|
147
|
+
jest.spyOn(toasts, 'showToast').mockImplementation(() => showToast);
|
|
148
|
+
|
|
149
|
+
const { container } = render(
|
|
150
|
+
<TestComponent
|
|
151
|
+
history={historyMock}
|
|
152
|
+
match={{
|
|
153
|
+
params: { id: ovalPolicyId, tab: 'details' },
|
|
154
|
+
path: ovalPoliciesShowPath,
|
|
155
|
+
}}
|
|
156
|
+
mocks={policyDetailMock.concat(policyUpdateValidationMock)}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
await waitFor(tick);
|
|
160
|
+
const editBtn = screen.getByRole('button', { name: 'edit name' });
|
|
161
|
+
userEvent.click(editBtn);
|
|
162
|
+
const inputField = screen.getByLabelText(/name text input/);
|
|
163
|
+
userEvent.clear(inputField);
|
|
164
|
+
userEvent.type(inputField, updatedName);
|
|
165
|
+
userEvent.click(screen.getByRole('button', { name: 'submit name' }));
|
|
166
|
+
await waitFor(tick);
|
|
167
|
+
expect(inputField).toBeInTheDocument();
|
|
168
|
+
expect(inputField).not.toBeDisabled();
|
|
169
|
+
expect(
|
|
170
|
+
container.querySelector('#edit-name-spinner')
|
|
171
|
+
).not.toBeInTheDocument();
|
|
172
|
+
expect(screen.getByText(ovalPolicy.name)).toBeInTheDocument();
|
|
173
|
+
expect(screen.getByText('has already been taken')).toBeInTheDocument();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { mockFactory, admin, intruder } from '../../../../testHelper';
|
|
2
2
|
import ovalPolicyQuery from '../../../../graphql/queries/ovalPolicy.gql';
|
|
3
3
|
import cvesQuery from '../../../../graphql/queries/cves.gql';
|
|
4
|
+
import hostgroupsQuery from '../../../../graphql/queries/hostgroups.gql';
|
|
4
5
|
|
|
5
6
|
const policyDetailMockFactory = mockFactory('ovalPolicy', ovalPolicyQuery);
|
|
6
7
|
const cvesMockFactory = mockFactory('cves', cvesQuery);
|
|
8
|
+
const hostgroupsMockFactory = mockFactory('hostgroups', hostgroupsQuery);
|
|
7
9
|
|
|
8
|
-
const ovalPolicy = {
|
|
10
|
+
export const ovalPolicy = {
|
|
11
|
+
__typename: 'ForemanOpenscap::OvalPolicy',
|
|
9
12
|
id: 'MDE6Rm9yZW1hbk9wZW5zY2FwOjpPdmFsUG9saWN5LTM=',
|
|
10
13
|
name: 'Third policy',
|
|
11
14
|
period: 'weekly',
|
|
@@ -51,6 +54,20 @@ const cvesResult = {
|
|
|
51
54
|
],
|
|
52
55
|
};
|
|
53
56
|
|
|
57
|
+
const hostgroupsResult = {
|
|
58
|
+
totalCount: 2,
|
|
59
|
+
nodes: [
|
|
60
|
+
{
|
|
61
|
+
id: 'MDE6SG9zdGdyb3VwLTQ=',
|
|
62
|
+
name: 'first hostgroup',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'MDE6SG9zdGdyb3VwLTEy',
|
|
66
|
+
name: 'second hostgroup',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
|
|
54
71
|
export const ovalPolicyId = 3;
|
|
55
72
|
|
|
56
73
|
export const pushMock = jest.fn();
|
|
@@ -85,3 +102,13 @@ export const policyCvesMock = cvesMockFactory(
|
|
|
85
102
|
cvesResult,
|
|
86
103
|
{ currentUser: admin }
|
|
87
104
|
);
|
|
105
|
+
export const policyHostgroupsMock = hostgroupsMockFactory(
|
|
106
|
+
{ search: `oval_policy_id = ${ovalPolicyId}`, first: 5, last: 5 },
|
|
107
|
+
hostgroupsResult,
|
|
108
|
+
{ currentUser: admin }
|
|
109
|
+
);
|
|
110
|
+
export const policyHostgroupsDeniedMock = hostgroupsMockFactory(
|
|
111
|
+
{ search: `oval_policy_id = ${ovalPolicyId}`, first: 5, last: 5 },
|
|
112
|
+
{ totalCount: 0, nodes: [] },
|
|
113
|
+
{ currentUser: intruder }
|
|
114
|
+
);
|
|
@@ -12,18 +12,27 @@ import {
|
|
|
12
12
|
resolvePath,
|
|
13
13
|
} from '../../../../helpers/pathsHelper';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
withRedux,
|
|
17
|
+
withMockedProvider,
|
|
18
|
+
tick,
|
|
19
|
+
withRouter,
|
|
20
|
+
} from '../../../../testHelper';
|
|
16
21
|
import {
|
|
17
22
|
policyDetailMock,
|
|
18
23
|
historyMock,
|
|
19
24
|
historyWithSearch,
|
|
20
25
|
pushMock,
|
|
21
26
|
policyCvesMock,
|
|
27
|
+
policyHostgroupsMock,
|
|
28
|
+
policyHostgroupsDeniedMock,
|
|
22
29
|
ovalPolicyId,
|
|
23
30
|
policyUnauthorizedMock,
|
|
24
31
|
} from './OvalPoliciesShow.fixtures';
|
|
25
32
|
|
|
26
|
-
const TestComponent =
|
|
33
|
+
const TestComponent = withRedux(
|
|
34
|
+
withRouter(withMockedProvider(OvalPoliciesShow))
|
|
35
|
+
);
|
|
27
36
|
|
|
28
37
|
describe('OvalPoliciesShow', () => {
|
|
29
38
|
it('should load details by default and handle tab change', async () => {
|
|
@@ -37,7 +46,7 @@ describe('OvalPoliciesShow', () => {
|
|
|
37
46
|
expect(screen.getByText('Loading')).toBeInTheDocument();
|
|
38
47
|
await waitFor(tick);
|
|
39
48
|
expect(screen.queryByText('Loading')).not.toBeInTheDocument();
|
|
40
|
-
expect(screen.
|
|
49
|
+
expect(screen.getAllByText('Third policy').pop()).toBeInTheDocument();
|
|
41
50
|
expect(screen.getByText('Weekly, on tuesday')).toBeInTheDocument();
|
|
42
51
|
expect(screen.getByText('A very strict policy')).toBeInTheDocument();
|
|
43
52
|
const activeTabHeader = container.querySelector(
|
|
@@ -105,7 +114,7 @@ describe('OvalPoliciesShow', () => {
|
|
|
105
114
|
it('should have button for scanning all hostgroups', async () => {
|
|
106
115
|
const btnText = 'Scan All Hostgroups';
|
|
107
116
|
|
|
108
|
-
const WithProvider = withMockedProvider(OvalPoliciesShow);
|
|
117
|
+
const WithProvider = withRedux(withMockedProvider(OvalPoliciesShow));
|
|
109
118
|
const history = createMemoryHistory();
|
|
110
119
|
history.push = jest.fn();
|
|
111
120
|
|
|
@@ -126,4 +135,38 @@ describe('OvalPoliciesShow', () => {
|
|
|
126
135
|
'/job_invocations/new?feature=foreman_openscap_run_oval_scans&host_ids=hostgroup_id+%5E+%284+10+12+11%29&inputs%5Boval_policies%5D=3'
|
|
127
136
|
);
|
|
128
137
|
});
|
|
138
|
+
it('should load hostgroups tab when specified in URL', async () => {
|
|
139
|
+
const mocks = policyDetailMock.concat(policyHostgroupsMock);
|
|
140
|
+
render(
|
|
141
|
+
<TestComponent
|
|
142
|
+
history={historyWithSearch}
|
|
143
|
+
match={{
|
|
144
|
+
params: { id: ovalPolicyId, tab: 'hostgroups' },
|
|
145
|
+
path: ovalPoliciesShowPath,
|
|
146
|
+
}}
|
|
147
|
+
mocks={mocks}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
expect(screen.getByText('Loading')).toBeInTheDocument();
|
|
151
|
+
await waitFor(tick);
|
|
152
|
+
await waitFor(tick);
|
|
153
|
+
expect(screen.queryByText('Loading')).not.toBeInTheDocument();
|
|
154
|
+
expect(screen.getByText('first hostgroup')).toBeInTheDocument();
|
|
155
|
+
});
|
|
156
|
+
it('should not show hostgroups for a user without permissions', async () => {
|
|
157
|
+
const mocks = policyDetailMock.concat(policyHostgroupsDeniedMock);
|
|
158
|
+
render(
|
|
159
|
+
<TestComponent
|
|
160
|
+
history={historyWithSearch}
|
|
161
|
+
match={{
|
|
162
|
+
params: { id: ovalPolicyId, tab: 'hostgroups' },
|
|
163
|
+
path: ovalPoliciesShowPath,
|
|
164
|
+
}}
|
|
165
|
+
mocks={mocks}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
await waitFor(tick);
|
|
169
|
+
await waitFor(tick);
|
|
170
|
+
expect(screen.getByText('Permission denied')).toBeInTheDocument();
|
|
171
|
+
});
|
|
129
172
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useQuery } from '@apollo/client';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
4
5
|
|
|
5
6
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
7
|
+
import { showToast } from '../../../helpers/toastHelper';
|
|
6
8
|
|
|
7
9
|
import OvalPoliciesShow from './OvalPoliciesShow';
|
|
8
10
|
import { encodeId } from '../../../helpers/globalIdHelper';
|
|
@@ -25,6 +27,7 @@ const WrappedOvalPoliciesShow = props => {
|
|
|
25
27
|
resultPath="ovalPolicy"
|
|
26
28
|
emptyStateTitle={__('No OVAL Policy found')}
|
|
27
29
|
permissions={['view_oval_policies']}
|
|
30
|
+
showToast={showToast(useDispatch())}
|
|
28
31
|
/>
|
|
29
32
|
);
|
|
30
33
|
};
|
data/webpack/routes/routes.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import OvalContentsIndex from './OvalContents/OvalContentsIndex';
|
|
3
|
+
import OvalContentsShow from './OvalContents/OvalContentsShow';
|
|
4
|
+
import OvalContentsNew from './OvalContents/OvalContentsNew';
|
|
3
5
|
import OvalPoliciesIndex from './OvalPolicies/OvalPoliciesIndex';
|
|
4
6
|
import OvalPoliciesShow from './OvalPolicies/OvalPoliciesShow';
|
|
5
7
|
|
|
6
8
|
import {
|
|
7
9
|
ovalContentsPath,
|
|
10
|
+
ovalContentsShowPath,
|
|
11
|
+
ovalContentsNewPath,
|
|
8
12
|
ovalPoliciesPath,
|
|
9
13
|
ovalPoliciesShowPath,
|
|
10
14
|
} from '../helpers/pathsHelper';
|
|
@@ -15,6 +19,16 @@ export default [
|
|
|
15
19
|
render: props => <OvalContentsIndex {...props} />,
|
|
16
20
|
exact: true,
|
|
17
21
|
},
|
|
22
|
+
{
|
|
23
|
+
path: ovalContentsNewPath,
|
|
24
|
+
render: props => <OvalContentsNew {...props} />,
|
|
25
|
+
exact: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: ovalContentsShowPath,
|
|
29
|
+
render: props => <OvalContentsShow {...props} />,
|
|
30
|
+
exact: true,
|
|
31
|
+
},
|
|
18
32
|
{
|
|
19
33
|
path: ovalPoliciesPath,
|
|
20
34
|
render: props => <OvalPoliciesIndex {...props} />,
|
data/webpack/testHelper.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
import store from 'foremanReact/redux';
|
|
2
4
|
import { MockedProvider } from '@apollo/react-testing';
|
|
3
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
4
6
|
import { getForemanContext } from 'foremanReact/Root/Context/ForemanContext';
|
|
5
7
|
|
|
8
|
+
export const withRedux = Component => props => (
|
|
9
|
+
<Provider store={store}>
|
|
10
|
+
<Component {...props} />
|
|
11
|
+
</Provider>
|
|
12
|
+
);
|
|
13
|
+
|
|
6
14
|
export const withRouter = Component => props => (
|
|
7
15
|
<MemoryRouter>
|
|
8
16
|
<Component {...props} />
|
|
@@ -71,7 +79,7 @@ export const intruder = userFactory('intruder', [
|
|
|
71
79
|
export const mockFactory = (resultName, query) => (
|
|
72
80
|
variables,
|
|
73
81
|
modelResults,
|
|
74
|
-
{ errors = [], currentUser = null }
|
|
82
|
+
{ errors = [], currentUser = null } = {}
|
|
75
83
|
) => {
|
|
76
84
|
const mock = {
|
|
77
85
|
request: {
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_openscap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- slukasik@redhat.com
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -72,7 +72,11 @@ files:
|
|
|
72
72
|
- app/controllers/policy_dashboard_controller.rb
|
|
73
73
|
- app/controllers/scap_contents_controller.rb
|
|
74
74
|
- app/controllers/tailoring_files_controller.rb
|
|
75
|
+
- app/graphql/mutations/oval_contents/delete.rb
|
|
76
|
+
- app/graphql/mutations/oval_policies/delete.rb
|
|
77
|
+
- app/graphql/mutations/oval_policies/update.rb
|
|
75
78
|
- app/graphql/types/cve.rb
|
|
79
|
+
- app/graphql/types/oval_check.rb
|
|
76
80
|
- app/graphql/types/oval_content.rb
|
|
77
81
|
- app/graphql/types/oval_policy.rb
|
|
78
82
|
- app/helpers/arf_report_dashboard_helper.rb
|
|
@@ -301,6 +305,7 @@ files:
|
|
|
301
305
|
- db/migrate/20201217130800_add_has_errata_to_cve.rb
|
|
302
306
|
- db/migrate/20201217161511_add_url_to_oval_content.rb
|
|
303
307
|
- db/migrate/20210409095625_add_oval_policy_reference_to_cve.rb
|
|
308
|
+
- db/migrate/20210819143316_drop_unused_tables.rb
|
|
304
309
|
- db/seeds.d/75-job_templates.rb
|
|
305
310
|
- db/seeds.d/openscap_feature.rb
|
|
306
311
|
- db/seeds.d/openscap_policy_notification.rb
|
|
@@ -387,6 +392,8 @@ files:
|
|
|
387
392
|
- test/functional/arf_reports_controller_test.rb
|
|
388
393
|
- test/functional/openscap_proxies_controller_test.rb
|
|
389
394
|
- test/functional/tailoring_files_controller_test.rb
|
|
395
|
+
- test/graphql/mutations/oval_policies/delete_mutation_test.rb
|
|
396
|
+
- test/graphql/queries/oval_content_query_test.rb
|
|
390
397
|
- test/graphql/queries/oval_contents_query_test.rb
|
|
391
398
|
- test/graphql/queries/oval_policies_query_test.rb
|
|
392
399
|
- test/helpers/arf_report_dashboard_helper_test.rb
|
|
@@ -410,15 +417,21 @@ files:
|
|
|
410
417
|
- test/unit/services/hostgroup_overrider_test.rb
|
|
411
418
|
- test/unit/services/lookup_key_overrider_test.rb
|
|
412
419
|
- test/unit/services/oval/cves_test.rb
|
|
420
|
+
- test/unit/services/oval/setup_check_test.rb
|
|
413
421
|
- test/unit/services/oval/setup_test.rb
|
|
414
422
|
- test/unit/services/report_dashboard/data_test.rb
|
|
415
423
|
- test/unit/services/tailoring_files_proxy_check_test.rb
|
|
416
424
|
- test/unit/tailoring_file_test.rb
|
|
425
|
+
- webpack/components/ConfirmModal.js
|
|
426
|
+
- webpack/components/ConfirmModal.scss
|
|
427
|
+
- webpack/components/EditableInput.js
|
|
428
|
+
- webpack/components/EditableInput.scss
|
|
417
429
|
- webpack/components/EmptyState.js
|
|
418
430
|
- webpack/components/IndexLayout.js
|
|
419
431
|
- webpack/components/IndexLayout.scss
|
|
420
432
|
- webpack/components/IndexTable/IndexTableHelper.js
|
|
421
433
|
- webpack/components/IndexTable/index.js
|
|
434
|
+
- webpack/components/LinkButton.js
|
|
422
435
|
- webpack/components/RuleSeverity/RuleSeverity.scss
|
|
423
436
|
- webpack/components/RuleSeverity/RuleSeverity.test.js
|
|
424
437
|
- webpack/components/RuleSeverity/__snapshots__/RuleSeverity.test.js.snap
|
|
@@ -428,34 +441,61 @@ files:
|
|
|
428
441
|
- webpack/components/RuleSeverity/i_severity-med.svg
|
|
429
442
|
- webpack/components/RuleSeverity/i_unknown.svg
|
|
430
443
|
- webpack/components/RuleSeverity/index.js
|
|
444
|
+
- webpack/components/withDeleteModal.js
|
|
431
445
|
- webpack/components/withLoading.js
|
|
432
446
|
- webpack/global_index.js
|
|
447
|
+
- webpack/graphql/mutations/deleteOvalContent.gql
|
|
448
|
+
- webpack/graphql/mutations/deleteOvalPolicy.gql
|
|
449
|
+
- webpack/graphql/mutations/updateOvalPolicy.gql
|
|
433
450
|
- webpack/graphql/queries/currentUserAttributes.gql
|
|
434
451
|
- webpack/graphql/queries/cves.gql
|
|
452
|
+
- webpack/graphql/queries/hostgroups.gql
|
|
453
|
+
- webpack/graphql/queries/ovalContent.gql
|
|
435
454
|
- webpack/graphql/queries/ovalContents.gql
|
|
436
455
|
- webpack/graphql/queries/ovalPolicies.gql
|
|
437
456
|
- webpack/graphql/queries/ovalPolicy.gql
|
|
438
457
|
- webpack/helpers/commonHelper.js
|
|
458
|
+
- webpack/helpers/formFieldsHelper.js
|
|
439
459
|
- webpack/helpers/globalIdHelper.js
|
|
460
|
+
- webpack/helpers/mutationHelper.js
|
|
440
461
|
- webpack/helpers/pageParamsHelper.js
|
|
441
462
|
- webpack/helpers/pathsHelper.js
|
|
442
463
|
- webpack/helpers/permissionsHelper.js
|
|
443
464
|
- webpack/helpers/tableHelper.js
|
|
465
|
+
- webpack/helpers/toastHelper.js
|
|
444
466
|
- webpack/index.js
|
|
445
467
|
- webpack/routes/OvalContents/OvalContentsIndex/OvalContentsIndex.js
|
|
446
468
|
- webpack/routes/OvalContents/OvalContentsIndex/OvalContentsTable.js
|
|
469
|
+
- webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.fixtures.js
|
|
470
|
+
- webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.test.js
|
|
447
471
|
- webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.fixtures.js
|
|
448
472
|
- webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.test.js
|
|
449
473
|
- webpack/routes/OvalContents/OvalContentsIndex/index.js
|
|
474
|
+
- webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.js
|
|
475
|
+
- webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.scss
|
|
476
|
+
- webpack/routes/OvalContents/OvalContentsNew/OvalContentsNewHelper.js
|
|
477
|
+
- webpack/routes/OvalContents/OvalContentsNew/__tests__/OvalContentsNew.test.js
|
|
478
|
+
- webpack/routes/OvalContents/OvalContentsNew/index.js
|
|
479
|
+
- webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.js
|
|
480
|
+
- webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.test.js
|
|
481
|
+
- webpack/routes/OvalContents/OvalContentsShow/OvalContentsShowHelper.js
|
|
482
|
+
- webpack/routes/OvalContents/OvalContentsShow/index.js
|
|
450
483
|
- webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesIndex.js
|
|
451
484
|
- webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesTable.js
|
|
485
|
+
- webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.fixtures.js
|
|
486
|
+
- webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.test.js
|
|
452
487
|
- webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.fixtures.js
|
|
453
488
|
- webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.test.js
|
|
454
489
|
- webpack/routes/OvalPolicies/OvalPoliciesIndex/index.js
|
|
455
490
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/CvesTab.js
|
|
456
491
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/CvesTable.js
|
|
492
|
+
- webpack/routes/OvalPolicies/OvalPoliciesShow/DetailsTab.js
|
|
493
|
+
- webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTab.js
|
|
494
|
+
- webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTable.js
|
|
457
495
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShow.js
|
|
458
496
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShowHelper.js
|
|
497
|
+
- webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.fixtures.js
|
|
498
|
+
- webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.test.js
|
|
459
499
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.fixtures.js
|
|
460
500
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.test.js
|
|
461
501
|
- webpack/routes/OvalPolicies/OvalPoliciesShow/index.js
|
|
@@ -531,9 +571,10 @@ test_files:
|
|
|
531
571
|
- test/unit/services/tailoring_files_proxy_check_test.rb
|
|
532
572
|
- test/unit/services/oval/cves_test.rb
|
|
533
573
|
- test/unit/services/oval/setup_test.rb
|
|
574
|
+
- test/unit/services/oval/setup_check_test.rb
|
|
534
575
|
- test/unit/services/config_name_service_test.rb
|
|
535
|
-
- test/unit/services/hostgroup_overrider_test.rb
|
|
536
576
|
- test/unit/services/lookup_key_overrider_test.rb
|
|
577
|
+
- test/unit/services/hostgroup_overrider_test.rb
|
|
537
578
|
- test/unit/tailoring_file_test.rb
|
|
538
579
|
- test/unit/oval_host_test.rb
|
|
539
580
|
- test/unit/oval_policy_test.rb
|
|
@@ -542,4 +583,6 @@ test_files:
|
|
|
542
583
|
- test/fixtures/cve_fixtures.rb
|
|
543
584
|
- test/graphql/queries/oval_contents_query_test.rb
|
|
544
585
|
- test/graphql/queries/oval_policies_query_test.rb
|
|
586
|
+
- test/graphql/queries/oval_content_query_test.rb
|
|
587
|
+
- test/graphql/mutations/oval_policies/delete_mutation_test.rb
|
|
545
588
|
- test/test_plugin_helper.rb
|