Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fixes migration bug where I was deleting attributes (#115098) #115293

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('legacy_migrations', () => {
test('it migrates both a "ruleAlertId" and a actions array with 1 element into the references array', () => {
const doc = {
attributes: {
ruleThrottle: '1d',
alertThrottle: '1d',
ruleAlertId: '123',
actions: [
{
Expand All @@ -37,6 +39,8 @@ describe('legacy_migrations', () => {
)
).toEqual({
attributes: {
ruleThrottle: '1d',
alertThrottle: '1d',
actions: [
{
actionRef: 'action_0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const legacyMigrateRuleAlertId = (
return {
...doc,
attributes: {
...attributesWithoutRuleAlertId.attributes,
...attributesWithoutRuleAlertId,
actions: actionsWithRef,
},
references: [...existingReferences, ...alertReferences, ...actionsReferences],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ export default ({ getService }: FtrProviderContext): void => {
undefined
);
});

it('migrates legacy siem-detection-engine-rule-actions and retains "ruleThrottle" and "alertThrottle" as the same attributes as before', async () => {
const response = await es.get<{
'siem-detection-engine-rule-actions': {
ruleThrottle: string;
alertThrottle: string;
};
}>({
index: '.kibana',
id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3',
});
expect(response.statusCode).to.eql(200);

// "alertThrottle" and "ruleThrottle" should still exist
expect(response.body._source?.['siem-detection-engine-rule-actions'].alertThrottle).to.eql(
'7d'
);
expect(response.body._source?.['siem-detection-engine-rule-actions'].ruleThrottle).to.eql(
'7d'
);
});
});
});
};