Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 24, 2020
1 parent 42305b4 commit eb8b906
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@
*/

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

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

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

after(async () => {
await tearDownUsers(securityService);
await esArchiver.unload('empty_kibana');
await tearDown(getService);
});

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

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

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

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

after(async () => {
await tearDownUsers(securityService);
await esArchiver.unload('empty_kibana');
await tearDown(getService);
});

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

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

after(async () => {
await tearDownUsers(securityService);
await esArchiver.unload('empty_kibana');
await tearDown(getService);
});

loadTestFile(require.resolve('./find'));
Expand Down
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 @@ -32,7 +32,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) {
}

// FLAKY: https://github.com/elastic/kibana/issues/82804
describe('update', () => {
describe.skip('update', () => {
const objectRemover = new ObjectRemover(supertest);

after(() => objectRemover.removeAll());
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,13 +50,12 @@ 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) {
export default function alertingApiIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('alerting api integration security and spaces enabled', function () {
this.tags('ciGroup5');

Expand Down

0 comments on commit eb8b906

Please sign in to comment.