-
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.
[9.0] [Siem Migration] - Start/Stop Translation integration tests (#2…
…12030) (#213221) # Backport This will backport the following commits from `main` to `9.0`: - [[Siem Migration] - Start/Stop Translation integration tests (#212030)](#212030) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jatin Kathuria","email":"jatin.kathuria@elastic.co"},"sourceCommit":{"committedDate":"2025-03-05T11:06:06Z","message":"[Siem Migration] - Start/Stop Translation integration tests (#212030)\n\n## Summary\n\nHandles\n- https://github.com/elastic/security-team/issues/11232\n\nThis PR adds the integration tests for \n- Start Translation API\n- Stop Translation API","sha":"4998b75677557f4781b94bd58cf04eae118943d6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Siem Migration] - Start/Stop Translation integration tests","number":212030,"url":"https://github.com/elastic/kibana/pull/212030","mergeCommit":{"message":"[Siem Migration] - Start/Stop Translation integration tests (#212030)\n\n## Summary\n\nHandles\n- https://github.com/elastic/security-team/issues/11232\n\nThis PR adds the integration tests for \n- Start Translation API\n- Stop Translation API","sha":"4998b75677557f4781b94bd58cf04eae118943d6"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212030","number":212030,"mergeCommit":{"message":"[Siem Migration] - Start/Stop Translation integration tests (#212030)\n\n## Summary\n\nHandles\n- https://github.com/elastic/security-team/issues/11232\n\nThis PR adds the integration tests for \n- Start Translation API\n- Stop Translation API","sha":"4998b75677557f4781b94bd58cf04eae118943d6"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Jatin Kathuria <jatin.kathuria@elastic.co>
- Loading branch information
1 parent
3bf69b0
commit f62e695
Showing
10 changed files
with
288 additions
and
6 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
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
127 changes: 127 additions & 0 deletions
127
...on_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/start.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,127 @@ | ||
/* | ||
* 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 { v4 as uuidv4 } from 'uuid'; | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../ftr_provider_context'; | ||
import { | ||
SiemMigrationsAPIErrorResponse, | ||
defaultOriginalRule, | ||
migrationRulesRouteHelpersFactory, | ||
} from '../../utils'; | ||
|
||
export default ({ getService }: FtrProviderContext) => { | ||
const supertest = getService('supertest'); | ||
const migrationRulesRoutes = migrationRulesRouteHelpersFactory(supertest); | ||
|
||
describe('Start Migration', () => { | ||
let migrationId: string; | ||
beforeEach(async () => { | ||
migrationId = uuidv4(); | ||
await migrationRulesRoutes.create({ | ||
migrationId, | ||
payload: [defaultOriginalRule], | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
await migrationRulesRoutes.stop({ migrationId }); | ||
}); | ||
it('should start migration successfully', async () => { | ||
const response = await migrationRulesRoutes.start({ | ||
migrationId, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
|
||
expect(response.body).to.eql({ started: true }); | ||
}); | ||
|
||
it('should return status of running migration correctly ', async () => { | ||
await migrationRulesRoutes.start({ | ||
migrationId, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
|
||
const response = await migrationRulesRoutes.stats({ migrationId }); | ||
|
||
expect(response.body).keys('status', 'rules', 'id', 'created_at', 'last_updated_at'); | ||
|
||
expect(response.body.rules).to.eql({ | ||
completed: 0, | ||
failed: 0, | ||
pending: 1, | ||
processing: 0, | ||
total: 1, | ||
}); | ||
|
||
expect(response.body.status).to.equal('running'); | ||
expect(response.body.id).to.equal(migrationId); | ||
}); | ||
|
||
it('should return started false for already running migration', async () => { | ||
await migrationRulesRoutes.start({ | ||
migrationId, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
|
||
const response = await migrationRulesRoutes.start({ | ||
migrationId, | ||
expectStatusCode: 200, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
|
||
expect(response.body).to.eql({ started: false }); | ||
}); | ||
|
||
describe('error scenarios', () => { | ||
it('should reject if connector_id is incorrect', async () => { | ||
const response = await migrationRulesRoutes.start({ | ||
migrationId: 'invalid_migration_id', | ||
expectStatusCode: 400, | ||
payload: { | ||
connector_id: 'preconfigured_bedrock', | ||
}, | ||
}); | ||
|
||
expect((response.body as unknown as SiemMigrationsAPIErrorResponse).message).to.eql( | ||
'Saved object [action/preconfigured_bedrock] not found' | ||
); | ||
}); | ||
|
||
it('should reject if connector_id is not provided', async () => { | ||
const response = await migrationRulesRoutes.start({ | ||
migrationId, | ||
expectStatusCode: 400, | ||
payload: { | ||
// @ts-expect-error | ||
connector_id: undefined, | ||
}, | ||
}); | ||
expect((response.body as unknown as SiemMigrationsAPIErrorResponse).message).to.eql( | ||
'[request body]: connector_id: Required' | ||
); | ||
}); | ||
|
||
it('should reject with 404 if migrationId is not found', async () => { | ||
await migrationRulesRoutes.start({ | ||
migrationId: 'invalid_migration_id', | ||
expectStatusCode: 404, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; |
67 changes: 67 additions & 0 deletions
67
...ion_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/stop.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,67 @@ | ||
/* | ||
* 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 { v4 as uuidv4 } from 'uuid'; | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../ftr_provider_context'; | ||
import { defaultOriginalRule, migrationRulesRouteHelpersFactory } from '../../utils'; | ||
|
||
export default ({ getService }: FtrProviderContext) => { | ||
const supertest = getService('supertest'); | ||
const migrationRulesRoutes = migrationRulesRouteHelpersFactory(supertest); | ||
|
||
describe('Stop Migration', () => { | ||
let migrationId: string; | ||
beforeEach(async () => { | ||
migrationId = uuidv4(); | ||
await migrationRulesRoutes.create({ | ||
migrationId, | ||
payload: [defaultOriginalRule], | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
await migrationRulesRoutes.stop({ migrationId }); | ||
}); | ||
it('should stop a running migration successfully', async () => { | ||
// start migration | ||
const { body } = await migrationRulesRoutes.start({ | ||
migrationId, | ||
payload: { | ||
connector_id: 'preconfigured-bedrock', | ||
}, | ||
}); | ||
expect(body).to.eql({ started: true }); | ||
|
||
// check if it running correctly | ||
let statsResponse = await migrationRulesRoutes.stats({ migrationId }); | ||
expect(statsResponse.body.status).to.eql('running'); | ||
|
||
// Stop Migration | ||
const response = await migrationRulesRoutes.stop({ migrationId }); | ||
expect(response.body).to.eql({ stopped: true }); | ||
|
||
// check if the migration is stopped | ||
statsResponse = await migrationRulesRoutes.stats({ migrationId }); | ||
expect(statsResponse.body.status).to.eql('ready'); | ||
}); | ||
describe('error scenarios', () => { | ||
it('should return 404 if migration id is invalid and non-existent', async () => { | ||
await migrationRulesRoutes.start({ | ||
migrationId: 'invalid_migration_id', | ||
expectStatusCode: 404, | ||
payload: { connector_id: 'preconfigured-bedrock' }, | ||
}); | ||
}); | ||
|
||
it('should return correct output when migration is not even running', async () => { | ||
const stopResponse = await migrationRulesRoutes.stop({ migrationId }); | ||
|
||
expect(stopResponse.body).to.eql({ stopped: true }); | ||
}); | ||
}); | ||
}); | ||
}; |
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