Skip to content

Commit

Permalink
Fix rbac test (#22912) (#22935)
Browse files Browse the repository at this point in the history
* conditionalize Monitoring tests for Cloud testing

* make security_page/login wait

* revert these files from another PR

* revert these files from another PR
  • Loading branch information
Lee Drengenberg committed Sep 11, 2018
1 parent cf95d1d commit db74ea2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
11 changes: 9 additions & 2 deletions test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`);
}
});
}


Expand All @@ -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}`);
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/security/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/security/rbac_phase1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/security/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
});
Expand Down
7 changes: 6 additions & 1 deletion x-pack/test/functional/page_objects/security_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit db74ea2

Please sign in to comment.