-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] [Detection Engine] Changes find_statuses route HTTP met… (#63508)
* changes http method for find_statuses route from GET to POST * fix test string formatting * update sample shell script for find statuses route * adds e2e test for find statuses
- Loading branch information
Showing
9 changed files
with
100 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; | ||
import { FtrProviderContext } from '../../common/ftr_provider_context'; | ||
import { | ||
createSignalsIndex, | ||
deleteAllAlerts, | ||
deleteSignalsIndex, | ||
deleteAllRulesStatuses, | ||
getSimpleRule, | ||
} from './utils'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default ({ getService }: FtrProviderContext): void => { | ||
const supertest = getService('supertest'); | ||
const es = getService('legacyEs'); | ||
|
||
describe('find_statuses', () => { | ||
beforeEach(async () => { | ||
await createSignalsIndex(supertest); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteSignalsIndex(supertest); | ||
await deleteAllAlerts(es); | ||
await deleteAllRulesStatuses(es); | ||
}); | ||
|
||
it('should return an empty find statuses body correctly if no statuses are loaded', async () => { | ||
const { body } = await supertest | ||
.post(`${DETECTION_ENGINE_RULES_URL}/_find_statuses`) | ||
.set('kbn-xsrf', 'true') | ||
.send({ ids: [] }) | ||
.expect(200); | ||
|
||
expect(body).to.eql({}); | ||
}); | ||
|
||
it('should return a single rule status when a single rule is loaded from a find status with defaults added', async () => { | ||
// add a single rule | ||
const { body: resBody } = await supertest | ||
.post(DETECTION_ENGINE_RULES_URL) | ||
.set('kbn-xsrf', 'true') | ||
.send(getSimpleRule()) | ||
.expect(200); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 1000)).then(async () => { | ||
// query the single rule from _find | ||
const { body } = await supertest | ||
.post(`${DETECTION_ENGINE_RULES_URL}/_find_statuses`) | ||
.set('kbn-xsrf', 'true') | ||
.send({ ids: [resBody.id] }) | ||
.expect(200); | ||
|
||
// expected result for status should be 'going to run' or 'succeeded | ||
expect(['succeeded', 'going to run']).to.contain(body[resBody.id].current_status.status); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters