Skip to content

Commit

Permalink
Adding not space aware test to find
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Sep 8, 2018
1 parent f9383fd commit 5d11bef
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 33 deletions.
39 changes: 35 additions & 4 deletions x-pack/test/saved_object_api_integration/common/suites/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ interface FindTest {
}

interface FindTests {
normal: FindTest;
spaceAwareType: FindTest;
notSpaceAwareType: FindTest;
unknownType: FindTest;
pageBeyondTotal: FindTest;
unknownSearchField: FindTest;
Expand All @@ -41,12 +42,23 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
before(() => esArchiver.load('saved_objects/spaces'));
after(() => esArchiver.unload('saved_objects/spaces'));

it(`should return ${tests.normal.statusCode} with ${tests.normal.description}`, async () =>
it(`space aware type should return ${tests.spaceAwareType.statusCode} with ${
tests.spaceAwareType.description
}`, async () =>
await supertest
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find?type=visualization&fields=title`)
.auth(auth.username, auth.password)
.expect(tests.normal.statusCode)
.then(tests.normal.response));
.expect(tests.spaceAwareType.statusCode)
.then(tests.spaceAwareType.response));

it(`not space aware type should return ${tests.spaceAwareType.statusCode} with ${
tests.notSpaceAwareType.description
}`, async () =>
await supertest
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find?type=globaltype&fields=name`)
.auth(auth.username, auth.password)
.expect(tests.notSpaceAwareType.statusCode)
.then(tests.notSpaceAwareType.response));

describe('unknown type', () => {
it(`should return ${tests.unknownType.statusCode} with ${
Expand Down Expand Up @@ -176,6 +188,24 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
});
};

const expectNotSpaceAwareResults = (resp: any) => {
expect(resp.body).to.eql({
page: 1,
per_page: 20,
total: 1,
saved_objects: [
{
type: 'globaltype',
id: `8121a00-8efd-21e7-1cb3-34ab966434445`,
version: 1,
attributes: {
name: 'My favorite global object',
},
},
],
});
};

const createExpectVisualizationResults = (spaceId = DEFAULT_SPACE_ID) => (resp: any) => {
expect(resp.body).to.eql({
page: 1,
Expand All @@ -200,6 +230,7 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
createExpectResults,
createExpectLegacyForbidden,
createExpectVisualizationResults,
expectNotSpaceAwareResults,
findTest,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function({ getService }: TestInvoker) {
expectRbacForbidden,
} = bulkCreateTestSuiteFactory(es, esArchiver, supertest);

describe.only('_bulk_create', () => {
describe('_bulk_create', () => {
[
{
spaceId: SPACES.DEFAULT.spaceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export default function({ getService }: TestInvoker) {
const supertest = getService('supertestWithoutAuth');
const esArchiver = getService('esArchiver');

describe.only('find', () => {
describe('find', () => {
const {
createExpectEmpty,
createExpectRbacForbidden,
createExpectResults,
createExpectLegacyForbidden,
createExpectVisualizationResults,
expectNotSpaceAwareResults,
findTest,
} = findTestSuiteFactory(esArchiver, supertest);

Expand Down Expand Up @@ -62,11 +63,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'forbidden login and find visualization message',
statusCode: 403,
response: createExpectLegacyForbidden(AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME),
},
notSpaceAwareType: {
description: 'forbidden login and find globaltype message',
statusCode: 403,
response: createExpectLegacyForbidden(AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME),
},
unknownType: {
description: 'forbidden login and find wigwags message',
statusCode: 403,
Expand Down Expand Up @@ -97,11 +103,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'empty result',
statusCode: 200,
Expand Down Expand Up @@ -132,11 +143,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'empty result',
statusCode: 200,
Expand Down Expand Up @@ -167,11 +183,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'empty result',
statusCode: 200,
Expand Down Expand Up @@ -202,11 +223,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'empty result',
statusCode: 200,
Expand Down Expand Up @@ -237,11 +263,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'forbidden find wigwags message',
statusCode: 403,
Expand Down Expand Up @@ -272,11 +303,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'empty result',
statusCode: 200,
Expand Down Expand Up @@ -307,11 +343,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'forbidden find wigwags message',
statusCode: 403,
Expand Down Expand Up @@ -342,11 +383,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'forbidden and find wigwags message',
statusCode: 403,
Expand Down Expand Up @@ -377,11 +423,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'only the visualization',
statusCode: 200,
response: createExpectVisualizationResults(scenario.spaceId),
},
notSpaceAwareType: {
description: 'only the globaltype',
statusCode: 200,
response: expectNotSpaceAwareResults,
},
unknownType: {
description: 'forbidden and find wigwags message',
statusCode: 403,
Expand Down Expand Up @@ -414,11 +465,16 @@ export default function({ getService }: TestInvoker) {
},
spaceId: scenario.spaceId,
tests: {
normal: {
spaceAwareType: {
description: 'forbidden login and find visualization message',
statusCode: 403,
response: createExpectRbacForbidden('visualization'),
},
notSpaceAwareType: {
description: 'forbidden login and find globaltype message',
statusCode: 403,
response: createExpectRbacForbidden('globaltype'),
},
unknownType: {
description: 'forbidden login and find wigwags message',
statusCode: 403,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function({ getService }: TestInvoker) {
supertest
);

describe.only('_bulk_get', () => {
describe('_bulk_get', () => {
bulkGetTest(`not a kibana user`, {
auth: {
username: AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME,
Expand Down
Loading

0 comments on commit 5d11bef

Please sign in to comment.