Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rbac test #22912

Merged
merged 4 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented line can be removed.

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 @@ -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();
Expand All @@ -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();
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', '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;
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