diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.test.ts index f5e17d2bff231..02ab664602043 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { convertPatchAPIToInternalSchema, patchTypeSpecificSnakeToCamel } from './rule_converters'; +import { patchTypeSpecificSnakeToCamel } from './rule_converters'; import { getEqlRuleParams, getMlRuleParams, @@ -15,7 +15,6 @@ import { getThreatRuleParams, getThresholdRuleParams, } from '../../rule_schema/mocks'; -import { getRuleMock } from '../../routes/__mocks__/request_responses'; describe('rule_converters', () => { describe('patchTypeSpecificSnakeToCamel', () => { @@ -204,79 +203,4 @@ describe('rule_converters', () => { ); }); }); - - describe('convertPatchAPIToInternalSchema', () => { - test('should set version to one specified in next params for custom rules', () => { - const nextParams = { - index: ['new-test-index'], - language: 'lucene', - version: 3, - }; - const existingRule = getRuleMock({ ...getQueryRuleParams(), version: 1 }); - const patchedParams = convertPatchAPIToInternalSchema(nextParams, existingRule); - expect(patchedParams).toEqual( - expect.objectContaining({ - params: expect.objectContaining({ version: 3 }), - }) - ); - }); - - test('should set version to one specified in next params for immutable rules', () => { - const nextParams = { - index: ['new-test-index'], - language: 'lucene', - version: 3, - }; - const existingRule = getRuleMock({ ...getQueryRuleParams(), version: 1, immutable: true }); - const patchedParams = convertPatchAPIToInternalSchema(nextParams, existingRule); - expect(patchedParams).toEqual( - expect.objectContaining({ - params: expect.objectContaining({ version: 3 }), - }) - ); - }); - - test('should not increment version for immutable rules if it is not specified in next params', () => { - const nextParams = { - index: ['new-test-index'], - language: 'lucene', - }; - const existingRule = getRuleMock({ ...getQueryRuleParams(), version: 1, immutable: true }); - const patchedParams = convertPatchAPIToInternalSchema(nextParams, existingRule); - expect(patchedParams).toEqual( - expect.objectContaining({ - params: expect.objectContaining({ version: 1 }), - }) - ); - }); - - test('should increment version for custom rules if it is not specified in next params', () => { - const nextParams = { - index: ['new-test-index'], - language: 'lucene', - }; - const existingRule = getRuleMock({ ...getQueryRuleParams(), version: 1 }); - const patchedParams = convertPatchAPIToInternalSchema(nextParams, existingRule); - expect(patchedParams).toEqual( - expect.objectContaining({ - params: expect.objectContaining({ version: 2 }), - }) - ); - }); - - test('should not increment version due to enabled, id, or rule_id, ', () => { - const nextParams = { - enabled: false, - id: 'some-id', - rule_id: 'some-rule-id', - }; - const existingRule = getRuleMock({ ...getQueryRuleParams(), version: 1 }); - const patchedParams = convertPatchAPIToInternalSchema(nextParams, existingRule); - expect(patchedParams).toEqual( - expect.objectContaining({ - params: expect.objectContaining({ version: 1 }), - }) - ); - }); - }); }); diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/import_rules.ts b/x-pack/test/detection_engine_api_integration/basic/tests/import_rules.ts index 5b8508ffe480d..d57b793cd1bc4 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/import_rules.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/import_rules.ts @@ -360,7 +360,6 @@ export default ({ getService }: FtrProviderContext): void => { output_index: '', }; ruleOutput.name = 'some other name'; - ruleOutput.version = 2; ruleOutput.revision = 0; expect(bodyToCompare).to.eql(ruleOutput); }); diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules.ts b/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules.ts index 31dd7b0dbc99c..1ca83b8ed1fa8 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules.ts @@ -49,7 +49,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); expect(bodyToCompare).to.eql(outputRule); @@ -86,7 +85,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutputWithoutRuleId(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body); expect(bodyToCompare).to.eql(outputRule); @@ -104,13 +102,12 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); expect(bodyToCompare).to.eql(outputRule); }); - it('should not change the version of a rule when it patches only enabled', async () => { + it('should not change the revision of a rule when it patches only enabled', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false @@ -127,7 +124,7 @@ export default ({ getService }: FtrProviderContext) => { expect(bodyToCompare).to.eql(outputRule); }); - it('should change the version of a rule when it patches enabled and another property', async () => { + it('should change the revision of a rule when it patches enabled and another property', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false and another property @@ -140,7 +137,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.enabled = false; outputRule.severity = 'low'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); @@ -168,7 +164,6 @@ export default ({ getService }: FtrProviderContext) => { outputRule.name = 'some other name'; outputRule.timeline_title = 'some title'; outputRule.timeline_id = 'some id'; - outputRule.version = 3; outputRule.revision = 2; const bodyToCompare = removeServerGeneratedProperties(body); diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules_bulk.ts index 21715fb7901bb..f0c135a9cd77d 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/patch_rules_bulk.ts @@ -49,7 +49,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); @@ -71,12 +70,10 @@ export default ({ getService }: FtrProviderContext) => { const outputRule1 = getSimpleRuleOutput(); outputRule1.name = 'some other name'; - outputRule1.version = 2; outputRule1.revision = 1; const outputRule2 = getSimpleRuleOutput('rule-2'); outputRule2.name = 'some other name'; - outputRule2.version = 2; outputRule2.revision = 1; const bodyToCompare1 = removeServerGeneratedProperties(body[0]); @@ -97,7 +94,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); @@ -119,12 +115,10 @@ export default ({ getService }: FtrProviderContext) => { const outputRule1 = getSimpleRuleOutputWithoutRuleId('rule-1'); outputRule1.name = 'some other name'; - outputRule1.version = 2; outputRule1.revision = 1; const outputRule2 = getSimpleRuleOutputWithoutRuleId('rule-2'); outputRule2.name = 'some other name'; - outputRule2.version = 2; outputRule2.revision = 1; const bodyToCompare1 = removeServerGeneratedPropertiesIncludingRuleId(body[0]); @@ -145,13 +139,12 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); }); - it('should not change the version of a rule when it patches only enabled', async () => { + it('should not change the revision of a rule when it patches only enabled', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false @@ -168,7 +161,7 @@ export default ({ getService }: FtrProviderContext) => { expect(bodyToCompare).to.eql(outputRule); }); - it('should change the version of a rule when it patches enabled and another property', async () => { + it('should change the revision of a rule when it patches enabled and another property', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false and another property @@ -181,7 +174,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.enabled = false; outputRule.severity = 'low'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -209,7 +201,6 @@ export default ({ getService }: FtrProviderContext) => { outputRule.name = 'some other name'; outputRule.timeline_title = 'some title'; outputRule.timeline_id = 'some id'; - outputRule.version = 3; outputRule.revision = 2; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -264,7 +255,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -295,7 +285,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/import_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/import_rules.ts index 849c2a9858aaf..7672153845e0a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/import_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/import_rules.ts @@ -714,7 +714,6 @@ export default ({ getService }: FtrProviderContext): void => { output_index: '', }; ruleOutput.name = 'some other name'; - ruleOutput.version = 2; ruleOutput.revision = 0; expect(bodyToCompare).to.eql(ruleOutput); }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules_bulk.ts index 48ea361536585..e7437f91bc69b 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules_bulk.ts @@ -72,7 +72,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); @@ -94,12 +93,10 @@ export default ({ getService }: FtrProviderContext) => { const outputRule1 = getSimpleRuleOutput(); outputRule1.name = 'some other name'; - outputRule1.version = 2; outputRule1.revision = 1; const outputRule2 = getSimpleRuleOutput('rule-2'); outputRule2.name = 'some other name'; - outputRule2.version = 2; outputRule2.revision = 1; const bodyToCompare1 = removeServerGeneratedProperties(body[0]); @@ -120,7 +117,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); @@ -142,12 +138,10 @@ export default ({ getService }: FtrProviderContext) => { const outputRule1 = getSimpleRuleOutputWithoutRuleId('rule-1'); outputRule1.name = 'some other name'; - outputRule1.version = 2; outputRule1.revision = 1; const outputRule2 = getSimpleRuleOutputWithoutRuleId('rule-2'); outputRule2.name = 'some other name'; - outputRule2.version = 2; outputRule2.revision = 1; const bodyToCompare1 = removeServerGeneratedPropertiesIncludingRuleId(body[0]); @@ -219,13 +213,12 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); expect(bodyToCompare).to.eql(outputRule); }); - it('should not change the version of a rule when it patches only enabled', async () => { + it('should not change the revision of a rule when it patches only enabled', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false @@ -242,7 +235,7 @@ export default ({ getService }: FtrProviderContext) => { expect(bodyToCompare).to.eql(outputRule); }); - it('should change the version of a rule when it patches enabled and another property', async () => { + it('should change the revision of a rule when it patches enabled and another property', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false and another property @@ -255,7 +248,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.enabled = false; outputRule.severity = 'low'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -283,7 +275,6 @@ export default ({ getService }: FtrProviderContext) => { outputRule.name = 'some other name'; outputRule.timeline_title = 'some title'; outputRule.timeline_id = 'some id'; - outputRule.version = 3; outputRule.revision = 2; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -338,7 +329,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]); @@ -369,7 +359,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body[0]);