Skip to content

Commit dcda457

Browse files
committed
fixes tests
1 parent c1ef1b5 commit dcda457

4 files changed

Lines changed: 38 additions & 20 deletions

File tree

x-pack/plugins/security_solution/common/detection_engine/schemas/request/add_prepackged_rules_schema.test.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ describe('add prepackaged rules schema', () => {
924924
expect(message.schema).toEqual({});
925925
});
926926

927-
test('You cannot send in an array of threat that are missing "technique"', () => {
927+
test('You can send in an array of threat that are missing "technique"', () => {
928928
const payload: Omit<AddPrepackagedRulesSchema, 'threat'> & {
929929
threat: Array<Partial<Omit<AddPrepackagedRulesSchema['threat'], 'technique'>>>;
930930
} = {
@@ -944,10 +944,21 @@ describe('add prepackaged rules schema', () => {
944944
const decoded = addPrepackagedRulesSchema.decode(payload);
945945
const checked = exactCheck(payload, decoded);
946946
const message = pipe(checked, foldLeftRight);
947-
expect(getPaths(left(message.errors))).toEqual([
948-
'Invalid value "undefined" supplied to "threat,technique"',
949-
]);
950-
expect(message.schema).toEqual({});
947+
expect(getPaths(left(message.errors))).toEqual([]);
948+
const expected: AddPrepackagedRulesSchemaDecoded = {
949+
...getAddPrepackagedRulesSchemaDecodedMock(),
950+
threat: [
951+
{
952+
framework: 'fake',
953+
tactic: {
954+
id: 'fakeId',
955+
name: 'fakeName',
956+
reference: 'fakeRef',
957+
},
958+
},
959+
],
960+
};
961+
expect(message.schema).toEqual(expected);
951962
});
952963

953964
test('You can optionally send in an array of false positives', () => {

x-pack/plugins/security_solution/common/detection_engine/schemas/request/import_rules_schema.test.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ describe('import rules schema', () => {
926926
expect(message.schema).toEqual({});
927927
});
928928

929-
test('You cannot send in an array of threat that are missing "technique"', () => {
929+
test('You can send in an array of threat that are missing "technique"', () => {
930930
const payload: Omit<ImportRulesSchema, 'threat'> & {
931931
threat: Array<Partial<Omit<ImportRulesSchema['threat'], 'technique'>>>;
932932
} = {
@@ -946,10 +946,21 @@ describe('import rules schema', () => {
946946
const decoded = importRulesSchema.decode(payload);
947947
const checked = exactCheck(payload, decoded);
948948
const message = pipe(checked, foldLeftRight);
949-
expect(getPaths(left(message.errors))).toEqual([
950-
'Invalid value "undefined" supplied to "threat,technique"',
951-
]);
952-
expect(message.schema).toEqual({});
949+
expect(getPaths(left(message.errors))).toEqual([]);
950+
const expected: ImportRulesSchemaDecoded = {
951+
...getImportRulesSchemaDecodedMock(),
952+
threat: [
953+
{
954+
framework: 'fake',
955+
tactic: {
956+
id: 'fakeId',
957+
name: 'fakeName',
958+
reference: 'fakeRef',
959+
},
960+
},
961+
],
962+
};
963+
expect(message.schema).toEqual(expected);
953964
});
954965

955966
test('You can optionally send in an array of false positives', () => {

x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_schema.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ describe('patch_rules_schema', () => {
973973
expect(message.schema).toEqual({});
974974
});
975975

976-
test('threat is invalid when updated with missing technique', () => {
976+
test('threat is valid when updated with missing technique', () => {
977977
const threat: Omit<PatchRulesSchema['threat'], 'technique'> = [
978978
{
979979
framework: 'fake',
@@ -993,10 +993,8 @@ describe('patch_rules_schema', () => {
993993
const decoded = patchRulesSchema.decode(payload);
994994
const checked = exactCheck(payload, decoded);
995995
const message = pipe(checked, foldLeftRight);
996-
expect(getPaths(left(message.errors))).toEqual([
997-
'Invalid value "undefined" supplied to "threat,technique"',
998-
]);
999-
expect(message.schema).toEqual({});
996+
expect(getPaths(left(message.errors))).toEqual([]);
997+
expect(message.schema).toEqual(payload);
1000998
});
1001999

10021000
test('validates with timeline_id and timeline_title', () => {

x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ describe('create rules schema', () => {
618618
expect(message.schema).toEqual({});
619619
});
620620

621-
test('You cannot send in an array of threat that are missing "technique"', () => {
621+
test('You can send in an array of threat that are missing "technique"', () => {
622622
const payload = {
623623
...getCreateRulesSchemaMock(),
624624
threat: [
@@ -636,10 +636,8 @@ describe('create rules schema', () => {
636636
const decoded = createRulesSchema.decode(payload);
637637
const checked = exactCheck(payload, decoded);
638638
const message = pipe(checked, foldLeftRight);
639-
expect(getPaths(left(message.errors))).toEqual([
640-
'Invalid value "undefined" supplied to "threat,technique"',
641-
]);
642-
expect(message.schema).toEqual({});
639+
expect(getPaths(left(message.errors))).toEqual([]);
640+
expect(message.schema).toEqual(payload);
643641
});
644642

645643
test('You can optionally send in an array of false positives', () => {

0 commit comments

Comments
 (0)