Skip to content

Commit

Permalink
Fixes Failing test: X-Pack Alerting API Integration Tests.x-pack/test…
Browse files Browse the repository at this point in the history
…/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy·ts - alerting api integration security and spaces enabled Alerts alerts "before all" hook in "alerts" (#84255) (#84572)

* Unskipping update test

* Changing order of tests

* Cleanup

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
ymao1 and kibanamachine authored Dec 1, 2020
1 parent 005fd77 commit b552138
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
*/

import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { setupSpacesAndUsers, tearDown } from '..';

// eslint-disable-next-line import/no-default-export
export default function actionsTests({ loadTestFile, getService }: FtrProviderContext) {
describe('Actions', () => {
before(async () => {
await setupSpacesAndUsers(getService);
});

after(async () => {
await tearDown(getService);
});

loadTestFile(require.resolve('./builtin_action_types/email'));
loadTestFile(require.resolve('./builtin_action_types/es_index'));
loadTestFile(require.resolve('./builtin_action_types/es_index_preconfigured'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,50 @@
*/

import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { setupSpacesAndUsers, tearDown } from '..';

// eslint-disable-next-line import/no-default-export
export default function alertingTests({ loadTestFile }: FtrProviderContext) {
export default function alertingTests({ loadTestFile, getService }: FtrProviderContext) {
describe('Alerts', () => {
loadTestFile(require.resolve('./find'));
loadTestFile(require.resolve('./create'));
loadTestFile(require.resolve('./delete'));
loadTestFile(require.resolve('./disable'));
loadTestFile(require.resolve('./enable'));
loadTestFile(require.resolve('./execution_status'));
loadTestFile(require.resolve('./get'));
loadTestFile(require.resolve('./get_alert_state'));
loadTestFile(require.resolve('./get_alert_instance_summary'));
loadTestFile(require.resolve('./list_alert_types'));
loadTestFile(require.resolve('./mute_all'));
loadTestFile(require.resolve('./mute_instance'));
loadTestFile(require.resolve('./unmute_all'));
loadTestFile(require.resolve('./unmute_instance'));
loadTestFile(require.resolve('./update'));
loadTestFile(require.resolve('./update_api_key'));
loadTestFile(require.resolve('./alerts'));
loadTestFile(require.resolve('./event_log'));
describe('legacy alerts', () => {
before(async () => {
await setupSpacesAndUsers(getService);
});

// note that this test will destroy existing spaces
loadTestFile(require.resolve('./rbac_legacy'));
after(async () => {
await tearDown(getService);
});

loadTestFile(require.resolve('./rbac_legacy'));
});

describe('alerts', () => {
before(async () => {
await setupSpacesAndUsers(getService);
});

after(async () => {
await tearDown(getService);
});

loadTestFile(require.resolve('./find'));
loadTestFile(require.resolve('./create'));
loadTestFile(require.resolve('./delete'));
loadTestFile(require.resolve('./disable'));
loadTestFile(require.resolve('./enable'));
loadTestFile(require.resolve('./execution_status'));
loadTestFile(require.resolve('./get'));
loadTestFile(require.resolve('./get_alert_state'));
loadTestFile(require.resolve('./get_alert_instance_summary'));
loadTestFile(require.resolve('./list_alert_types'));
loadTestFile(require.resolve('./mute_all'));
loadTestFile(require.resolve('./mute_instance'));
loadTestFile(require.resolve('./unmute_all'));
loadTestFile(require.resolve('./unmute_instance'));
loadTestFile(require.resolve('./update'));
loadTestFile(require.resolve('./update_api_key'));
loadTestFile(require.resolve('./alerts'));
loadTestFile(require.resolve('./event_log'));
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export default function alertTests({ getService }: FtrProviderContext) {
const es = getService('legacyEs');
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const securityService = getService('security');
const spacesService = getService('spaces');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const esTestIndexTool = new ESTestIndexTool(es, retry);

Expand All @@ -39,7 +37,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
await esArchiver.load('alerts_legacy');
await esTestIndexTool.setup();
await es.indices.create({ index: authorizationIndex });
await setupSpacesAndUsers(spacesService, securityService);
await setupSpacesAndUsers(getService);
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { FtrProviderContext } from '../../common/ftr_provider_context';
import { isCustomRoleSpecification } from '../../common/types';
import { Spaces, Users } from '../scenarios';

export async function setupSpacesAndUsers(
spacesService: ReturnType<FtrProviderContext['getService']>,
securityService: ReturnType<FtrProviderContext['getService']>
) {
export async function setupSpacesAndUsers(getService: FtrProviderContext['getService']) {
const securityService = getService('security');
const spacesService = getService('spaces');

for (const space of Spaces) {
await spacesService.create(space);
}
Expand All @@ -36,7 +36,10 @@ export async function setupSpacesAndUsers(
}
}

export async function tearDownUsers(securityService: ReturnType<FtrProviderContext['getService']>) {
export async function tearDown(getService: FtrProviderContext['getService']) {
const securityService = getService('security');
const esArchiver = getService('esArchiver');

for (const user of Users) {
await securityService.user.delete(user.username);

Expand All @@ -47,30 +50,15 @@ export async function tearDownUsers(securityService: ReturnType<FtrProviderConte
}
}
}

await esArchiver.unload('empty_kibana');
}

// eslint-disable-next-line import/no-default-export
export default function alertingApiIntegrationTests({
loadTestFile,
getService,
}: FtrProviderContext) {
const securityService = getService('security');
const spacesService = getService('spaces');
const esArchiver = getService('esArchiver');

export default function alertingApiIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('alerting api integration security and spaces enabled', function () {
this.tags('ciGroup5');

before(async () => {
await setupSpacesAndUsers(spacesService, securityService);
});

after(async () => {
await tearDownUsers(securityService);

await esArchiver.unload('empty_kibana');
});

loadTestFile(require.resolve('./actions'));
loadTestFile(require.resolve('./alerting'));
});
Expand Down

0 comments on commit b552138

Please sign in to comment.