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

configurable test users for xpack -homepage tests. #60808

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

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');
rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved
rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved
});

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');
rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved

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