-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Rbac phase1 functional UI tests #20949
Changes from all commits
39582c9
9b9e71d
e415270
1f98448
90f09e0
ad1582e
fbedc26
94772a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import expect from 'expect.js'; | ||
import { indexBy } from 'lodash'; | ||
export default function ({ getService, getPageObjects }) { | ||
|
||
const PageObjects = getPageObjects(['security', 'settings', 'common', 'visualize', 'header']); | ||
const log = getService('log'); | ||
const esArchiver = getService('esArchiver'); | ||
const remote = getService('remote'); | ||
const kibanaServer = getService('kibanaServer'); | ||
|
||
describe('rbac ', async function () { | ||
before(async () => { | ||
await remote.setWindowSize(1600, 1000); | ||
log.debug('users'); | ||
await esArchiver.loadIfNeeded('logstash_functional'); | ||
log.debug('load kibana index with default index pattern'); | ||
await esArchiver.load('discover'); | ||
await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC', 'defaultIndex': 'logstash-*' }); | ||
await PageObjects.settings.navigateTo(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we shouldn't need to navigate to the settings page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, without navigating to settings page, am unable to adding a role from the management page. I tried removing and it failed on me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, apologies. |
||
await PageObjects.security.clickElasticsearchRoles(); | ||
await PageObjects.security.addRole('rbac_all', { | ||
"kibana": ["all"], | ||
"indices": [{ | ||
"names": [ "logstash-*" ], | ||
"privileges": [ "read", "view_index_metadata" ] | ||
}] | ||
}); | ||
|
||
await PageObjects.security.clickElasticsearchRoles(); | ||
await PageObjects.security.addRole('rbac_read', { | ||
"kibana": ["read"], | ||
"indices": [{ | ||
"names": [ "logstash-*" ], | ||
"privileges": [ "read", "view_index_metadata" ] | ||
}] | ||
}); | ||
await PageObjects.security.clickElasticsearchUsers(); | ||
log.debug('After Add user new: , userObj.userName'); | ||
await PageObjects.security.addUser({ username: 'kibanauser', password: 'changeme', | ||
confirmPassword: 'changeme', fullname: 'kibanafirst kibanalast', | ||
email: '[email protected]', save: true, | ||
roles: ['rbac_all'] }); | ||
log.debug('After Add user: , userObj.userName'); | ||
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username'); | ||
log.debug('actualUsers = %j', users); | ||
log.debug('roles: ', users.kibanauser.roles); | ||
expect(users.kibanauser.roles).to.eql(['rbac_all']); | ||
expect(users.kibanauser.fullname).to.eql('kibanafirst kibanalast'); | ||
expect(users.kibanauser.reserved).to.be(false); | ||
await PageObjects.security.clickElasticsearchUsers(); | ||
log.debug('After Add user new: , userObj.userName'); | ||
await PageObjects.security.addUser({ username: 'kibanareadonly', password: 'changeme', | ||
confirmPassword: 'changeme', fullname: 'kibanareadonlyFirst kibanareadonlyLast', | ||
email: '[email protected]', save: true, | ||
roles: ['rbac_read'] }); | ||
log.debug('After Add user: , userObj.userName'); | ||
const users1 = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username'); | ||
const user = users1.kibanareadonly; | ||
log.debug('actualUsers = %j', users1); | ||
log.debug('roles: ', user.roles); | ||
expect(user.roles).to.eql(['rbac_read']); | ||
expect(user.fullname).to.eql('kibanareadonlyFirst kibanareadonlyLast'); | ||
expect(user.reserved).to.be(false); | ||
await PageObjects.security.logout(); | ||
}); | ||
|
||
|
||
// this is to acertain that all role assigned to the user can perform actions like creating a Visualization | ||
it('rbac all role can save a visualization', async function () { | ||
const fromTime = '2015-09-19 06:31:44.000'; | ||
const toTime = '2015-09-23 18:31:44.000'; | ||
const vizName1 = 'Visualization VerticalBarChart'; | ||
|
||
log.debug('navigateToApp visualize'); | ||
await PageObjects.security.login('kibanauser', 'changeme'); | ||
await PageObjects.common.navigateToUrl('visualize', 'new'); | ||
log.debug('clickVerticalBarChart'); | ||
await PageObjects.visualize.clickVerticalBarChart(); | ||
await PageObjects.visualize.clickNewSearch(); | ||
log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); | ||
await PageObjects.header.setAbsoluteRange(fromTime, toTime); | ||
await PageObjects.visualize.clickGo(); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.visualize.waitForVisualization(); | ||
const success = await PageObjects.visualize.saveVisualization(vizName1); | ||
expect(success).to.be(true); | ||
await PageObjects.security.logout(); | ||
|
||
}); | ||
|
||
it('rbac read only role can not save a visualization', async function () { | ||
const fromTime = '2015-09-19 06:31:44.000'; | ||
const toTime = '2015-09-23 18:31:44.000'; | ||
const vizName1 = 'Viz VerticalBarChart'; | ||
|
||
log.debug('navigateToApp visualize'); | ||
await PageObjects.security.login('kibanareadonly', 'changeme'); | ||
await PageObjects.common.navigateToUrl('visualize', 'new'); | ||
log.debug('clickVerticalBarChart'); | ||
await PageObjects.visualize.clickVerticalBarChart(); | ||
await PageObjects.visualize.clickNewSearch(); | ||
log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); | ||
await PageObjects.header.setAbsoluteRange(fromTime, toTime); | ||
await PageObjects.visualize.clickGo(); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
await PageObjects.visualize.waitForVisualization(); | ||
const success = await PageObjects.visualize.saveVisualization(vizName1); | ||
expect(success).to.be(false); | ||
await PageObjects.security.logout(); | ||
|
||
}); | ||
|
||
after(async function () { | ||
await PageObjects.security.logout(); | ||
}); | ||
|
||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: generally we use a
before
for setup logic, but we're doingexpect
in here, it feels more like a test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, just wanted to make sure the before method did all the set up before the actual test kicked in. Would consider this as a part of set up logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to @LeeDr on this one, I didn't see any
expect
calls in the other functional tests, which is what made me mention it here. The one downside is that the failure reasons when the test fail are going to be rather unclear if just thebefore
fails as we have no context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kobelb I asked @Rasroh to move the role and user creation code from tests (how she originally wrote it) to the before method because we already have other automated tests creating roles and users and didn't want these setup steps to count as additional passing tests when they would actually be duplicates. I realize we care more about getting the test coverage than the count of tests, but it just seemed more fair for it to be in the before method.
I think we should still get acceptable failure information if the expects in the before method fail vs having them in a test. There's debug logging before those expects including showing the list of users.
I asked @Rasroh to change one of the expects in the before so it would fail. Seems like reasonable output;