Don't create API key for disabled alerts when calling create API#57041
Don't create API key for disabled alerts when calling create API#57041mikecote merged 5 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
💔 Build FailedTest FailuresKibana Pipeline / kibana-xpack-agent / X-Pack Alerting API Integration Tests.x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find·ts.alerting api integration security and spaces enabled Alerting find superuser at space1 should handle find alert request with filter appropriatelyStandard OutStack TraceKibana Pipeline / kibana-xpack-agent / X-Pack Alerting API Integration Tests.x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find·ts.alerting api integration security and spaces enabled Alerting find superuser at space1 should handle find alert request with filter appropriatelyStandard OutStack TraceTo update your PR or re-run it, just comment with: |
peterschretlen
left a comment
There was a problem hiding this comment.
LGTM. Tested with SIEM and this is a nice change for detection engine: before this fix, when you loaded the pre-built signal rules, each would create an API key even though none of them were turned on. Now we only create keys for the ones actually being used 👍
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
pmuellr
left a comment
There was a problem hiding this comment.
LGTM, left a comment ...
|
|
||
| test(`doesn't create API key for disabled alerts`, async () => { | ||
| const data = getMockData({ enabled: false }); | ||
| alertsClientParams.createAPIKey.mockResolvedValueOnce({ |
There was a problem hiding this comment.
I don't think this is needed, given
expect(alertsClientParams.createAPIKey).not.toHaveBeenCalled();But I also suspect it could be useful if we ever start calling this, so ... it's fine. Perhaps a comment that it's not expected this will actually get called ...
There was a problem hiding this comment.
Nice catch! I went ahead and removed it here: 31ead6d and maybe in a future refactor this code will move into a beforeEach for the ones that do call that function.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…stic#57041) * Don't create API key for disabled alerts when calling create API * Fix failing test * Remove unused code in test
) (#57239) * Don't create API key for disabled alerts when calling create API * Fix failing test * Remove unused code in test Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* master: (34 commits) [Index management] Server-side NP ready (elastic#56829) Webhook action - make user and password secrets optional (elastic#56823) [DOCS] Removes reference to IRC (elastic#57245) [Monitoring] NP migration: Local angular module (elastic#51823) [SIEM] Adds ECS link to help menu (elastic#57104) Ensure http interceptors are shares across lifecycle methods (elastic#57150) [Remote clusters] Migrate server code out of legacy (elastic#56781) fixes render bug in alert list (elastic#57152) siem 7.6 updates (elastic#57169) Make the update alert API key API work when AAD is out of sync (elastic#56640) fix(NA): MaxListenersExceededWarning on getLoggerStream (elastic#57133) [Metrics UI] Setup commonly used time ranges in timepicker (elastic#56701) [Maps] set filter.meta.key to geoFieldName so query passes filterMatchesIndex when ignoreFilterIfFieldNotInIndex is true (elastic#56692) Create plugin mock for event log plugin (elastic#57048) fix ts error on master (elastic#57236) Don't create API key for disabled alerts when calling create API (elastic#57041) Fix enable and disable API to still work when AAD is out of sync (elastic#56634) [DOCS] Canvas embed objects (elastic#57156) Delete autocomplete namespace (elastic#57187) Security - Inject logout url (elastic#57201) ...
Fixes #57036.
In this PR, I'm changing the create function within the alerts client to not create an API key when the alert is created as disabled.
I'm also refactoring a bit of the unit tests for alerts client create function.