Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Oct 10, 2024
1 parent b2ed78a commit 454006f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const getPrebuiltRuleMock = (rewrites?: Partial<PrebuiltRuleAsset>): Preb
language: 'kuery',
rule_id: 'rule-1',
version: 1,
author: [],
...rewrites,
} as PrebuiltRuleAsset);

Expand Down Expand Up @@ -51,6 +52,7 @@ export const getPrebuiltThreatMatchRuleMock = (): PrebuiltRuleAsset => ({
language: 'kuery',
rule_id: 'rule-1',
version: 1,
author: [],
threat_query: '*:*',
threat_index: ['list-index'],
threat_mapping: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
getRuleSavedObjectWithLegacyInvestigationFields,
getRuleSavedObjectWithLegacyInvestigationFieldsEmptyArray,
createRuleThroughAlertingEndpoint,
getCustomQueryRuleParams,
} from '../../../utils';
import {
createRule,
Expand Down Expand Up @@ -1140,7 +1141,7 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id);
const newRuleToUpdate = getCustomQueryRuleParams({ rule_id: immutableRule.rule_id });
const ruleToUpdate = getRuleWithWebHookAction(hookAction.id, false, newRuleToUpdate);
await updateRule(supertest, ruleToUpdate);

Expand All @@ -1161,7 +1162,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: false,
elastic_rule: true,
Expand Down Expand Up @@ -1197,7 +1198,7 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id);
const newRuleToUpdate = getCustomQueryRuleParams({ rule_id: immutableRule.rule_id });
const ruleToUpdate = getRuleWithWebHookAction(hookAction.id, true, newRuleToUpdate);
await updateRule(supertest, ruleToUpdate);

Expand All @@ -1218,7 +1219,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: true,
elastic_rule: true,
Expand Down Expand Up @@ -1254,7 +1255,7 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id, false);
const newRuleToUpdate = getCustomQueryRuleParams({ rule_id: immutableRule.rule_id });
await updateRule(supertest, newRuleToUpdate);
await createLegacyRuleAction(supertest, immutableRule.id, hookAction.id);

Expand All @@ -1275,7 +1276,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: false,
elastic_rule: true,
Expand Down Expand Up @@ -1311,7 +1312,10 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id, true);
const newRuleToUpdate = getCustomQueryRuleParams({
rule_id: immutableRule.rule_id,
enabled: true,
});
await updateRule(supertest, newRuleToUpdate);
await createLegacyRuleAction(supertest, immutableRule.id, hookAction.id);

Expand All @@ -1332,7 +1336,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: true,
elastic_rule: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import {
fetchRule,
getRuleWithWebHookAction,
getSimpleMlRule,
getSimpleRule,
getSimpleThreatMatch,
getStats,
getThresholdRuleForAlertTesting,
installMockPrebuiltRules,
updateRule,
deleteAllEventLogExecutionEvents,
getCustomQueryRuleParams,
} from '../../../utils';
import {
createRule,
Expand Down Expand Up @@ -408,7 +408,7 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id, false);
const newRuleToUpdate = getCustomQueryRuleParams({ rule_id: immutableRule.rule_id });
await updateRule(supertest, newRuleToUpdate);
await createLegacyRuleAction(supertest, immutableRule.id, hookAction.id);

Expand All @@ -429,7 +429,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: false,
elastic_rule: true,
Expand Down Expand Up @@ -465,7 +465,10 @@ export default ({ getService }: FtrProviderContext) => {
await installMockPrebuiltRules(supertest, es);
const immutableRule = await fetchRule(supertest, { ruleId: ELASTIC_SECURITY_RULE_ID });
const hookAction = await createWebHookRuleAction(supertest);
const newRuleToUpdate = getSimpleRule(immutableRule.rule_id, true);
const newRuleToUpdate = getCustomQueryRuleParams({
rule_id: immutableRule.rule_id,
enabled: true,
});
await updateRule(supertest, newRuleToUpdate);
await createLegacyRuleAction(supertest, immutableRule.id, hookAction.id);

Expand All @@ -486,7 +489,7 @@ export default ({ getService }: FtrProviderContext) => {
...omittedFields
} = foundRule;
expect(omittedFields).to.eql({
rule_name: 'Simple Rule Query',
rule_name: 'Custom query rule',
rule_type: 'query',
enabled: true,
elastic_rule: true,
Expand Down

0 comments on commit 454006f

Please sign in to comment.