Skip to content

Commit f3d4cfb

Browse files
authored
Merge branch '8.16' into backport/8.16/pr-196322
2 parents 2118144 + 495308d commit f3d4cfb

32 files changed

Lines changed: 363 additions & 103 deletions

File tree

oas_docs/output/kibana.serverless.staging.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15012,7 +15012,7 @@ paths:
1501215012
nullable: true
1501315013
type: string
1501415014
- in: query
15015-
name: userFilter
15015+
name: createdByFilter
1501615016
schema:
1501715017
nullable: true
1501815018
type: string

oas_docs/output/kibana.serverless.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15012,7 +15012,7 @@ paths:
1501215012
nullable: true
1501315013
type: string
1501415014
- in: query
15015-
name: userFilter
15015+
name: createdByFilter
1501615016
schema:
1501715017
nullable: true
1501815018
type: string

oas_docs/output/kibana.staging.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18442,7 +18442,7 @@ paths:
1844218442
nullable: true
1844318443
type: string
1844418444
- in: query
18445-
name: userFilter
18445+
name: createdByFilter
1844618446
schema:
1844718447
nullable: true
1844818448
type: string

oas_docs/output/kibana.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18442,7 +18442,7 @@ paths:
1844218442
nullable: true
1844318443
type: string
1844418444
- in: query
18445-
name: userFilter
18445+
name: createdByFilter
1844618446
schema:
1844718447
nullable: true
1844818448
type: string

x-pack/packages/kbn-cloud-security-posture/public/src/constants/component_constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ import { euiThemeVars } from '@kbn/ui-theme';
99
export const statusColors = {
1010
passed: euiThemeVars.euiColorSuccess,
1111
failed: euiThemeVars.euiColorVis9,
12+
unknown: euiThemeVars.euiColorLightShade,
1213
};

x-pack/packages/security-solution/upselling/messages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export const ALERT_SUPPRESSION_RULE_DETAILS = i18n.translate(
4848
);
4949

5050
export const UPGRADE_NOTES_MANAGEMENT_USER_FILTER = (requiredLicense: string) =>
51-
i18n.translate('securitySolutionPackages.noteManagement.userFilter.upsell', {
52-
defaultMessage: 'Upgrade to {requiredLicense} to make use of user filters',
51+
i18n.translate('securitySolutionPackages.noteManagement.createdByFilter.upsell', {
52+
defaultMessage: 'Upgrade to {requiredLicense} to make use of createdBy filter',
5353
values: {
5454
requiredLicense,
5555
},
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import React from 'react';
9+
import { render, screen } from '@testing-library/react';
10+
import { ComplianceScoreBar } from './compliance_score_bar';
11+
import {
12+
COMPLIANCE_SCORE_BAR_UNKNOWN,
13+
COMPLIANCE_SCORE_BAR_PASSED,
14+
COMPLIANCE_SCORE_BAR_FAILED,
15+
} from './test_subjects';
16+
17+
describe('<ComplianceScoreBar />', () => {
18+
it('should display 0% compliance score with status unknown when both passed and failed are 0', () => {
19+
render(<ComplianceScoreBar totalPassed={0} totalFailed={0} />);
20+
expect(screen.getByText('0%')).toBeInTheDocument();
21+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_UNKNOWN)).not.toBeNull();
22+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_FAILED)).toBeNull();
23+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_PASSED)).toBeNull();
24+
});
25+
26+
it('should display 100% compliance score when passed is greater than 0 and failed is 0', () => {
27+
render(<ComplianceScoreBar totalPassed={10} totalFailed={0} />);
28+
expect(screen.getByText('100%')).toBeInTheDocument();
29+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_PASSED)).not.toBeNull();
30+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_FAILED)).toBeNull();
31+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_UNKNOWN)).toBeNull();
32+
});
33+
34+
it('should display 0% compliance score when passed is 0 and failed is greater than 0', () => {
35+
render(<ComplianceScoreBar totalPassed={0} totalFailed={10} />);
36+
expect(screen.getByText('0%')).toBeInTheDocument();
37+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_FAILED)).not.toBeNull();
38+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_PASSED)).toBeNull();
39+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_UNKNOWN)).toBeNull();
40+
});
41+
42+
it('should display 50% compliance score when passed is equal to failed', () => {
43+
render(<ComplianceScoreBar totalPassed={5} totalFailed={5} />);
44+
expect(screen.getByText('50%')).toBeInTheDocument();
45+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_FAILED)).not.toBeNull();
46+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_PASSED)).not.toBeNull();
47+
expect(screen.queryByTestId(COMPLIANCE_SCORE_BAR_UNKNOWN)).toBeNull();
48+
});
49+
});

x-pack/plugins/cloud_security_posture/public/components/compliance_score_bar.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import { i18n } from '@kbn/i18n';
1111
import React from 'react';
1212
import { statusColors } from '@kbn/cloud-security-posture';
1313
import { calculatePostureScore } from '../../common/utils/helpers';
14-
import { CSP_FINDINGS_COMPLIANCE_SCORE } from './test_subjects';
14+
import {
15+
CSP_FINDINGS_COMPLIANCE_SCORE,
16+
COMPLIANCE_SCORE_BAR_UNKNOWN,
17+
COMPLIANCE_SCORE_BAR_FAILED,
18+
COMPLIANCE_SCORE_BAR_PASSED,
19+
} from './test_subjects';
1520

