mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [[security_page] improve force logout (#170227)](https://github.com/elastic/kibana/pull/170227) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2023-11-01T13:45:32Z","message":"[security_page] improve force logout (#170227)\n\n## Summary\r\n\r\nAddressing `forceLogout` flakiness\r\nhttps://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests/builds/370\r\n\r\n```\r\nError: timed out waiting for Waiting for logout to complete\r\n at onFailure (retry_for_truthy.ts:39:13)\r\n at retryForSuccess (retry_for_success.ts:59:13)\r\n at retryForTruthy (retry_for_truthy.ts:27:3)\r\n at RetryService.waitFor (retry.ts:59:5)\r\n at SecurityPageObject.forceLogout (security_page.ts:319:7)\r\n at Object.forceLogout (svl_common_page.ts:95:7)\r\n at Context. (view_case.ts:44:7)\r\n at Object.apply (wrap_function.js:73:16)\r\n```\r\n\r\n<img width=\"1294\" alt=\"image\"\r\nsrc=\"92ff13da
-2c80-4eb7-8b3e-63779fb61075\">\r\n\r\n\r\nFlaky-test-runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3839\r\n200/200","sha":"f21e31acf26e18e76d32cfafb0cfae83f98bd7f5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.12.0","v8.11.1"],"number":170227,"url":"https://github.com/elastic/kibana/pull/170227","mergeCommit":{"message":"[security_page] improve force logout (#170227)\n\n## Summary\r\n\r\nAddressing `forceLogout` flakiness\r\nhttps://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests/builds/370\r\n\r\n```\r\nError: timed out waiting for Waiting for logout to complete\r\n at onFailure (retry_for_truthy.ts:39:13)\r\n at retryForSuccess (retry_for_success.ts:59:13)\r\n at retryForTruthy (retry_for_truthy.ts:27:3)\r\n at RetryService.waitFor (retry.ts:59:5)\r\n at SecurityPageObject.forceLogout (security_page.ts:319:7)\r\n at Object.forceLogout (svl_common_page.ts:95:7)\r\n at Context. (view_case.ts:44:7)\r\n at Object.apply (wrap_function.js:73:16)\r\n```\r\n\r\n<img width=\"1294\" alt=\"image\"\r\nsrc=\"92ff13da
-2c80-4eb7-8b3e-63779fb61075\">\r\n\r\n\r\nFlaky-test-runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3839\r\n200/200","sha":"f21e31acf26e18e76d32cfafb0cfae83f98bd7f5"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170227","number":170227,"mergeCommit":{"message":"[security_page] improve force logout (#170227)\n\n## Summary\r\n\r\nAddressing `forceLogout` flakiness\r\nhttps://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests/builds/370\r\n\r\n```\r\nError: timed out waiting for Waiting for logout to complete\r\n at onFailure (retry_for_truthy.ts:39:13)\r\n at retryForSuccess (retry_for_success.ts:59:13)\r\n at retryForTruthy (retry_for_truthy.ts:27:3)\r\n at RetryService.waitFor (retry.ts:59:5)\r\n at SecurityPageObject.forceLogout (security_page.ts:319:7)\r\n at Object.forceLogout (svl_common_page.ts:95:7)\r\n at Context. (view_case.ts:44:7)\r\n at Object.apply (wrap_function.js:73:16)\r\n```\r\n\r\n<img width=\"1294\" alt=\"image\"\r\nsrc=\"92ff13da
-2c80-4eb7-8b3e-63779fb61075\">\r\n\r\n\r\nFlaky-test-runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3839\r\n200/200","sha":"f21e31acf26e18e76d32cfafb0cfae83f98bd7f5"}},{"branch":"8.11","label":"v8.11.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
This commit is contained in:
parent
1015325669
commit
f65031fd2f
1 changed files with 13 additions and 4 deletions
|
@ -41,6 +41,8 @@ export class SecurityPageObject extends FtrService {
|
|||
private readonly monacoEditor = this.ctx.getService('monacoEditor');
|
||||
private readonly es = this.ctx.getService('es');
|
||||
|
||||
delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
public loginPage = Object.freeze({
|
||||
login: async (username?: string, password?: string, options: LoginOptions = {}) => {
|
||||
if (!(await this.isLoginFormVisible())) {
|
||||
|
@ -316,7 +318,7 @@ export class SecurityPageObject extends FtrService {
|
|||
await this.waitForLoginPage();
|
||||
} else {
|
||||
this.log.debug('Waiting for logout to complete');
|
||||
await this.retry.waitFor('Waiting for logout to complete', async () => {
|
||||
await this.retry.waitFor('logout to complete', async () => {
|
||||
// There are cases when browser/Kibana would like users to confirm that they want to navigate away from the
|
||||
// current page and lose the state (e.g. unsaved changes) via native alert dialog.
|
||||
const alert = await this.browser.getAlert();
|
||||
|
@ -324,12 +326,19 @@ export class SecurityPageObject extends FtrService {
|
|||
await alert.accept();
|
||||
}
|
||||
|
||||
await this.retry.waitFor('URL redirects to finish', async () => {
|
||||
const urlBefore = await this.browser.getCurrentUrl();
|
||||
await this.delay(1000);
|
||||
const urlAfter = await this.browser.getCurrentUrl();
|
||||
return urlAfter === urlBefore;
|
||||
});
|
||||
|
||||
const currentUrl = await this.browser.getCurrentUrl();
|
||||
if (this.config.get('serverless')) {
|
||||
// Logout might trigger multiple redirects, but in the end we expect the Cloud login page
|
||||
this.log.debug('Wait 5 sec for Cloud login page to be displayed');
|
||||
return await this.find.existsByDisplayedByCssSelector('.login-form-password', 5000);
|
||||
return currentUrl.includes('/login') || currentUrl.includes('/projects');
|
||||
} else {
|
||||
return !(await this.browser.getCurrentUrl()).includes('/logout');
|
||||
return !currentUrl.includes('/logout');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue