Skip to content

Commit

Permalink
configurable test users for xpack -homepage tests. (elastic#60808)
Browse files Browse the repository at this point in the history
* configurable test users for xpack

* removed exclusive tests

* added data-test-subj for the access denied page

* updated the JEST snapshot, cleaned up the test

* changes to the test_api_keys role

* more changes to consolidate the page object function

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
rashmivkulkarni and elasticmachine committed Mar 26, 2020
1 parent c13993e commit 8237b34
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const PermissionDenied = () => (
<EuiEmptyPrompt
iconType="securityApp"
title={
<h2>
<h2 data-test-subj="apiKeysPermissionDeniedMessage">
<FormattedMessage
id="xpack.security.management.apiKeys.deniedPermissionTitle"
defaultMessage="You need permission to manage API keys"
Expand Down
17 changes: 15 additions & 2 deletions x-pack/test/functional/apps/api_keys/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,31 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'apiKeys']);
const log = getService('log');
const security = getService('security');

describe('Home page', function() {
this.tags('smoke');
before(async () => {
await security.testUser.setRoles(['kibana_admin']);
await pageObjects.common.navigateToApp('apiKeys');
});

after(async () => {
await security.testUser.restoreDefaults();
});

// https://www.elastic.co/guide/en/kibana/7.6/api-keys.html#api-keys-security-privileges
it('Shows required privileges ', async () => {
log.debug('Checking for required privileges method section header');
const message = await pageObjects.apiKeys.apiKeysPermissionDeniedMessage();
expect(message).to.be('You need permission to manage API keys');
});

it('Loads the app', async () => {
await security.testUser.setRoles(['test_api_keys']);
log.debug('Checking for section header');
const headerText = await (await pageObjects.apiKeys.noAPIKeysHeading()).getVisibleText();
const headerText = await pageObjects.apiKeys.noAPIKeysHeading();
expect(headerText).to.be('No API keys');

const goToConsoleButton = await pageObjects.apiKeys.getGoToConsoleButton();
expect(await goToConsoleButton.isDisplayed()).to.be(true);
});
Expand Down
15 changes: 15 additions & 0 deletions x-pack/test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ export default async function({ readConfigFile }) {
},
kibana: [],
},

//Kibana feature privilege isn't specific to advancedSetting. It can be anything. https://github.com/elastic/kibana/issues/35965
test_api_keys: {
elasticsearch: {
cluster: ['manage_security', 'manage_api_key'],
},
kibana: [
{
feature: {
advancedSettings: ['read'],
},
spaces: ['default'],
},
],
},
},
defaultRoles: ['superuser'],
},
Expand Down
7 changes: 6 additions & 1 deletion x-pack/test/functional/page_objects/api_keys_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ export function ApiKeysPageProvider({ getService }: FtrProviderContext) {

return {
async noAPIKeysHeading() {
return await testSubjects.find('noApiKeysHeader');
return await testSubjects.getVisibleText('noApiKeysHeader');
},

async getGoToConsoleButton() {
return await testSubjects.find('goToConsoleButton');
},

async apiKeysPermissionDeniedMessage() {
return await testSubjects.getVisibleText('apiKeysPermissionDeniedMessage');
},
};
}

0 comments on commit 8237b34

Please sign in to comment.