mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Fix rbac test (#22912)
* 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:
parent
6ce47520ad
commit
4f26340c28
5 changed files with 19 additions and 7 deletions
|
@ -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}`);
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.');
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue