Skip to content
Merged
Changes from 10 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
25 changes: 21 additions & 4 deletions x-pack/test/functional/apps/api_keys/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,26 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const log = getService('log');
const security = getService('security');
const testSubjects = getService('testSubjects');
const es = getService('es');
const find = getService('find');
const browser = getService('browser');

async function clearAllApiKeys() {
const existingKeys = await es.security.queryApiKeys();
if (existingKeys.count > 0) {
Promise.all(
await existingKeys.api_keys.map(async (key) => {
Comment thread
cuff-links marked this conversation as resolved.
Outdated
await es.security.invalidateApiKey({ ids: [key.id] });
Comment thread
cuff-links marked this conversation as resolved.
Outdated
})
);
} else {
log.debug('No API keys to delete.');
}
}

describe('Home page', function () {
before(async () => {
await clearAllApiKeys();
Comment thread
cuff-links marked this conversation as resolved.
Outdated
await security.testUser.setRoles(['kibana_admin']);
await pageObjects.common.navigateToApp('apiKeys');
});
Expand All @@ -39,8 +54,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('creates API key', function () {
before(async () => {
await security.testUser.setRoles(['kibana_admin']);
await security.testUser.setRoles(['test_api_keys']);
await security.testUser.setRoles(['kibana_admin', 'test_api_keys']);
await pageObjects.common.navigateToApp('apiKeys');

// Delete any API keys created outside of these tests
Expand All @@ -51,6 +65,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.apiKeys.deleteAllApiKeyOneByOne();
});

after(async () => {
await clearAllApiKeys();
Comment thread
cuff-links marked this conversation as resolved.
Outdated
});

it('when submitting form, close dialog and displays new api key', async () => {
const apiKeyName = 'Happy API Key';
await pageObjects.apiKeys.clickOnPromptCreateApiKey();
Expand Down Expand Up @@ -95,8 +113,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('deletes API key(s)', function () {
before(async () => {
await security.testUser.setRoles(['kibana_admin']);
await security.testUser.setRoles(['test_api_keys']);
await security.testUser.setRoles(['kibana_admin', 'test_api_keys']);
await pageObjects.common.navigateToApp('apiKeys');
});

Expand Down