Skip to content

Commit

Permalink
[Security Solution] Support for kibana spaces in openapi generated se…
Browse files Browse the repository at this point in the history
…curitySolutionApi service for integration tests (#194029)

### Summary

This PR adds support for Kibana Spaces in the generated
`securitySolutionApi` service for integration tests.

Users can now pass an extra parameter `kibanaSpace` when calling a route
from the service. The provided space will be prefixed to the API's path.
If no argument is provided, it is default'ed to `'default'`

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
tiansivive and kibanamachine authored Sep 26, 2024
1 parent de8c599 commit 2f45c90
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 2f45c90

Please sign in to comment.