Skip to content

Commit 5d11bef

Browse files
committed
Adding not space aware test to find
1 parent f9383fd commit 5d11bef

7 files changed

Lines changed: 200 additions & 33 deletions

File tree

x-pack/test/saved_object_api_integration/common/suites/find.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interface FindTest {
1616
}
1717

1818
interface FindTests {
19-
normal: FindTest;
19+
spaceAwareType: FindTest;
20+
notSpaceAwareType: FindTest;
2021
unknownType: FindTest;
2122
pageBeyondTotal: FindTest;
2223
unknownSearchField: FindTest;
@@ -41,12 +42,23 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
4142
before(() => esArchiver.load('saved_objects/spaces'));
4243
after(() => esArchiver.unload('saved_objects/spaces'));
4344

44-
it(`should return ${tests.normal.statusCode} with ${tests.normal.description}`, async () =>
45+
it(`space aware type should return ${tests.spaceAwareType.statusCode} with ${
46+
tests.spaceAwareType.description
47+
}`, async () =>
4548
await supertest
4649
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find?type=visualization&fields=title`)
4750
.auth(auth.username, auth.password)
48-
.expect(tests.normal.statusCode)
49-
.then(tests.normal.response));
51+
.expect(tests.spaceAwareType.statusCode)
52+
.then(tests.spaceAwareType.response));
53+
54+
it(`not space aware type should return ${tests.spaceAwareType.statusCode} with ${
55+
tests.notSpaceAwareType.description
56+
}`, async () =>
57+
await supertest
58+
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find?type=globaltype&fields=name`)
59+
.auth(auth.username, auth.password)
60+
.expect(tests.notSpaceAwareType.statusCode)
61+
.then(tests.notSpaceAwareType.response));
5062

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

191+
const expectNotSpaceAwareResults = (resp: any) => {
192+
expect(resp.body).to.eql({
193+
page: 1,
194+
per_page: 20,
195+
total: 1,
196+
saved_objects: [
197+
{
198+
type: 'globaltype',
199+
id: `8121a00-8efd-21e7-1cb3-34ab966434445`,
200+
version: 1,
201+
attributes: {
202+
name: 'My favorite global object',
203+
},
204+
},
205+
],
206+
});
207+
};
208+
179209
const createExpectVisualizationResults = (spaceId = DEFAULT_SPACE_ID) => (resp: any) => {
180210
expect(resp.body).to.eql({
181211
page: 1,
@@ -200,6 +230,7 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
200230
createExpectResults,
201231
createExpectLegacyForbidden,
202232
createExpectVisualizationResults,
233+
expectNotSpaceAwareResults,
203234
findTest,
204235
};
205236
}

x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function({ getService }: TestInvoker) {
2222
expectRbacForbidden,
2323
} = bulkCreateTestSuiteFactory(es, esArchiver, supertest);
2424

25-
describe.only('_bulk_create', () => {
25+
describe('_bulk_create', () => {
2626
[
2727
{
2828
spaceId: SPACES.DEFAULT.spaceId,

x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ export default function({ getService }: TestInvoker) {
1414
const supertest = getService('supertestWithoutAuth');
1515
const esArchiver = getService('esArchiver');
1616

17-
describe.only('find', () => {
17+
describe('find', () => {
1818
const {
1919
createExpectEmpty,
2020
createExpectRbacForbidden,
2121
createExpectResults,
2222
createExpectLegacyForbidden,
2323
createExpectVisualizationResults,
24+
expectNotSpaceAwareResults,
2425
findTest,
2526
} = findTestSuiteFactory(esArchiver, supertest);
2627

@@ -62,11 +63,16 @@ export default function({ getService }: TestInvoker) {
6263
},
6364
spaceId: scenario.spaceId,
6465
tests: {
65-
normal: {
66+
spaceAwareType: {
6667
description: 'forbidden login and find visualization message',
6768
statusCode: 403,
6869
response: createExpectLegacyForbidden(AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME),
6970
},
71+
notSpaceAwareType: {
72+
description: 'forbidden login and find globaltype message',
73+
statusCode: 403,
74+
response: createExpectLegacyForbidden(AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME),
75+
},
7076
unknownType: {
7177
description: 'forbidden login and find wigwags message',
7278
statusCode: 403,
@@ -97,11 +103,16 @@ export default function({ getService }: TestInvoker) {
97103
},
98104
spaceId: scenario.spaceId,
99105
tests: {
100-
normal: {
106+
spaceAwareType: {
101107
description: 'only the visualization',
102108
statusCode: 200,
103109
response: createExpectVisualizationResults(scenario.spaceId),
104110
},
111+
notSpaceAwareType: {
112+
description: 'only the globaltype',
113+
statusCode: 200,
114+
response: expectNotSpaceAwareResults,
115+
},
105116
unknownType: {
106117
description: 'empty result',
107118
statusCode: 200,
@@ -132,11 +143,16 @@ export default function({ getService }: TestInvoker) {
132143
},
133144
spaceId: scenario.spaceId,
134145
tests: {
135-
normal: {
146+
spaceAwareType: {
136147
description: 'only the visualization',
137148
statusCode: 200,
138149
response: createExpectVisualizationResults(scenario.spaceId),
139150
},
151+
notSpaceAwareType: {
152+
description: 'only the globaltype',
153+
statusCode: 200,
154+
response: expectNotSpaceAwareResults,
155+
},
140156
unknownType: {
141157
description: 'empty result',
142158
statusCode: 200,
@@ -167,11 +183,16 @@ export default function({ getService }: TestInvoker) {
167183
},
168184
spaceId: scenario.spaceId,
169185
tests: {
170-
normal: {
186+
spaceAwareType: {
171187
description: 'only the visualization',
172188
statusCode: 200,
173189
response: createExpectVisualizationResults(scenario.spaceId),
174190
},
191+
notSpaceAwareType: {
192+
description: 'only the globaltype',
193+
statusCode: 200,
194+
response: expectNotSpaceAwareResults,
195+
},
175196
unknownType: {
176197
description: 'empty result',
177198
statusCode: 200,
@@ -202,11 +223,16 @@ export default function({ getService }: TestInvoker) {
202223
},
203224
spaceId: scenario.spaceId,
204225
tests: {
205-
normal: {
226+
spaceAwareType: {
206227
description: 'only the visualization',
207228
statusCode: 200,
208229
response: createExpectVisualizationResults(scenario.spaceId),
209230
},
231+
notSpaceAwareType: {
232+
description: 'only the globaltype',
233+
statusCode: 200,
234+
response: expectNotSpaceAwareResults,
235+
},
210236
unknownType: {
211237
description: 'empty result',
212238
statusCode: 200,
@@ -237,11 +263,16 @@ export default function({ getService }: TestInvoker) {
237263
},
238264
spaceId: scenario.spaceId,
239265
tests: {
240-
normal: {
266+
spaceAwareType: {
241267
description: 'only the visualization',
242268
statusCode: 200,
243269
response: createExpectVisualizationResults(scenario.spaceId),
244270
},
271+
notSpaceAwareType: {
272+
description: 'only the globaltype',
273+
statusCode: 200,
274+
response: expectNotSpaceAwareResults,
275+
},
245276
unknownType: {
246277
description: 'forbidden find wigwags message',
247278
statusCode: 403,
@@ -272,11 +303,16 @@ export default function({ getService }: TestInvoker) {
272303
},
273304
spaceId: scenario.spaceId,
274305
tests: {
275-
normal: {
306+
spaceAwareType: {
276307
description: 'only the visualization',
277308
statusCode: 200,
278309
response: createExpectVisualizationResults(scenario.spaceId),
279310
},
311+
notSpaceAwareType: {
312+
description: 'only the globaltype',
313+
statusCode: 200,
314+
response: expectNotSpaceAwareResults,
315+
},
280316
unknownType: {
281317
description: 'empty result',
282318
statusCode: 200,
@@ -307,11 +343,16 @@ export default function({ getService }: TestInvoker) {
307343
},
308344
spaceId: scenario.spaceId,
309345
tests: {
310-
normal: {
346+
spaceAwareType: {
311347
description: 'only the visualization',
312348
statusCode: 200,
313349
response: createExpectVisualizationResults(scenario.spaceId),
314350
},
351+
notSpaceAwareType: {
352+
description: 'only the globaltype',
353+
statusCode: 200,
354+
response: expectNotSpaceAwareResults,
355+
},
315356
unknownType: {
316357
description: 'forbidden find wigwags message',
317358
statusCode: 403,
@@ -342,11 +383,16 @@ export default function({ getService }: TestInvoker) {
342383
},
343384
spaceId: scenario.spaceId,
344385
tests: {
345-
normal: {
386+
spaceAwareType: {
346387
description: 'only the visualization',
347388
statusCode: 200,
348389
response: createExpectVisualizationResults(scenario.spaceId),
349390
},
391+
notSpaceAwareType: {
392+
description: 'only the globaltype',
393+
statusCode: 200,
394+
response: expectNotSpaceAwareResults,
395+
},
350396
unknownType: {
351397
description: 'forbidden and find wigwags message',
352398
statusCode: 403,
@@ -377,11 +423,16 @@ export default function({ getService }: TestInvoker) {
377423
},
378424
spaceId: scenario.spaceId,
379425
tests: {
380-
normal: {
426+
spaceAwareType: {
381427
description: 'only the visualization',
382428
statusCode: 200,
383429
response: createExpectVisualizationResults(scenario.spaceId),
384430
},
431+
notSpaceAwareType: {
432+
description: 'only the globaltype',
433+
statusCode: 200,
434+
response: expectNotSpaceAwareResults,
435+
},
385436
unknownType: {
386437
description: 'forbidden and find wigwags message',
387438
statusCode: 403,
@@ -414,11 +465,16 @@ export default function({ getService }: TestInvoker) {
414465
},
415466
spaceId: scenario.spaceId,
416467
tests: {
417-
normal: {
468+
spaceAwareType: {
418469
description: 'forbidden login and find visualization message',
419470
statusCode: 403,
420471
response: createExpectRbacForbidden('visualization'),
421472
},
473+
notSpaceAwareType: {
474+
description: 'forbidden login and find globaltype message',
475+
statusCode: 403,
476+
response: createExpectRbacForbidden('globaltype'),
477+
},
422478
unknownType: {
423479
description: 'forbidden login and find wigwags message',
424480
statusCode: 403,

x-pack/test/saved_object_api_integration/security_only/apis/bulk_get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function({ getService }: TestInvoker) {
1818
supertest
1919
);
2020

21-
describe.only('_bulk_get', () => {
21+
describe('_bulk_get', () => {
2222
bulkGetTest(`not a kibana user`, {
2323
auth: {
2424
username: AUTHENTICATION.NOT_A_KIBANA_USER.USERNAME,

0 commit comments

Comments
 (0)