forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detection Engine] add FTR tests
- Loading branch information
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
x-pack/test/functional/es_archives/signals/legacy_signals_index_non_default_space/data.json
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,12 @@ | ||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "1", | ||
"index": ".siem-signals-another-space-legacy", | ||
"source": { | ||
"@timestamp": "2020-10-10T00:00:00.000Z", | ||
"signal": {} | ||
}, | ||
"type": "_doc" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../test/functional/es_archives/signals/legacy_signals_index_non_default_space/mappings.json
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,29 @@ | ||
{ | ||
"type": "index", | ||
"value": { | ||
"aliases": { | ||
".siem-signals-another-space": { | ||
"is_write_index": false | ||
} | ||
}, | ||
"index": ".siem-signals-another-space-legacy", | ||
"mappings": { | ||
"_meta": { | ||
"version": 1 | ||
}, | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"signal": { "type": "object" } | ||
} | ||
}, | ||
"settings": { | ||
"index": { | ||
"lifecycle": { | ||
"indexing_complete": true | ||
} | ||
} | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
.../alerts/basic_license_essentials_tier/ess_specific_index_logic/migrations/deprecations.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,94 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import type { DeprecationsDetails } from '@kbn/core/server'; | ||
|
||
import { | ||
createAlertsIndex, | ||
deleteAllAlerts, | ||
} from '../../../../../../../../common/utils/security_solution'; | ||
|
||
import { FtrProviderContext } from '../../../../../../../ftr_provider_context'; | ||
|
||
export default ({ getService }: FtrProviderContext): void => { | ||
const esArchiver = getService('esArchiver'); | ||
const supertest = getService('supertest'); | ||
const log = getService('log'); | ||
const es = getService('es'); | ||
|
||
const getDeprecations = async (): Promise<DeprecationsDetails[]> => { | ||
const { body } = await supertest.get('/api/deprecations/').set('kbn-xsrf', 'true').expect(200); | ||
return body.deprecations; | ||
}; | ||
|
||
const getLegacyIndicesDeprecation = async (): Promise<DeprecationsDetails | undefined> => { | ||
const deprecations = await getDeprecations(); | ||
|
||
return deprecations.find(({ title }) => title === 'Found not migrated detection alerts'); | ||
}; | ||
|
||
describe.only('@ess Alerts migration deprecations API', () => { | ||
describe('no siem legacy indices exist', () => { | ||
it('should return empty siem signals deprecation', async () => { | ||
const deprecation = await getLegacyIndicesDeprecation(); | ||
|
||
expect(deprecation).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('siem legacy indices exist', () => { | ||
beforeEach(async () => { | ||
await esArchiver.load('x-pack/test/functional/es_archives/signals/legacy_signals_index'); | ||
await createAlertsIndex(supertest, log); | ||
}); | ||
|
||
afterEach(async () => { | ||
await esArchiver.unload('x-pack/test/functional/es_archives/signals/legacy_signals_index'); | ||
await deleteAllAlerts(supertest, log, es); | ||
}); | ||
|
||
it('should return legacy siem signals deprecation', async () => { | ||
const deprecation = await getLegacyIndicesDeprecation(); | ||
|
||
expect(deprecation?.level).toBe('warning'); | ||
|
||
// ensures space included in manual steps | ||
expect(deprecation?.correctiveActions.manualSteps[1]).toContain( | ||
'Spaces with at least one non-migrated signals index: default.' | ||
); | ||
expect(deprecation?.correctiveActions.manualSteps[2]).toContain( | ||
'Example of migration API calls:' | ||
); | ||
expect(deprecation?.correctiveActions.manualSteps[3]).toContain( | ||
'GET <kibana host>:<port>/api/detection_engine/signals/migration_status?from=1970-01-01T00:00:00.000Z' | ||
); | ||
}); | ||
|
||
describe('multiple spaces', () => { | ||
beforeEach(async () => { | ||
await esArchiver.load( | ||
'x-pack/test/functional/es_archives/signals/legacy_signals_index_non_default_space' | ||
); | ||
}); | ||
|
||
afterEach(async () => { | ||
await esArchiver.unload( | ||
'x-pack/test/functional/es_archives/signals/legacy_signals_index_non_default_space' | ||
); | ||
}); | ||
|
||
it('should return legacy siem signals deprecation with multiple spaces', async () => { | ||
const deprecation = await getLegacyIndicesDeprecation(); | ||
|
||
expect(deprecation?.correctiveActions.manualSteps[1]).toContain('another-space'); | ||
expect(deprecation?.correctiveActions.manualSteps[1]).toContain('default'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; |
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