Skip to content

Commit

Permalink
follow constants naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliidm authored and WafaaNasr committed Feb 5, 2024
1 parent 0226547 commit 6afef7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ export const DEFAULT_SUPPRESSION_MISSING_FIELDS_STRATEGY = 'suppress' as const;

export const MINIMUM_LICENSE_FOR_SUPPRESSION = 'platinum' as const;

export const SuppressibleAlertRules: Type[] = ['threshold', 'saved_query', 'query', 'threat_match'];
export const SUPPRESSIBLE_ALERT_RULES: Type[] = [
'threshold',
'saved_query',
'query',
'threat_match',
];
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { Type } from '@kbn/securitysolution-io-ts-alerting-types';
import { hasLargeValueList } from '@kbn/securitysolution-list-utils';

import type { EntriesArray } from '@kbn/securitysolution-io-ts-list-types';
import { SuppressibleAlertRules } from './constants';
import { SUPPRESSIBLE_ALERT_RULES } from './constants';

describe('#hasLargeValueList', () => {
test('it returns false if empty array', () => {
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('normalizeMachineLearningJobIds', () => {
describe('Alert Suppression Rules', () => {
describe('isSuppressibleAlertRule', () => {
test('should return true for a suppressible rule type', () => {
const suppressibleRules: Type[] = Object.values(SuppressibleAlertRules);
const suppressibleRules: Type[] = Object.values(SUPPRESSIBLE_ALERT_RULES);
suppressibleRules.forEach((rule) => {
const result = isSuppressibleAlertRule(rule);
expect(result).toBe(true);
Expand All @@ -242,7 +242,7 @@ describe('Alert Suppression Rules', () => {

describe('isSuppressionRuleConfiguredWithDuration', () => {
test('should return true for a suppressible rule type', () => {
const suppressibleRules: Type[] = Object.values(SuppressibleAlertRules);
const suppressibleRules: Type[] = Object.values(SUPPRESSIBLE_ALERT_RULES);
suppressibleRules.forEach((rule) => {
const result = isSuppressionRuleConfiguredWithDuration(rule);
expect(result).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { Type } from '@kbn/securitysolution-io-ts-alerting-types';
import { hasLargeValueList } from '@kbn/securitysolution-list-utils';

import type { Threshold, ThresholdNormalized } from '../api/detection_engine/model/rule_schema';
import { SuppressibleAlertRules } from './constants';
import { SUPPRESSIBLE_ALERT_RULES } from './constants';

export const hasLargeValueItem = (
exceptionItems: Array<ExceptionListItemSchema | CreateExceptionListItemSchema>
Expand Down Expand Up @@ -71,7 +71,7 @@ export const normalizeMachineLearningJobIds = (value: string | string[]): string
Array.isArray(value) ? value : [value];

export const isSuppressibleAlertRule = (ruleType: Type): boolean => {
return SuppressibleAlertRules.includes(ruleType);
return SUPPRESSIBLE_ALERT_RULES.includes(ruleType);
};
export const isSuppressionRuleConfiguredWithDuration = (ruleType: Type) =>
isSuppressibleAlertRule(ruleType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as useIsExperimentalFeatureEnabledMock from '../../../common/hooks/use_
import { useAlertSuppression } from './use_alert_suppression';

describe('useAlertSuppression', () => {
it('should return the correct isSuppressionEnabled value if rule Type exists in SuppressibleAlertRules and Feature Flag is enabled', () => {
it('should return the correct isSuppressionEnabled value if rule Type exists in SUPPRESSIBLE_ALERT_RULES and Feature Flag is enabled', () => {
jest
.spyOn(useIsExperimentalFeatureEnabledMock, 'useIsExperimentalFeatureEnabled')
.mockImplementation((featureFlagName: string) => {
Expand All @@ -20,7 +20,7 @@ describe('useAlertSuppression', () => {

expect(result.current.isSuppressionEnabled).toBe(true);
});
it('should return the correct isSuppressionEnabled value if rule Type exists in SuppressibleAlertRules and Feature Flag is disabled', () => {
it('should return the correct isSuppressionEnabled value if rule Type exists in SUPPRESSIBLE_ALERT_RULES and Feature Flag is disabled', () => {
jest
.spyOn(useIsExperimentalFeatureEnabledMock, 'useIsExperimentalFeatureEnabled')
.mockImplementation((featureFlagName: string) => {
Expand All @@ -31,7 +31,7 @@ describe('useAlertSuppression', () => {
expect(result.current.isSuppressionEnabled).toBe(false);
});

it('should return the correct isSuppressionEnabled value if rule Type exists in SuppressibleAlertRules', () => {
it('should return the correct isSuppressionEnabled value if rule Type exists in SUPPRESSIBLE_ALERT_RULES', () => {
const { result } = renderHook(() => useAlertSuppression('query'));

expect(result.current.isSuppressionEnabled).toBe(true);
Expand Down

0 comments on commit 6afef7e

Please sign in to comment.