1621
/**
1722
* This component will take 100% of the width set by the parent
@@ -59,12 +64,22 @@ export const ComplianceScoreBar = ({
5964
gap: 1px;
6065
`}
6166
>
67+
{!totalPassed && !totalFailed && (
68+
<EuiFlexItem
69+
css={css`
70+
flex: 1;
71+
background: ${statusColors.unknown};
72+
`}
73+
data-test-subj={COMPLIANCE_SCORE_BAR_UNKNOWN}
74+
/>
75+
)}
6276
{!!totalPassed && (
6377
<EuiFlexItem
6478
css={css`
6579
flex: ${totalPassed};
6680
background: ${statusColors.passed};
6781
`}
82+
data-test-subj={COMPLIANCE_SCORE_BAR_PASSED}
6883
/>
6984
)}
7085
{!!totalFailed && (
@@ -73,6 +88,7 @@ export const ComplianceScoreBar = ({
7388
flex: ${totalFailed};
7489
background: ${statusColors.failed};
7590
`}
91+
data-test-subj={COMPLIANCE_SCORE_BAR_FAILED}
7692
/>
7793
)}
7894
</EuiFlexGroup>

x-pack/plugins/cloud_security_posture/public/components/test_subjects.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ export const CIS_GCP_INPUT_FIELDS_TEST_SUBJECTS = {
9292
};
9393

9494
export const SUBSCRIPTION_NOT_ALLOWED_TEST_SUBJECT = 'cloud_posture_page_subscription_not_allowed';
95+
96+
export const COMPLIANCE_SCORE_BAR_UNKNOWN = 'complianceScoreBarUnknown';
97+
export const COMPLIANCE_SCORE_BAR_FAILED = 'complianceScoreBarFailed';
98+
export const COMPLIANCE_SCORE_BAR_PASSED = 'complianceScoreBarPassed';
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import React from 'react';
9+
import { render } from '@testing-library/react';
10+
import { useEuiTheme } from '@elastic/eui';
11+
import { ComplianceBarComponent } from './latest_findings_group_renderer';
12+
import { RawBucket } from '@kbn/grouping/src';
13+
import { FindingsGroupingAggregation } from './use_grouped_findings';
14+
import { ComplianceScoreBar } from '../../../components/compliance_score_bar';
15+
16+
jest.mock('@elastic/eui', () => {
17+
const actual = jest.requireActual('@elastic/eui');
18+
return {
19+
...actual,
20+
useEuiTheme: jest.fn(),
21+
};
22+
});
23+
24+
jest.mock('../../../components/compliance_score_bar', () => ({
25+
ComplianceScoreBar: jest.fn(() => null),
26+
}));
27+
28+
jest.mock('../../../components/cloud_security_grouping');
29+
30+
describe('<ComplianceBarComponent />', () => {
31+
beforeEach(() => {
32+
(useEuiTheme as jest.Mock).mockReturnValue({ euiTheme: { size: { s: 's' } } });
33+
(ComplianceScoreBar as jest.Mock).mockClear();
34+
});
35+
36+
it('renders ComplianceScoreBar with correct totalFailed and totalPassed, when total = failed+passed', () => {
37+
const bucket = {
38+
doc_count: 10,
39+
failedFindings: {
40+
doc_count: 4,
41+
},
42+
passedFindings: {
43+
doc_count: 6,
44+
},
45+
} as RawBucket<FindingsGroupingAggregation>;
46+
47+
render(<ComplianceBarComponent bucket={bucket} />);
48+
49+
expect(ComplianceScoreBar).toHaveBeenCalledWith(
50+
expect.objectContaining({
51+
totalFailed: 4,
52+
totalPassed: 6,
53+
}),
54+
{}
55+
);
56+
});
57+
58+
it('renders ComplianceScoreBar with correct totalFailed and totalPassed, when there are unknown findings', () => {
59+
const bucket = {
60+
doc_count: 10,
61+
failedFindings: {
62+
doc_count: 3,
63+
},
64+
passedFindings: {
65+
doc_count: 6,
66+
},
67+
} as RawBucket<FindingsGroupingAggregation>;
68+
69+
render(<ComplianceBarComponent bucket={bucket} />);
70+
71+
expect(ComplianceScoreBar).toHaveBeenCalledWith(
72+
expect.objectContaining({
73+
totalFailed: 3,
74+
totalPassed: 6,
75+
}),
76+
{}
77+
);
78+
});
79+
80+
it('renders ComplianceScoreBar with correct totalFailed and totalPassed, when there are no findings', () => {
81+
const bucket = {
82+
doc_count: 10,
83+
failedFindings: {
84+
doc_count: 0,
85+
},
86+
passedFindings: {
87+
doc_count: 0,
88+
},
89+
} as RawBucket<FindingsGroupingAggregation>;
90+
91+
render(<ComplianceBarComponent bucket={bucket} />);
92+
93+
expect(ComplianceScoreBar).toHaveBeenCalledWith(
94+
expect.objectContaining({
95+
totalFailed: 0,
96+
totalPassed: 0,
97+
}),
98+
{}
99+
);
100+
});
101+
});

0 commit comments

Comments
 (0)