Skip to content

Commit

Permalink
Update incorrect SO index in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Apr 18, 2023
1 parent a7f95c9 commit 5f601bf
Show file tree
Hide file tree
Showing 8 changed files with 1,964 additions and 9 deletions.
1,943 changes: 1,943 additions & 0 deletions cases.patch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../common/ftr_provider_context';

Expand Down Expand Up @@ -32,7 +33,7 @@ export default ({ getService }: FtrProviderContext): void => {
references: [{}];
}>(
{
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3',
},
{
Expand Down Expand Up @@ -79,7 +80,7 @@ export default ({ getService }: FtrProviderContext): void => {
};
}>(
{
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import type { Client } from '@elastic/elasticsearch';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import type { ToolingLog } from '@kbn/tooling-log';
import { countDownES } from './count_down_es';

Expand All @@ -20,7 +21,7 @@ export const deleteAllRuleExecutionInfo = async (es: Client, log: ToolingLog): P
async () => {
return es.deleteByQuery(
{
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
q: 'type:siem-detection-engine-rule-execution-info',
wait_for_completion: true,
refresh: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/

import type { Client } from '@elastic/elasticsearch';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';

/**
* Remove all timelines from the .kibana index
* @param es The ElasticSearch handle
*/
export const deleteAllTimelines = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
q: 'type:siem-ui-timeline',
wait_for_completion: true,
refresh: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
import type { Client } from '@elastic/elasticsearch';
import type { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import type { SavedObjectReference } from '@kbn/core/server';
import type { LegacyRuleActions } from '@kbn/security-solution-plugin/server/lib/detection_engine/rule_actions_legacy';

Expand All @@ -19,6 +20,6 @@ interface LegacyActionSO extends LegacyRuleActions {
*/
export const getLegacyActionSO = async (es: Client): Promise<SearchResponse<LegacyActionSO>> =>
es.search({
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
q: 'type:siem-detection-engine-rule-actions',
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import type { Client } from '@elastic/elasticsearch';
import type { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import { SavedObjectReference } from '@kbn/core/server';
import type { LegacyRuleActions } from '@kbn/security-solution-plugin/server/lib/detection_engine/rule_actions_legacy';

Expand All @@ -24,6 +25,6 @@ export const getLegacyActionSOById = async (
id: string
): Promise<SearchResponse<LegacyActionSO>> =>
es.search({
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
q: `type:siem-detection-engine-rule-actions AND _id:"siem-detection-engine-rule-actions:${id}"`,
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getPrebuiltRuleWithExceptionsMock,
} from '@kbn/security-solution-plugin/server/lib/detection_engine/prebuilt_rules/mocks';
import { ELASTIC_SECURITY_RULE_ID } from '@kbn/security-solution-plugin/common';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';

/**
* A helper function to create a rule asset saved object
Expand Down Expand Up @@ -73,7 +74,12 @@ export const createPrebuiltRuleAssetSavedObjects = async (
await es.bulk({
refresh: true,
body: rules.flatMap((doc) => [
{ index: { _index: '.kibana', _id: `security-rule:${doc['security-rule'].rule_id}` } },
{
index: {
_index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
_id: `security-rule:${doc['security-rule'].rule_id}`,
},
},
doc,
]),
});
Expand All @@ -97,7 +103,7 @@ export const createHistoricalPrebuiltRuleAssetSavedObjects = async (
body: rules.flatMap((doc) => [
{
index: {
_index: '.kibana',
_index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
_id: `security-rule:${doc['security-rule'].rule_id}_${doc['security-rule'].version}`,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/

import type { Client } from '@elastic/elasticsearch';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';

/**
* Remove all prebuilt rule assets from the .kibana index
* @param es The ElasticSearch handle
*/
export const deleteAllPrebuiltRuleAssets = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
index: SECURITY_SOLUTION_SAVED_OBJECT_INDEX,
q: 'type:security-rule',
wait_for_completion: true,
refresh: true,
Expand Down

0 comments on commit 5f601bf

Please sign in to comment.