-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution] Edit host isolation exception IP UI #114279
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] Edit host isolation exception IP UI #114279
Conversation
…ation-exception-add
…ation-exception-add
…ation-exception-add
…ation-exception-add
…ation-exceptions-edit
|
Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt) |
|
@elasticmachine merge upstream |
paul-tavares
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided some feedback, nothing major. I am a bit confused by some of the Unit tests where actions/setup seems to be done, but there are no checks (expect()) done following that setup. At the very least you should include a expect() at the end of them that check for "something" that indicates (to the future us 😁 ) what the intent of the test/setup is
x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts
Outdated
Show resolved
Hide resolved
...security_solution/public/management/pages/host_isolation_exceptions/store/middleware.test.ts
Outdated
Show resolved
Hide resolved
...security_solution/public/management/pages/host_isolation_exceptions/store/middleware.test.ts
Show resolved
Hide resolved
...gins/security_solution/public/management/pages/host_isolation_exceptions/store/middleware.ts
Outdated
Show resolved
Hide resolved
...gins/security_solution/public/management/pages/host_isolation_exceptions/store/middleware.ts
Show resolved
Hide resolved
...gins/security_solution/public/management/pages/host_isolation_exceptions/store/middleware.ts
Show resolved
Hide resolved
...security_solution/public/management/pages/host_isolation_exceptions/view/components/form.tsx
Show resolved
Hide resolved
| it('should submit the entry data when submit is pressed with valid data', async () => { | ||
| const confirmButton = renderResult.getByTestId('add-exception-confirm-button'); | ||
| expect(confirmButton).not.toHaveAttribute('disabled'); | ||
| const waiter = waitForAction('hostIsolationExceptionsCreateEntry'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure why there is code after the expect() here (and maybe in other places). I know its not part of this PR, but I might have missed it in the prior one where this was introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a multi-step test. In this case:
- Check the submit button is enabled
- Press the button
- Check the expected action was triggered
The waiter variable, is a promise to waitForAction which is a check on itself. If that action would not trigger, this test will fail and the component would not be working as expected.
I create the waiter variable before the click to avoid race conditions on the spy and the render.
There's nothing that technically limit you to put expect only at the end of a test function. In this particular test, there's no further things to check in the UI.
| expect(confirmButton).not.toHaveAttribute('disabled'); | ||
| const waiter = waitForAction('hostIsolationExceptionsSubmitEdit'); | ||
| userEvent.click(confirmButton); | ||
| await waiter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. Feels like maybe you are missing an expect() following this set of additional actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is complete. waiter is a promise that waits for an action and is a check on itself, it is just not called expect. If this action would not trigger when you click the button, this component would be broken.
...y_solution/public/management/pages/host_isolation_exceptions/view/components/form_flyout.tsx
Outdated
Show resolved
Hide resolved
…ation-exceptions-edit
The reason why the setup seems strange like this: is because I faced many race conditions where the render will trigger the actions too fast for the middlewareSpy to register the action to spy and trigger. So I started following the pattern of first registering the spy, rendering, then waiting for the check. I will check those tests once again to see if there's some UI check I should do, like a disabled button, but they are complete as they are. |
paul-tavares
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still left some comments around the tests that have no expect, but that should not hold up this PR from my perspective.
👍
...gins/security_solution/public/management/pages/host_isolation_exceptions/store/middleware.ts
Show resolved
Hide resolved
...ity_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx
Show resolved
Hide resolved
...security_solution/public/management/pages/host_isolation_exceptions/store/middleware.test.ts
Show resolved
Hide resolved
...ity_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/search/session·ts.apis search search session touched time updates when you poll on an searchStandard OutStack TraceMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
ashokaditya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked it out and took it for a spin. Works as expected. I have minor suggestions but not a blocker for rolling it out.
🚀 🐑
Note: I still believe the error messages could be better. Showing the failed to fetch or other such API-specific messages to the user is not useful in my opinion. Perhaps it's how it has been done so far, but I think this can be done better.
For instance, as a user I don't know what I should do with this info:

| }); | ||
| } | ||
|
|
||
| export async function getOneHostIsolationExceptionItem( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I think the One is not necessary for the name, Item already says it's a singular thing. Unless getHostIsolationExceptionItem name collides with another 😅
| const [formHasError, setFormHasError] = useState(true); | ||
| const [exception, setException] = useState<CreateExceptionListItemSchema | undefined>(undefined); | ||
| const [exception, setException] = useState< | ||
| CreateExceptionListItemSchema | UpdateExceptionListItemSchema | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: You can also use <HostIsolationExceptionsPageState['form']['entry']> here instead.
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…mple/introduce-baseline-tests * 'master' of github.com:elastic/kibana: (55 commits) [Fleet] Improve Functionality around Managed Package Policies (elastic#114526) cleanup (elastic#114902) remove stray semicolon (elastic#114969) [Security Solution] Edit host isolation exception IP UI (elastic#114279) [ML] APM Correlations: Round duration values to be used in range aggregations. (elastic#114833) [Index Management] Added `data-test-subj` values to the index context menu buttons (elastic#114900) [Stack monitoring] Fix logstash functional tests for react (elastic#114819) Implement hybrid approach to writing rule execution event logs (elastic#114852) [Detection Rules] Add 7.16 rules (elastic#114939) Fixing exceptions export format (elastic#114920) Clean up inaccurate comments (elastic#114935) chore(NA): fixes a typo on persist_bazel_cache.sh comment (elastic#114943) [ci] Fixes Bazel cache writes (elastic#114915) fix package.json: (elastic#114936) [Controls] Redux Toolkit and Embeddable Redux Wrapper (elastic#114371) [APM] Fixes incorrect index config names (elastic#114901) (elastic#114904) [Workplace Search] Fix button order and remove extra source name label (elastic#114899) [Actions] Fixed actions telemetry for multiple namespaces usage (elastic#114748) docs: fix config names (elastic#114903) Update kibana to EMS 7.16 (elastic#114865) ...
Summary
Continuation of #111253 #113541 and #113762
This PR introduces the functionality to edit a host isolation exception item.
All the validations remain the same as with the add an item.
Note to reviewers: I had to re-introduce ts-ignore in several parts where the
LoadingResourceStateis being used.I will work on fixing all the related types problems with it in the upcoming weeks.
Checklist
Delete any items that are not applicable to this PR.