Skip to content

Commit

Permalink
Follow up (#116860)
Browse files Browse the repository at this point in the history
## Summary

One line follow up from #116490 from @dhurley14 here: #116490 (comment)


### 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
  • Loading branch information
FrankHassanabad authored Oct 30, 2021
1 parent ea62dd0 commit eaedb78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ describe.each([

describe('getTupleDuplicateErrorsAndUniqueRules', () => {
test('returns tuple of empty duplicate errors array and rule array with instance of Syntax Error when imported rule contains parse error', async () => {
// This is a string because we have a double "::" below to make an error happen on purpose.
const multipartPayload =
'{"name"::"Simple Rule Query","description":"Simple Rule Query","risk_score":1,"rule_id":"rule-1","severity":"high","type":"query","query":"user.name: root or user.name: admin"}\n';
const ndJsonStream = new Readable({
Expand Down Expand Up @@ -657,6 +658,7 @@ describe.each([
});

test('returns empty errors array and rule array with instance of Syntax Error when imported rule contains parse error', async () => {
// This is a string because we have a double "::" below to make an error happen on purpose.
const multipartPayload =
'{"name"::"Simple Rule Query","description":"Simple Rule Query","risk_score":1,"rule_id":"rule-1","severity":"high","type":"query","query":"user.name: root or user.name: admin"}\n';
const ndJsonStream = new Readable({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ export const getInvalidConnectors = async (
actionsClient: ActionsClient
): Promise<[BulkError[], PromiseFromStreams[]]> => {
const actionsFind = await actionsClient.getAll();
const actionIds = actionsFind.map((action) => action.id);
const actionIds = new Set(actionsFind.map((action) => action.id));
const { errors, rulesAcc } = rules.reduce(
(acc, parsedRule) => {
if (parsedRule instanceof Error) {
acc.rulesAcc.set(uuid.v4(), parsedRule);
} else {
const { rule_id: ruleId, actions } = parsedRule;
const missingActionIds = actions.flatMap((action) => {
if (actionIds.find((actionsId) => actionsId === action.id) == null) {
if (!actionIds.has(action.id)) {
return [action.id];
} else {
return [];
Expand Down

0 comments on commit eaedb78

Please sign in to comment.