Skip to content

Commit

Permalink
Fixed the types and the cypress test set to match what we are now exp…
Browse files Browse the repository at this point in the history
…orting
  • Loading branch information
FrankHassanabad committed Jun 10, 2020
1 parent 94362b5 commit 4953082
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"actions":[],"created_at":"2020-03-26T10:09:07.569Z","updated_at":"2020-03-26T10:09:08.021Z","created_by":"elastic","description":"Rule 1","enabled":true,"false_positives":[],"filters":[],"from":"now-360s","id":"49db5bd1-bdd5-4821-be26-bb70a815dedb","immutable":false,"index":["apm-*-transaction*","auditbeat-*","endgame-*","filebeat-*","packetbeat-*","winlogbeat-*"],"interval":"5m","rule_id":"0cea4194-03f2-4072-b281-d31b72221d9d","language":"kuery","output_index":".siem-signals-default","max_signals":100,"risk_score":50,"name":"Rule 1","query":"host.name:*","references":[],"meta":{"from":"1m","throttle":"no_actions"},"severity":"low","updated_by":"elastic","tags":["rule1"],"to":"now","type":"query","threat":[],"throttle":"no_actions","version":1}
{"actions":[],"created_at":"2020-03-26T10:09:07.569Z","updated_at":"2020-03-26T10:09:08.021Z","created_by":"elastic","description":"Rule 1","enabled":true,"false_positives":[],"filters":[],"from":"now-360s","id":"49db5bd1-bdd5-4821-be26-bb70a815dedb","immutable":false,"index":["apm-*-transaction*","auditbeat-*","endgame-*","filebeat-*","packetbeat-*","winlogbeat-*"],"interval":"5m","rule_id":"0cea4194-03f2-4072-b281-d31b72221d9d","language":"kuery","output_index":".siem-signals-default","max_signals":100,"risk_score":50,"name":"Rule 1","query":"host.name:*","references":[],"meta":{"from":"1m","throttle":"no_actions"},"severity":"low","updated_by":"elastic","tags":["rule1"],"to":"now","type":"query","threat":[],"throttle":"no_actions","version":1,"exceptions_list":[]}
{"exported_count":1,"missing_rules":[],"missing_rules_count":0}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
createSignalsIndex,
deleteAllAlerts,
deleteSignalsIndex,
getSimpleRule,
getSimpleRuleOutput,
removeServerGeneratedProperties,
removeServerGeneratedPropertiesIncludingRuleId,
getSimpleRuleOutputWithoutRuleId,
getSimpleMlRule,
getSimpleRuleUpdate,
getSimpleMlRuleUpdate,
} from '../../utils';

