From d72f1b4f03f935bd0434f03567627239c9ceb3f9 Mon Sep 17 00:00:00 2001 From: Maxim Palenov Date: Wed, 11 Sep 2024 00:10:59 +0200 Subject: [PATCH] mock historical prebuilt rule versions --- .../cypress/tasks/api_calls/prebuilt_rules.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/prebuilt_rules.ts b/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/prebuilt_rules.ts index f4273cad22299..420794de7e338 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/prebuilt_rules.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/prebuilt_rules.ts @@ -145,15 +145,24 @@ export const bulkCreateRuleAssets = ({ const url = `${Cypress.env('ELASTICSEARCH_URL')}/${index}/_bulk?refresh`; const bulkIndexRequestBody = rules.reduce((body, rule) => { - const indexOperation = { + const document = JSON.stringify(rule); + const documentId = `security-rule:${rule['security-rule'].rule_id}`; + const historicalDocumentId = `${documentId}_${rule['security-rule'].version}`; + + const indexRuleAsset = `${JSON.stringify({ + index: { + _index: index, + _id: documentId, + }, + })}\n${document}\n`; + const indexHistoricalRuleAsset = `${JSON.stringify({ index: { _index: index, - _id: `security-rule:${rule['security-rule'].rule_id}`, + _id: historicalDocumentId, }, - }; + })}\n${document}\n`; - const documentData = JSON.stringify(rule); - return body.concat(JSON.stringify(indexOperation), '\n', documentData, '\n'); + return body.concat(indexRuleAsset, indexHistoricalRuleAsset); }, ''); rootRequest({