Skip to content

Commit

Permalink
Moving some tests around
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Sep 7, 2018
1 parent 7fec308 commit bc602b1
Show file tree
Hide file tree
Showing 22 changed files with 116 additions and 118 deletions.
4 changes: 2 additions & 2 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/functional/config.js'),
require.resolve('../test/api_integration/config.js'),
require.resolve('../test/saml_api_integration/config.js'),
require.resolve('../test/spaces_api_integration/spaces_only/config.js'),
require.resolve('../test/spaces_api_integration/security_and_spaces/config.js'),
require.resolve('../test/spaces_api_integration/spaces_only/config'),
require.resolve('../test/spaces_api_integration/security_and_spaces/config'),
require.resolve('../test/saved_object_api_integration/security_and_spaces/config'),
require.resolve('../test/saved_object_api_integration/security_only/config'),
require.resolve('../test/saved_object_api_integration/spaces_only/config'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@
* you may not use this file except in compliance with the Elastic License.
*/

import path from 'path';
import { resolveKibanaPath } from '@kbn/plugin-helpers';
import path from 'path';
import { TestInvoker } from './lib/types';
import { EsProvider } from './services/es';

interface CreateTestConfigOptions {
license: string;
disabledPlugins?: [string];
}

export function createTestConfig(name, { license = 'trial', disabledPlugins = [] } = {}) {

return async function ({ readConfigFile }) {
export function createTestConfig(name: string, options: CreateTestConfigOptions) {
const { license, disabledPlugins = [] } = options;

return async ({ readConfigFile }: TestInvoker) => {
const config = {
kibana: {
api: await readConfigFile(resolveKibanaPath('test/api_integration/config.js')),
functional: await readConfigFile(require.resolve('../../../../test/functional/config.js'))
functional: await readConfigFile(require.resolve('../../../../test/functional/config.js')),
},
xpack: {
api: await readConfigFile(require.resolve('../../api_integration/config.js'))
}
api: await readConfigFile(require.resolve('../../api_integration/config.js')),
},
};

console.log('resolving', require.resolve(`../${name}/apis/`));
return {
testFiles: [require.resolve(`../${name}/apis/`)],
servers: config.xpack.api.get('servers'),
Expand All @@ -40,7 +44,7 @@ export function createTestConfig(name, { license = 'trial', disabledPlugins = []
},

esArchiver: {
directory: path.join(__dirname, 'fixtures', 'es_archiver')
directory: path.join(__dirname, 'fixtures', 'es_archiver'),
},

esTestCluster: {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/spaces_api_integration/common/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export type LoadTestFileFn = (path: string) => string;

export type GetServiceFn = (service: string) => any;

export type ReadConfigFileFn = (path: string) => any;

export interface TestInvoker {
getService: GetServiceFn;
loadTestFile: LoadTestFileFn;
readConfigFile: ReadConfigFileFn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { createTestSuiteFactory } from '../../../common/suites/spaces/create';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { createTestSuiteFactory } from '../../common/suites/spaces/create';

// tslint:disable:no-default-export
export default function createSpacesOnlySuite({ getService }: TestInvoker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { deleteTestSuiteFactory } from '../../../common/suites/spaces/delete';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { deleteTestSuiteFactory } from '../../common/suites/spaces/delete';

// tslint:disable:no-default-export
export default function deleteSpaceTestSuite({ getService }: TestInvoker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { getTestSuiteFactory } from '../../../common/suites/spaces/get';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { getTestSuiteFactory } from '../../common/suites/spaces/get';

// tslint:disable:no-default-export
export default function getSpaceTestSuite({ getService }: TestInvoker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { getAllTestSuiteFactory } from '../../../common/suites/spaces/get_all';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { getAllTestSuiteFactory } from '../../common/suites/spaces/get_all';

// tslint:disable:no-default-export
export default function getAllSpacesTestSuite({ getService }: TestInvoker) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { createUsersAndRoles } from '../../common/lib/create_users_and_roles';
import { TestInvoker } from '../../common/lib/types';

// tslint:disable:no-default-export
export default function({ loadTestFile, getService }: TestInvoker) {
const es = getService('es');
const supertest = getService('supertest');

describe('apis spaces', () => {
before(async () => {
await createUsersAndRoles(es, supertest);
});

loadTestFile(require.resolve('./create'));
loadTestFile(require.resolve('./delete'));
loadTestFile(require.resolve('./get_all'));
loadTestFile(require.resolve('./get'));
loadTestFile(require.resolve('./select'));
loadTestFile(require.resolve('./update'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { selectTestSuiteFactory } from '../../../common/suites/spaces/select';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { selectTestSuiteFactory } from '../../common/suites/spaces/select';

// tslint:disable:no-default-export
export default function selectSpaceTestSuite({ getService }: TestInvoker) {
Expand Down Expand Up @@ -92,7 +92,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
});

selectTest(
`${scenario.userWithReadGlobally.USERNAME} selects ${scenario.otherSpaceId} from
`${scenario.userWithReadGlobally.USERNAME} selects ${scenario.otherSpaceId} from
${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand All @@ -111,7 +111,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
);

selectTest(
`${scenario.userWithDualRead.USERNAME} selects ${scenario.otherSpaceId} from
`${scenario.userWithDualRead.USERNAME} selects ${scenario.otherSpaceId} from
${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand All @@ -130,7 +130,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
);

selectTest(
`${scenario.userWithLegacyRead.USERNAME} can select ${scenario.otherSpaceId}
`${scenario.userWithLegacyRead.USERNAME} can select ${scenario.otherSpaceId}
from ${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand Down Expand Up @@ -165,7 +165,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
},
].forEach(scenario => {
selectTest(
`${scenario.userWithAllAtSpace.USERNAME} can select ${scenario.spaceId}
`${scenario.userWithAllAtSpace.USERNAME} can select ${scenario.spaceId}
from ${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand All @@ -184,7 +184,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
);

selectTest(
`${scenario.userWithReadAtSpace.USERNAME} can select ${scenario.spaceId}
`${scenario.userWithReadAtSpace.USERNAME} can select ${scenario.spaceId}
from ${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand All @@ -203,7 +203,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
);

selectTest(
`${scenario.userWithAllAtOtherSpace.USERNAME} cannot select ${scenario.spaceId}
`${scenario.userWithAllAtOtherSpace.USERNAME} cannot select ${scenario.spaceId}
from ${scenario.spaceId}`,
{
currentSpaceId: scenario.spaceId,
Expand Down Expand Up @@ -233,7 +233,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
},
].forEach(scenario => {
selectTest(
`${scenario.userWithAllAtBothSpaces.USERNAME} can select ${scenario.spaceId}
`${scenario.userWithAllAtBothSpaces.USERNAME} can select ${scenario.spaceId}
from ${scenario.otherSpaceId}`,
{
currentSpaceId: scenario.otherSpaceId,
Expand All @@ -252,7 +252,7 @@ export default function selectSpaceTestSuite({ getService }: TestInvoker) {
);

selectTest(
`${scenario.userWithAllAtOtherSpace.USERNAME} cannot select ${scenario.spaceId}
`${scenario.userWithAllAtOtherSpace.USERNAME} cannot select ${scenario.spaceId}
from ${scenario.otherSpaceId}`,
{
currentSpaceId: scenario.otherSpaceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AUTHENTICATION } from '../../../common/lib/authentication';
import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { updateTestSuiteFactory } from '../../../common/suites/spaces/update';
import { AUTHENTICATION } from '../../common/lib/authentication';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { updateTestSuiteFactory } from '../../common/suites/spaces/update';

// tslint:disable:no-default-export
export default function updateSpaceTestSuite({ getService }: TestInvoker) {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
},
].forEach(scenario => {
updateTest(
`${scenario.userWithAllGlobally.USERNAME} can update space_1 from
`${scenario.userWithAllGlobally.USERNAME} can update space_1 from
the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down Expand Up @@ -88,7 +88,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
);

updateTest(
`${scenario.userWithDualAll.USERNAME} can update space_1 from
`${scenario.userWithDualAll.USERNAME} can update space_1 from
the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down Expand Up @@ -128,7 +128,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
);

updateTest(
`${scenario.userWithLegacyAll.USERNAME} can update space_1 from
`${scenario.userWithLegacyAll.USERNAME} can update space_1 from
the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down Expand Up @@ -168,7 +168,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
);

updateTest(
`${scenario.userWithReadGlobally.USERNAME} cannot update space_1
`${scenario.userWithReadGlobally.USERNAME} cannot update space_1
from the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down Expand Up @@ -203,7 +203,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
);

updateTest(
`${scenario.userWithDualRead.USERNAME} cannot update space_1
`${scenario.userWithDualRead.USERNAME} cannot update space_1
from the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down Expand Up @@ -238,7 +238,7 @@ export default function updateSpaceTestSuite({ getService }: TestInvoker) {
);

updateTest(
`${scenario.userWithLegacyRead.USERNAME} cannot update space_1
`${scenario.userWithLegacyRead.USERNAME} cannot update space_1
from the ${scenario.spaceId} space`,
{
spaceId: scenario.spaceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

import { createTestConfig } from '../common/config';

// tslint:disable:no-default-export
export default createTestConfig('security_and_spaces', { license: 'trial' });
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SPACES } from '../../../common/lib/spaces';
import { TestInvoker } from '../../../common/lib/types';
import { createTestSuiteFactory } from '../../../common/suites/spaces/create';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { createTestSuiteFactory } from '../../common/suites/spaces/create';

// tslint:disable:no-default-export
export default function createSpacesOnlySuite({ getService }: TestInvoker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SPACES } from '../../../common/lib/spaces';
import { deleteTestSuiteFactory } from '../../../common/suites/spaces/delete';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { deleteTestSuiteFactory } from '../../common/suites/spaces/delete';

// tslint:disable:no-default-export
export default function deleteSpaceTestSuite({ getService }) {
export default function deleteSpaceTestSuite({ getService }: TestInvoker) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const esArchiver = getService('esArchiver');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SPACES } from '../../../common/lib/spaces';
import { getTestSuiteFactory } from '../../../common/suites/spaces/get';
import { SPACES } from '../../common/lib/spaces';
import { TestInvoker } from '../../common/lib/types';
import { getTestSuiteFactory } from '../../common/suites/spaces/get';

// tslint:disable:no-default-export
export default function getSpaceTestSuite({ getService }) {
export default function getSpaceTestSuite({ getService }: TestInvoker) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const esArchiver = getService('esArchiver');

Expand Down
Loading

0 comments on commit bc602b1

Please sign in to comment.