-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Spaces] Add Scout tests around using Saved Objects API in different spaces #244323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| fleet: FleetApiService; | ||
| streams: StreamsApiService; | ||
| core: CoreApiService; | ||
| savedObjects: SavedObjectsApiService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a new savedObjects API helper that can be used within Scout tests to perform common Saved Object operations.
While API helpers are fine for setup and teardown operations, in the test body we should use the apiClient fixture to send API requests scoped to the role/privileges of our choice (in this case, the savedObjectsManagement privilege).
| } | ||
| ); | ||
| }, | ||
| delete: async (type, id, spaceId, force) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware that many of these Saved Object operations are deprecated, except for import/export APIs (and a few others). I have however decided to add most operations to the interface for convenience, as I don't believe there are any plans to remove these anytime soon.
| * Note: since version 8.0, Kibana requires most saved objects to have globally unique IDs | ||
| * Learn more: https://www.elastic.co/docs/explore-analyze/find-and-organize/saved-objects | ||
| */ | ||
| TEST_SPACES.forEach((space) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment says, this test suite validates api/saved_objects/_import behavior when operating within a single space at a time to ensure consistent behavior regardless of the space we're in. Each test suite creates just one space.
| import { ATTRIBUTE_TITLE_KEY, ATTRIBUTE_TITLE_VALUE, COMMON_HEADERS, SPACES } from './constants'; | ||
| import { prepareImportFormData } from './helpers'; | ||
|
|
||
| apiTest.describe(`_import API with multiple spaces`, { tag: tags.ESS_ONLY }, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment above says, this test suite creates multiple spaces at the same time to test the Saved Object APIs across multiple spaces (see test cases for details).
| { | ||
| base: [], | ||
| feature: { | ||
| savedObjectsManagement: ['all'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both test suites we're creating an API key with the minimum privilege necessary to call the Saved Objects API: savedObjectsManagement: ['all'].
| export interface SavedObjectsApiService { | ||
| // Note: the create and bulk create operations are deprecated in favor of the import API so they weren't added to the API helper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elastic/kibana-security we would appreciate if you can verify helpers implementation to make sure we didn't do anything wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up here to say I was able to leverage the kbnClient.savedObects helper just fine, and I have removed the Saved Objects API service that the PR introduced.
💔 Build Failed
Failed CI StepsHistory
cc @csr |
This PR migrates FTR tests belonging to the
x-pack/platform/test/saved_object_api_integration/spaces_only/config.tsFTR test config to Scout. The "Spaces Only" test suite validates Saved Objects API behavior in a multi-space Kibana environment.This suite focuses purely on space isolation and namespace behavior, testing how objects are created, retrieved, updated, and deleted across different Kibana spaces.
Important
Deprecated Saved API operations: most Saved Object API operations are deprecated so they aren't used in the new Scout tests, except for the bulk delete operation. The import and export APIs aren't deprecated so these tests focus especially on those.