[8.6] Fix exceptions_success_count relate only to exceptions items (#145700) (#146012)

# Backport

This will backport the following commits from `main` to `8.6`:
- [Fix exceptions_success_count relate only to exceptions items
(#145700)](https://github.com/elastic/kibana/pull/145700)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Khristinin
Nikita","email":"nikita.khristinin@elastic.co"},"sourceCommit":{"committedDate":"2022-11-22T15:51:54Z","message":"Fix
exceptions_success_count relate only to exceptions items (#145700)\n\n##
Fix import rules success message\r\n\r\nfix
https://github.com/elastic/kibana/issues/136760\r\n\r\nexceptions_success_count
now don't count exceptions list, only\r\nexceptions list
items\r\n\r\nAfter discussion with the team, that is ok to return only
exceptions\r\nlist items as success_count for the rule import, because
it reflects our\r\nUI. It does not really reflect the backend, because
we also have the\r\nexceptions list
container.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/202669384-5ddda1a7-e832-41a9-b899-5473a8188681.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"93e0cf5a34bd5aef5a2be6cb8d43c8f9597e3b02","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Security
Solution
Platform","backport:prev-minor","v8.7.0"],"number":145700,"url":"https://github.com/elastic/kibana/pull/145700","mergeCommit":{"message":"Fix
exceptions_success_count relate only to exceptions items (#145700)\n\n##
Fix import rules success message\r\n\r\nfix
https://github.com/elastic/kibana/issues/136760\r\n\r\nexceptions_success_count
now don't count exceptions list, only\r\nexceptions list
items\r\n\r\nAfter discussion with the team, that is ok to return only
exceptions\r\nlist items as success_count for the rule import, because
it reflects our\r\nUI. It does not really reflect the backend, because
we also have the\r\nexceptions list
container.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/202669384-5ddda1a7-e832-41a9-b899-5473a8188681.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"93e0cf5a34bd5aef5a2be6cb8d43c8f9597e3b02"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145700","number":145700,"mergeCommit":{"message":"Fix
exceptions_success_count relate only to exceptions items (#145700)\n\n##
Fix import rules success message\r\n\r\nfix
https://github.com/elastic/kibana/issues/136760\r\n\r\nexceptions_success_count
now don't count exceptions list, only\r\nexceptions list
items\r\n\r\nAfter discussion with the team, that is ok to return only
exceptions\r\nlist items as success_count for the rule import, because
it reflects our\r\nUI. It does not really reflect the backend, because
we also have the\r\nexceptions list
container.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/202669384-5ddda1a7-e832-41a9-b899-5473a8188681.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"93e0cf5a34bd5aef5a2be6cb8d43c8f9597e3b02"}}]}]
BACKPORT-->

Co-authored-by: Khristinin Nikita <nikita.khristinin@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-23 07:05:30 -05:00 committed by GitHub
parent 7b6d34c7d0
commit 2720f45855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View file

@ -33,7 +33,7 @@ describe('Import rules', () => {
cy.wrap(response?.statusCode).should('eql', 200);
cy.get(TOASTER).should(
'have.text',
'Successfully imported 1 ruleSuccessfully imported 2 exceptions.'
'Successfully imported 1 ruleSuccessfully imported 1 exception.'
);
cy.get(RULES_TABLE).then(($table) => {
@ -75,7 +75,7 @@ describe('Import rules', () => {
cy.wrap(response?.statusCode).should('eql', 200);
cy.get(TOASTER).should(
'have.text',
'Successfully imported 1 ruleSuccessfully imported 2 exceptions.'
'Successfully imported 1 ruleSuccessfully imported 1 exception.'
);
});
});

View file

@ -43,7 +43,9 @@ export const importRuleExceptions = async ({
const {
errors,
success,
success_count: successCount,
// return only count of exception list items, without count excpetions list
// to be consistent with UI, and users shouldn't know about backend structure
success_count_exception_list_items: successCount,
} = await exceptionsClient.importExceptionListAndItemsAsArray({
exceptionsToImport: exceptions,
overwrite,

View file

@ -973,7 +973,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
@ -1143,7 +1143,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
@ -1273,7 +1273,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
});

View file

@ -874,7 +874,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
@ -1044,7 +1044,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
@ -1174,7 +1174,7 @@ export default ({ getService }: FtrProviderContext): void => {
errors: [],
exceptions_errors: [],
exceptions_success: true,
exceptions_success_count: 2,
exceptions_success_count: 1,
});
});
});