-
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.
Browse files
Browse the repository at this point in the history
# Backport This will backport the following commits from `main` to `8.x`: - [[Automatic Import] Add more FTR tests (#203772)](#203772) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Bharat Pasupula","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-12T04:58:59Z","message":"[Automatic Import] Add more FTR tests (#203772)","sha":"0f160ab61637fb78737cf0cdfe16743bebdb8dd4","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:Security-Scalability","Feature:AutomaticImport"],"title":"[Automatic Import] Add more FTR tests","number":203772,"url":"https://github.com/elastic/kibana/pull/203772","mergeCommit":{"message":"[Automatic Import] Add more FTR tests (#203772)","sha":"0f160ab61637fb78737cf0cdfe16743bebdb8dd4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203772","number":203772,"mergeCommit":{"message":"[Automatic Import] Add more FTR tests (#203772)","sha":"0f160ab61637fb78737cf0cdfe16743bebdb8dd4"}}]}] BACKPORT--> Co-authored-by: Bharat Pasupula <[email protected]>
- Loading branch information
1 parent
9694327
commit 8c7e4e4
Showing
16 changed files
with
285 additions
and
11 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
15 changes: 15 additions & 0 deletions
15
x-pack/test/automatic_import_api_integration/apis/config_graphs.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,15 @@ | ||
/* | ||
* 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 { createTestConfig } from '../common/config'; | ||
|
||
export default createTestConfig('apis', { | ||
license: 'trial', | ||
ssl: true, | ||
testFiles: [require.resolve('./tests/graphs')], | ||
publicBaseUrl: 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
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
67 changes: 67 additions & 0 deletions
67
x-pack/test/automatic_import_api_integration/apis/tests/graphs/categorization.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 expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postCategorization } from '../../../common/lib/api/categorization'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run categorization', () => { | ||
it('should get 400 when trying to run categorization with invalid json', async () => { | ||
const response = await postCategorization({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run categorization without connector action', async () => { | ||
const response = await postCategorization({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
65 changes: 65 additions & 0 deletions
65
x-pack/test/automatic_import_api_integration/apis/tests/graphs/ecs_mapping.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,65 @@ | ||
/* | ||
* 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 '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postEcsMapping } from '../../../common/lib/api/ecs'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run ecs_mapping', () => { | ||
it('should get 400 when trying to run ecs_mapping with invalid json', async () => { | ||
const response = await postEcsMapping({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run ecs_mapping without connector action', async () => { | ||
const response = await postEcsMapping({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
33 changes: 33 additions & 0 deletions
33
x-pack/test/automatic_import_api_integration/apis/tests/graphs/index.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,33 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../../common/ftr_provider_context'; | ||
import { | ||
createUsersAndRoles, | ||
deleteUsersAndRoles, | ||
activateUserProfiles, | ||
} from '../../../common/lib/authentication'; | ||
|
||
export default ({ loadTestFile, getService }: FtrProviderContext): void => { | ||
describe('Automatic Import enabled: basic', function () { | ||
before(async () => { | ||
await createUsersAndRoles(getService); | ||
// once a user profile is created the only way to remove it is to delete the user and roles, so best to activate | ||
// before all the tests | ||
await activateUserProfiles(getService); | ||
}); | ||
|
||
after(async () => { | ||
await deleteUsersAndRoles(getService); | ||
}); | ||
|
||
// Basic | ||
loadTestFile(require.resolve('./ecs_mapping')); | ||
loadTestFile(require.resolve('./categorization')); | ||
loadTestFile(require.resolve('./related')); | ||
}); | ||
}; |
67 changes: 67 additions & 0 deletions
67
x-pack/test/automatic_import_api_integration/apis/tests/graphs/related.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 expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postRelated } from '../../../common/lib/api/related'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run related', () => { | ||
it('should get 400 when trying to run related with invalid json', async () => { | ||
const response = await postRelated({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run related without connector action', async () => { | ||
const response = await postRelated({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
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
Oops, something went wrong.