Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Detections] Refactor functional update_actions tests for rules update API #138757

Closed
vitaliidm opened this issue Aug 12, 2022 · 3 comments
Assignees
Labels
8.5 candidate Feature:Rule Actions Security Solution Detection Rule Actions area Feature:Rule Management Security Solution Detection Rule Management area refactoring Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture v8.5.0 v8.6.0

Comments

@vitaliidm
Copy link
Contributor

vitaliidm commented Aug 12, 2022

Background: #138625 (comment)

Summary

Current add actions tests for immutable rules have complex logic, that includes:

  • fetching immutable rule
  • update immutable rule with mocked properties
  • add actions to it
  • verify added action and rest of updated rule properties, if they were not modified, against earlier mocked rule

source: update_actions.ts

        const immutableRule = await getRule(supertest, log, '9a1a2dae-0b5f-4c3d-8305-a268d404c306');
        const hookAction = await createNewAction(supertest, log);
        const newRuleToUpdate = getSimpleRule(immutableRule.rule_id);
        const ruleToUpdate = getRuleWithWebHookAction(hookAction.id, false, newRuleToUpdate);
        const updatedRule = await updateRule(supertest, log, ruleToUpdate);
        const bodyToCompare = removeServerGeneratedProperties(updatedRule);

Proposal

  • simplify tests by removing step of updating immutable rule with mock data
  • make assertions whether rule properties were not modified against fetched earlier immutable rule

That would allow:

  • to ease maintenance, as we won't need to keep mocks up to date with rule schema
  • make tests more robust, as adding new fields to rule, won't cause tests failures (example: adding required_fields to rule causes tests failure, as mock expected empty results for it)
@vitaliidm vitaliidm added triage_needed refactoring technical debt Improvement of the software architecture and operational architecture Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team labels Aug 12, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@banderror banderror added Feature:Rule Actions Security Solution Detection Rule Actions area Feature:Rule Management Security Solution Detection Rule Management area 8.5 candidate and removed triage_needed labels Aug 15, 2022
@vitaliidm vitaliidm added v8.6.0 and removed v8.4.0 labels Oct 3, 2022
vitaliidm added a commit that referenced this issue Oct 4, 2022
…142464)

## Summary

- addresses #138757

according to proposal in above task:
- removes step of updating immutable rule with mock data
- makes assertions whether rule properties were not modified against fetched earlier immutable rule


### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 4, 2022
…lastic#142464)

## Summary

- addresses elastic#138757

according to proposal in above task:
- removes step of updating immutable rule with mock data
- makes assertions whether rule properties were not modified against fetched earlier immutable rule

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

(cherry picked from commit 10884e6)
kibanamachine added a commit that referenced this issue Oct 4, 2022
…142464) (#142567)

## Summary

- addresses #138757

according to proposal in above task:
- removes step of updating immutable rule with mock data
- makes assertions whether rule properties were not modified against fetched earlier immutable rule

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

(cherry picked from commit 10884e6)

Co-authored-by: Vitalii Dmyterko <[email protected]>
@vitaliidm
Copy link
Contributor Author

implemented in #142464

WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this issue Oct 11, 2022
…lastic#142464)

## Summary

- addresses elastic#138757

according to proposal in above task:
- removes step of updating immutable rule with mock data
- makes assertions whether rule properties were not modified against fetched earlier immutable rule


### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this issue Oct 14, 2022
…lastic#142464)

## Summary

- addresses elastic#138757

according to proposal in above task:
- removes step of updating immutable rule with mock data
- makes assertions whether rule properties were not modified against fetched earlier immutable rule


### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.5 candidate Feature:Rule Actions Security Solution Detection Rule Actions area Feature:Rule Management Security Solution Detection Rule Management area refactoring Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture v8.5.0 v8.6.0
Projects
None yet
Development

No branches or pull requests

3 participants