Skip to content

Commit 34be0cd

Browse files
[Synthetics] Migrate obs security api_keys FTR test to Scout API
Ports `x-pack/solutions/observability/test/api_integration/apis/security` (API key creation with synthetics-service ES privileges + uptime feature) to a Scout API spec in the synthetics suite, and removes the standalone FTR config along with its Buildkite manifest and CODEOWNERS entries. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a067907 commit 34be0cd

7 files changed

Lines changed: 94 additions & 88 deletions

File tree

.buildkite/ftr-manifests/ftr_oblt_stateful_configs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ enabled:
3535
- x-pack/solutions/observability/test/functional/apps/apm/config.ts
3636
- x-pack/solutions/observability/test/functional_with_es_ssl/config.ts
3737
- x-pack/solutions/observability/test/api_integration/apis/cases/config.ts
38-
- x-pack/solutions/observability/test/api_integration/apis/security/config.ts
3938
- x-pack/solutions/observability/test/accessibility/config.ts
4039
- x-pack/solutions/observability/test/functional/apps/infra/config.ts
4140
- x-pack/solutions/observability/test/functional/config.firefox.ts

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,6 @@ x-pack/platform/plugins/shared/streams/common/sig_events_tuning_config.ts @elast
19191919
/x-pack/solutions/observability/test/accessibility/apps/observability.ts @elastic/actionable-obs-team
19201920
/x-pack/solutions/observability/test/functional/services/slo/ @elastic/actionable-obs-team
19211921
/x-pack/solutions/observability/test/observability_functional @elastic/actionable-obs-team
1922-
/x-pack/solutions/observability/test/api_integration/apis/security/ @elastic/actionable-obs-team
19231922
/x-pack/solutions/observability/plugins/infra/public/alerting @elastic/actionable-obs-team
19241923
/x-pack/solutions/observability/plugins/infra/server/lib/alerting @elastic/actionable-obs-team
19251924
/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/alerting/ @elastic/actionable-obs-team

x-pack/solutions/observability/plugins/synthetics/test/scout/.meta/api/standard.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
{
2-
"sha1": "38069c93eb2ea0f612e27c7486f67a9c6eb65af1",
2+
"sha1": "2c9bd37f28a7c69ee2f5e6eb8f85da935f64e8cf",
33
"tests": [
4+
{
5+
"id": "8ac308de9d7a2bf-019801460b8f6ef",
6+
"title": "ApiKeys [POST] internal/security/api_key allows an API key to be created with kibana privileges",
7+
"expectedStatus": "passed",
8+
"tags": [
9+
"@local-stateful-classic"
10+
],
11+
"location": {
12+
"file": "x-pack/solutions/observability/plugins/synthetics/test/scout/api/tests/api_keys.spec.ts",
13+
"line": 50,
14+
"column": 10
15+
}
16+
},
417
{
518
"id": "1592a89c4ddba37-f51682f5b9fe1da",
619
"title": "getMonitorFilters get list of filters (empty)",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { expect } from '@kbn/scout-oblt/api';
9+
import { apiTest, KIBANA_HEADERS } from '../fixtures';
10+
11+
/**
12+
* Ported from FTR
13+
* `x-pack/solutions/observability/test/api_integration/apis/security/api_keys.ts`.
14+
*
15+
* Verifies a privileged user can create an API key whose role descriptors carry
16+
* the synthetics-service Elasticsearch privileges plus the uptime feature. Drives
17+
* the *internal* security route, so it uses cookie-based auth
18+
* (`samlAuth.asInteractiveUser('admin')` + `KIBANA_HEADERS`), matching the
19+
* `synthetics_enablement` spec.
20+
*
21+
* The Elasticsearch privileges mirror `getServiceApiKeyPrivileges(false)` from
22+
* `@kbn/synthetics-plugin/server/synthetics_service/get_api_key`; we inline them
23+
* here (and use `'*'` for `ALL_SPACES_ID`) to avoid importing across the plugin
24+
* server boundary, matching the local-constants convention in this Scout suite.
25+
*
26+
* Tagged stateful-only to preserve the original FTR scope: the legacy `uptime`
27+
* feature privilege and the stateful-only `read_ilm` cluster privilege are not
28+
* meaningful in the serverless observability target.
29+
*/
30+
31+
const SYNTHETICS_SERVICE_ES_PRIVILEGES = {
32+
cluster: ['monitor', 'read_pipeline', 'read_ilm'],
33+
indices: [
34+
{
35+
names: ['synthetics-*'],
36+
privileges: ['view_index_metadata', 'create_doc', 'auto_configure', 'read'],
37+
},
38+
],
39+
run_as: [],
40+
} as const;
41+
42+
apiTest.describe('ApiKeys', { tag: ['@local-stateful-classic'] }, () => {
43+
let adminHeaders: Record<string, string>;
44+
45+
apiTest.beforeAll(async ({ samlAuth }) => {
46+
const { cookieHeader } = await samlAuth.asInteractiveUser('admin');
47+
adminHeaders = { ...KIBANA_HEADERS, ...cookieHeader };
48+
});
49+
50+
apiTest(
51+
'[POST] internal/security/api_key allows an API key to be created with kibana privileges',
52+
async ({ apiClient }) => {
53+
const res = await apiClient.post('internal/security/api_key', {
54+
headers: adminHeaders,
55+
body: {
56+
name: 'test_api_key',
57+
expiration: '12d',
58+
kibana_role_descriptors: {
59+
uptime_save: {
60+
elasticsearch: SYNTHETICS_SERVICE_ES_PRIVILEGES,
61+
kibana: [
62+
{
63+
base: [],
64+
spaces: ['*'],
65+
feature: {
66+
uptime: ['all'],
67+
},
68+
},
69+
],
70+
},
71+
},
72+
},
73+
responseType: 'json',
74+
});
75+
76+
expect(res).toHaveStatusCode(200);
77+
expect(res.body).toMatchObject({ name: 'test_api_key' });
78+
}
79+
);
80+
});

x-pack/solutions/observability/test/api_integration/apis/security/api_keys.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

x-pack/solutions/observability/test/api_integration/apis/security/config.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

x-pack/solutions/observability/test/api_integration/apis/security/index.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)