Skip to content

Commit

Permalink
[8.x] [Security Solution] Support for kibana spaces in openapi genera…
Browse files Browse the repository at this point in the history
…ted securitySolutionApi service for integration tests (#194029) (#194400)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] Support for kibana spaces in openapi generated
securitySolutionApi service for integration tests
(#194029)](#194029)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tiago Vila
Verde","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-26T17:53:25Z","message":"[Security
Solution] Support for kibana spaces in openapi generated
securitySolutionApi service for integration tests (#194029)\n\n###
Summary\r\n\r\nThis PR adds support for Kibana Spaces in the
generated\r\n`securitySolutionApi` service for integration
tests.\r\n\r\nUsers can now pass an extra parameter `kibanaSpace` when
calling a route\r\nfrom the service. The provided space will be prefixed
to the API's path.\r\nIf no argument is provided, it is default'ed to
`'default'`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"2f45c90d2f58e9f0e3b5ff90f7cbece482478c00","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","v8.16.0"],"number":194029,"url":"https://github.com/elastic/kibana/pull/194029","mergeCommit":{"message":"[Security
Solution] Support for kibana spaces in openapi generated
securitySolutionApi service for integration tests (#194029)\n\n###
Summary\r\n\r\nThis PR adds support for Kibana Spaces in the
generated\r\n`securitySolutionApi` service for integration
tests.\r\n\r\nUsers can now pass an extra parameter `kibanaSpace` when
calling a route\r\nfrom the service. The provided space will be prefixed
to the API's path.\r\nIf no argument is provided, it is default'ed to
`'default'`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"2f45c90d2f58e9f0e3b5ff90f7cbece482478c00"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194029","number":194029,"mergeCommit":{"message":"[Security
Solution] Support for kibana spaces in openapi generated
securitySolutionApi service for integration tests (#194029)\n\n###
Summary\r\n\r\nThis PR adds support for Kibana Spaces in the
generated\r\n`securitySolutionApi` service for integration
tests.\r\n\r\nUsers can now pass an extra parameter `kibanaSpace` when
calling a route\r\nfrom the service. The provided space will be prefixed
to the API's path.\r\nIf no argument is provided, it is default'ed to
`'default'`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"2f45c90d2f58e9f0e3b5ff90f7cbece482478c00"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
tiansivive and kibanamachine authored Sep 30, 2024
1 parent a5b2d04 commit 7ba0966
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '
import { replaceParams } from '@kbn/openapi-common/shared';
import { FtrProviderContext } from 'x-pack/test/api_integration/ftr_provider_context';

import { routeWithNamespace } from 'x-pack/test/common/utils/security_solution';

{{#each operations}}
import {
{{operationId}}RequestQueryInput,
Expand All @@ -29,9 +31,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
* {{{description}}}
*/
{{/if}}
{{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props{{/if}}) {
{{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props, {{/if}}kibanaSpace: string = 'default') {
return supertest
.{{method}}({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}})
.{{method}}(routeWithNamespace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace))
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '{{version}}')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
Expand Down
Loading

0 comments on commit 7ba0966

Please sign in to comment.