Commit 5e74b4c
authored
[Scout] Remove custom role deletion the
This PR removes the custom role deletion logic from the `requestAuth`
fixture (used by Scout API tests to request an API key). Custom roles
will still be deleted in the `samlAuth` fixture. We were attempting to
delete the custom role in two places instead of one.
### Context
Currently, a bug in the Scout API tests causes the custom role to be
deleted twice: once [in the `requestAuth`
fixture](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-scout/src/playwright/fixtures/scope/worker/api_key.ts#L169-L178)
and again [in the `samlAuth`
fixture](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-scout/src/playwright/fixtures/scope/worker/core_fixtures.ts#L186-L198).
We should ensure the custom role is deleted only **once**, ideally
within the `samlAuth` fixture, to align with the behavior in UI tests.
This issue specifically affects Scout API tests that use the
`requestAuth` fixture.
### How to test
First, enable `debug` Scout logs in you local environment:
```
export SCOUT_LOG_LEVEL=debug
```
Start the servers:
```
node scripts/scout.js start-server --stateful
```
In a separate terminal run some Scout API tests:
```
npx playwright test x-pack/platform/plugins/private/painless_lab/test/scout/api/tests/execute_api_custom_cluster_privileges.spec.ts --config x-pack/platform/plugins/private/painless_lab/test/scout/api/playwright.config.ts --project local
```
Notice the custom role is deleted just once:
```
Running 4 tests using 1 worker
[local] › x-pack/platform/plugins/private/painless_lab/test/scout/api/tests/execute_api_custom_cluster_privileges.spec.ts:15:12 › POST api/painless_lab/execute with specific cluster privileges › should execute a valid painless script using cluster:admin/scripts/painless/execute credentials @ess
info [scout-worker] Created API key for custom_role_worker_1 role: myTestApiKey-0-custom_role_worker_1-worker-1
[local] › x-pack/platform/plugins/private/painless_lab/test/scout/api/tests/execute_api_custom_cluster_privileges.spec.ts:38:12 › POST api/painless_lab/execute with specific cluster privileges › should execute a valid painless script using cluster:admin credentials @ess
info [scout-worker] Created API key for custom_role_worker_1 role: myTestApiKey-1-custom_role_worker_1-worker-1
[local] › x-pack/platform/plugins/private/painless_lab/test/scout/api/tests/execute_api_custom_cluster_privileges.spec.ts:60:12 › POST api/painless_lab/execute with specific cluster privileges › should return an unauthorized status code when using monitor cluster credentials @ess
info [scout-worker] Created API key for custom_role_worker_1 role: myTestApiKey-2-custom_role_worker_1-worker-1
[local] › x-pack/platform/plugins/private/painless_lab/test/scout/api/tests/execute_api_custom_cluster_privileges.spec.ts:79:12 › POST api/painless_lab/execute with specific cluster privileges › should return an unauthorized status code when using both cluster and Kibana privileges @ess
info [scout-worker] Created API key for custom_role_worker_1 role: myTestApiKey-3-custom_role_worker_1-worker-1
info [scout-worker] Invalidated API key: myTestApiKey-0-custom_role_worker_1-worker-1
info [scout-worker] Invalidated API key: myTestApiKey-1-custom_role_worker_1-worker-1
info [scout-worker] Invalidated API key: myTestApiKey-2-custom_role_worker_1-worker-1
info [scout-worker] Invalidated API key: myTestApiKey-3-custom_role_worker_1-worker-1
info [scout-worker] Deleting custom role custom_role_worker_1
info [scout-worker] Custom role 'custom_role_worker_1' deleted
4 passed (9.5s)
```
Without this change, you would see an error (because we were attempting
to delete the custom role twice):
```
info [scout-worker] Deleted custom_role_worker_1 custom role
ERROR [scout-worker] Failed to delete custom role 'custom_role_worker_1' during worker cleanup: {"found":false}
4 passed (11.0s)
```requestAuth fixture (so it is deleted just once in samlAuth) (#244462)1 parent a7f8bb6 commit 5e74b4c
File tree
1 file changed
+2
-15
lines changed1 file changed
+2
-15
lines changedLines changed: 2 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
50 | | - | |
| 48 | + | |
51 | 49 | | |
52 | | - | |
53 | 50 | | |
54 | 51 | | |
55 | 52 | | |
| |||
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
151 | | - | |
152 | | - | |
153 | 148 | | |
154 | 149 | | |
155 | 150 | | |
| |||
166 | 161 | | |
167 | 162 | | |
168 | 163 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 164 | + | |
178 | 165 | | |
179 | 166 | | |
180 | 167 | | |
| |||
0 commit comments