diff --git a/test/functional/page_objects/common_page.js b/test/functional/page_objects/common_page.js index f6417438e5137..fe1894828e21e 100644 --- a/test/functional/page_objects/common_page.js +++ b/test/functional/page_objects/common_page.js @@ -56,8 +56,14 @@ export function CommonPageProvider({ getService, getPageObjects }) { }; const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig); - await remote.get(appUrl); - await this.loginIfPrompted(appUrl); + await retry.try(async () => { + log.debug(`navigateToUrl ${appUrl}`); + await remote.get(appUrl); + const currentUrl = await this.loginIfPrompted(appUrl); + if (!currentUrl.includes(appUrl)) { + throw new Error(`expected ${currentUrl}.includes(${appUrl})`); + } + }); } @@ -75,6 +81,7 @@ export function CommonPageProvider({ getService, getPageObjects }) { config.get('servers.kibana.password') ); await remote.setFindTimeout(20000).findByCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide)'); + await remote.get(appUrl); currentUrl = await remote.getCurrentUrl(); log.debug(`Finished login process currentUrl = ${currentUrl}`); } diff --git a/x-pack/test/functional/apps/security/management.js b/x-pack/test/functional/apps/security/management.js index ccd4cdbc6f27a..73c1b348f5094 100644 --- a/x-pack/test/functional/apps/security/management.js +++ b/x-pack/test/functional/apps/security/management.js @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }) { describe('Management', () => { before(async () => { - await PageObjects.security.login('elastic', 'changeme'); + // await PageObjects.security.login('elastic', 'changeme'); await PageObjects.security.initTests(); await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'UTC', diff --git a/x-pack/test/functional/apps/security/rbac_phase1.js b/x-pack/test/functional/apps/security/rbac_phase1.js index 4b444cfbb79dd..3f1dcb162b510 100644 --- a/x-pack/test/functional/apps/security/rbac_phase1.js +++ b/x-pack/test/functional/apps/security/rbac_phase1.js @@ -77,7 +77,7 @@ export default function ({ getService, getPageObjects }) { const toTime = '2015-09-23 18:31:44.000'; const vizName1 = 'Visualization VerticalBarChart'; - log.debug('navigateToApp visualize'); + log.debug('log in as kibanauser with rbac_all role'); await PageObjects.security.login('kibanauser', 'changeme'); await PageObjects.common.navigateToUrl('visualize', 'new'); log.debug('clickVerticalBarChart'); @@ -99,7 +99,7 @@ export default function ({ getService, getPageObjects }) { const toTime = '2015-09-23 18:31:44.000'; const vizName1 = 'Viz VerticalBarChart'; - log.debug('navigateToApp visualize'); + log.debug('log in as kibanareadonly with rbac_read role'); await PageObjects.security.login('kibanareadonly', 'changeme'); await PageObjects.common.navigateToUrl('visualize', 'new'); log.debug('clickVerticalBarChart'); diff --git a/x-pack/test/functional/apps/security/security.js b/x-pack/test/functional/apps/security/security.js index fef30cd573fa7..3cb09a3adf8a4 100644 --- a/x-pack/test/functional/apps/security/security.js +++ b/x-pack/test/functional/apps/security/security.js @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) { }); it('displays message if login fails', async () => { - await PageObjects.security.loginPage.login('wrong-user', 'wrong-password'); + await PageObjects.security.loginPage.login('wrong-user', 'wrong-password', false); const errorMessage = await PageObjects.security.loginPage.getErrorMessage(); expect(errorMessage).to.be('Oops! Error. Try again.'); }); diff --git a/x-pack/test/functional/page_objects/security_page.js b/x-pack/test/functional/page_objects/security_page.js index 4c17eb7437e88..6c1912fd3f6cf 100644 --- a/x-pack/test/functional/page_objects/security_page.js +++ b/x-pack/test/functional/page_objects/security_page.js @@ -19,7 +19,7 @@ export function SecurityPageProvider({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'header', 'settings']); class LoginPage { - async login(username, password) { + async login(username, password, expectSuccess = true) { const [superUsername, superPassword] = config.get('servers.elasticsearch.auth').split(':'); username = username || superUsername; @@ -29,6 +29,11 @@ export function SecurityPageProvider({ getService, getPageObjects }) { await testSubjects.setValue('loginUsername', username); await testSubjects.setValue('loginPassword', password); await testSubjects.click('loginSubmit'); + // wait for either kibanaChrome or loginErrorMessage + if (expectSuccess) { + await remote.setFindTimeout(20000).findByCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide)'); + log.debug(`Finished login process currentUrl = ${await remote.getCurrentUrl()}`); + } } async getErrorMessage() {