// eslint-disable-next-line import/no-default-export
Expand All @@ -41,11 +41,11 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's name
const updatedRule = getSimpleRule('rule-1');
const updatedRule = getSimpleRuleUpdate('rule-1');
updatedRule.rule_id = 'rule-1';
updatedRule.name = 'some other name';
delete updatedRule.id;
Expand All @@ -68,11 +68,11 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's type to try to be a machine learning job type
const updatedRule = getSimpleMlRule('rule-1');
const updatedRule = getSimpleMlRuleUpdate('rule-1');
updatedRule.rule_id = 'rule-1';
updatedRule.name = 'some other name';
delete updatedRule.id;
Expand All @@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should update a single rule property of name using an auto-generated rule_id', async () => {
const rule = getSimpleRule('rule-1');
const rule = getSimpleRuleUpdate('rule-1');
delete rule.rule_id;
// create a simple rule
const { body: createRuleBody } = await supertest
Expand All @@ -100,7 +100,7 @@ export default ({ getService }: FtrProviderContext) => {
.expect(200);

// update a simple rule's name
const updatedRule = getSimpleRule('rule-1');
const updatedRule = getSimpleRuleUpdate('rule-1');
updatedRule.rule_id = createRuleBody.rule_id;
updatedRule.name = 'some other name';
delete updatedRule.id;
Expand All @@ -123,11 +123,11 @@ export default ({ getService }: FtrProviderContext) => {
const { body: createdBody } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's name
const updatedRule = getSimpleRule('rule-1');
const updatedRule = getSimpleRuleUpdate('rule-1');
updatedRule.name = 'some other name';
updatedRule.id = createdBody.id;
delete updatedRule.rule_id;
Expand All @@ -150,11 +150,11 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's enabled to false and another property
const updatedRule = getSimpleRule('rule-1');
const updatedRule = getSimpleRuleUpdate('rule-1');
updatedRule.severity = 'low';
updatedRule.enabled = false;

Expand All @@ -178,10 +178,10 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

const ruleUpdate = getSimpleRule('rule-1');
const ruleUpdate = getSimpleRuleUpdate('rule-1');
ruleUpdate.timeline_title = 'some title';
ruleUpdate.timeline_id = 'some id';

Expand All @@ -192,7 +192,7 @@ export default ({ getService }: FtrProviderContext) => {
.send(ruleUpdate)
.expect(200);

const ruleUpdate2 = getSimpleRule('rule-1');
const ruleUpdate2 = getSimpleRuleUpdate('rule-1');
ruleUpdate2.name = 'some other name';

// update a simple rule's name
Expand All @@ -211,7 +211,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should give a 404 if it is given a fake id', async () => {
const simpleRule = getSimpleRule();
const simpleRule = getSimpleRuleUpdate();
simpleRule.id = '5096dec6-b6b9-4d8d-8f93-6c2602079d9d';
delete simpleRule.rule_id;

Expand All @@ -228,7 +228,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should give a 404 if it is given a fake rule_id', async () => {
const simpleRule = getSimpleRule();
const simpleRule = getSimpleRuleUpdate();
simpleRule.rule_id = 'fake_id';
delete simpleRule.id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
createSignalsIndex,
deleteAllAlerts,
deleteSignalsIndex,
getSimpleRule,
getSimpleRuleOutput,
removeServerGeneratedProperties,
getSimpleRuleOutputWithoutRuleId,
removeServerGeneratedPropertiesIncludingRuleId,
getSimpleRuleUpdate,
} from '../../utils';

// eslint-disable-next-line import/no-default-export
Expand All @@ -40,10 +40,10 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

const updatedRule = getSimpleRule('rule-1');
const updatedRule = getSimpleRuleUpdate('rule-1');
updatedRule.name = 'some other name';

// update a simple rule's name
Expand All @@ -65,20 +65,20 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// create a second simple rule
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-2'))
.send(getSimpleRuleUpdate('rule-2'))
.expect(200);

const updatedRule1 = getSimpleRule('rule-1');
const updatedRule1 = getSimpleRuleUpdate('rule-1');
updatedRule1.name = 'some other name';

const updatedRule2 = getSimpleRule('rule-2');
const updatedRule2 = getSimpleRuleUpdate('rule-2');
updatedRule2.name = 'some other name';

// update both rule names
Expand Down Expand Up @@ -107,11 +107,11 @@ export default ({ getService }: FtrProviderContext) => {
const { body: createRuleBody } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's name
const updatedRule1 = getSimpleRule('rule-1');
const updatedRule1 = getSimpleRuleUpdate('rule-1');
updatedRule1.id = createRuleBody.id;
updatedRule1.name = 'some other name';
delete updatedRule1.rule_id;
Expand All @@ -134,23 +134,23 @@ export default ({ getService }: FtrProviderContext) => {
const { body: createRule1 } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// create a second simple rule
const { body: createRule2 } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-2'))
.send(getSimpleRuleUpdate('rule-2'))
.expect(200);

// update both rule names
const updatedRule1 = getSimpleRule('rule-1');
const updatedRule1 = getSimpleRuleUpdate('rule-1');
updatedRule1.id = createRule1.id;
updatedRule1.name = 'some other name';
delete updatedRule1.rule_id;

const updatedRule2 = getSimpleRule('rule-1');
const updatedRule2 = getSimpleRuleUpdate('rule-1');
updatedRule2.id = createRule2.id;
updatedRule2.name = 'some other name';
delete updatedRule2.rule_id;
Expand Down Expand Up @@ -180,11 +180,11 @@ export default ({ getService }: FtrProviderContext) => {
const { body: createdBody } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's name
const updatedRule1 = getSimpleRule('rule-1');
const updatedRule1 = getSimpleRuleUpdate('rule-1');
updatedRule1.id = createdBody.id;
updatedRule1.name = 'some other name';
delete updatedRule1.rule_id;
Expand All @@ -207,11 +207,11 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's enabled to false and another property
const updatedRule1 = getSimpleRule('rule-1');
const updatedRule1 = getSimpleRuleUpdate('rule-1');
updatedRule1.severity = 'low';
updatedRule1.enabled = false;

Expand All @@ -235,11 +235,11 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update a simple rule's timeline_title
const ruleUpdate = getSimpleRule('rule-1');
const ruleUpdate = getSimpleRuleUpdate('rule-1');
ruleUpdate.timeline_title = 'some title';
ruleUpdate.timeline_id = 'some id';

Expand All @@ -250,7 +250,7 @@ export default ({ getService }: FtrProviderContext) => {
.expect(200);

// update a simple rule's name
const ruleUpdate2 = getSimpleRule('rule-1');
const ruleUpdate2 = getSimpleRuleUpdate('rule-1');
ruleUpdate2.name = 'some other name';

const { body } = await supertest
Expand All @@ -268,7 +268,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should return a 200 but give a 404 in the message if it is given a fake id', async () => {
const ruleUpdate = getSimpleRule('rule-1');
const ruleUpdate = getSimpleRuleUpdate('rule-1');
ruleUpdate.id = '1fd52120-d3a9-4e7a-b23c-96c0e1a74ae5';
delete ruleUpdate.rule_id;

Expand All @@ -290,7 +290,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should return a 200 but give a 404 in the message if it is given a fake rule_id', async () => {
const ruleUpdate = getSimpleRule('rule-1');
const ruleUpdate = getSimpleRuleUpdate('rule-1');
ruleUpdate.rule_id = 'fake_id';
delete ruleUpdate.id;

Expand All @@ -313,14 +313,14 @@ export default ({ getService }: FtrProviderContext) => {
await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

const ruleUpdate = getSimpleRule('rule-1');
const ruleUpdate = getSimpleRuleUpdate('rule-1');
ruleUpdate.name = 'some other name';
delete ruleUpdate.id;

const ruleUpdate2 = getSimpleRule('fake_id');
const ruleUpdate2 = getSimpleRuleUpdate('fake_id');
ruleUpdate2.name = 'some other name';
delete ruleUpdate.id;

Expand Down Expand Up @@ -353,16 +353,16 @@ export default ({ getService }: FtrProviderContext) => {
const { body: createdBody } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.send(getSimpleRule('rule-1'))
.send(getSimpleRuleUpdate('rule-1'))
.expect(200);

// update one rule name and give a fake id for the second
const rule1 = getSimpleRule();
const rule1 = getSimpleRuleUpdate();
delete rule1.rule_id;
rule1.id = createdBody.id;
rule1.name = 'some other name';

const rule2 = getSimpleRule();
const rule2 = getSimpleRuleUpdate();
delete rule2.rule_id;
rule2.id = 'b3aa019a-656c-4311-b13b-4d9852e24347';
rule2.name = 'some other name';
Expand Down
Loading

0 comments on commit 4953082

Please sign in to comment.