Fix rbac test (#22912) (#22933)

* conditionalize Monitoring tests for Cloud testing

* make security_page/login wait

* revert these files from another PR

* revert these files from another PR
This commit is contained in:
Lee Drengenberg 2018-09-11 15:15:04 -05:00 committed by GitHub
parent cfd2a8fee8
commit 4b26d3fe3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 7 deletions

View file

@ -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}`);
}

View file

@ -22,7 +22,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',

View file

@ -81,7 +81,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');
log.debug('navigateToApp visualize');
await PageObjects.visualize.navigateToNewVisualization();
@ -103,7 +103,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');
log.debug('navigateToApp visualize');
await PageObjects.visualize.navigateToNewVisualization();

View file

@ -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.');
});

View file

@ -19,7 +19,7 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'header', 'settings', 'home']);
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() {