Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds SOM integration tests for serverless #184888

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
14428a9
Adds SOM integration tests for serverless
TinaHeiligers May 20, 2024
ba714a3
Adds assertion for find
TinaHeiligers May 21, 2024
2482892
adds tests for bulk_get
TinaHeiligers May 25, 2024
0eff45c
adds tests for _bulk_delete
TinaHeiligers Jun 3, 2024
601e55f
Adds scroll_count
TinaHeiligers Jun 3, 2024
907dc33
Adds scroll_count
TinaHeiligers Jun 4, 2024
321db7b
Merge branch 'main' into SOM-serverless-find-int-test
kibanamachine Jun 4, 2024
ccb566c
Merge branch 'main' into SOM-serverless-find-int-test
kibanamachine Jun 5, 2024
8032917
Add relationships api integration tests
TinaHeiligers Jun 4, 2024
2446ef2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 6, 2024
a9cc309
Merge branch 'main' into kbn175757-serverless-SOM-APIint
TinaHeiligers Jun 6, 2024
7de5703
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 6, 2024
43afb95
Fix syntax
TinaHeiligers Jun 6, 2024
b34e97c
remove unused
TinaHeiligers Jun 6, 2024
8434dfd
Refactors relationships tests
TinaHeiligers Jun 6, 2024
4c58391
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 7, 2024
58e6f13
refactor before and after hooks to be one level shallower :shrug:
jloleysens Jun 7, 2024
e10b03e
Refactors before and after hooks for relationships to load fixtures
TinaHeiligers Jun 8, 2024
90afd0c
minor unrelated fix, update comment about inAppUrl
TinaHeiligers Jun 8, 2024
01c197a
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 8, 2024
cbc282b
Update x-pack/test_serverless/api_integration/test_suites/common/save…
TinaHeiligers Jun 8, 2024
fcc9645
Merge branch 'main' into kbn175757-serverless-SOM-APIint
jloleysens Jun 10, 2024
395d1fe
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 10, 2024
6023dbf
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 10, 2024
785504b
Merge branch 'main' into kbn175757-serverless-SOM-APIint
TinaHeiligers Jun 12, 2024
89214b9
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 12, 2024
78cc092
use supertestWithoutAuth
TinaHeiligers Jun 12, 2024
32ec76b
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 12, 2024
564884e
Merge branch 'main' into kbn175757-serverless-SOM-APIint
kibanamachine Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export default function ({ getService }: FtrProviderContext) {
});

describe('index patterns', () => {
it('should validate visualization response schema', async () => {
it('should validate index-pattern response schema', async () => {
TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
const resp = await supertest
.get(relationshipsUrl('index-pattern', '8963ca30-3224-11e8-a572-ffca06da1357'))
.expect(200);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { SavedObjectWithMetadata } from '@kbn/saved-objects-management-plugin/common';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { RoleCredentials } from '../../../../shared/services';

export default function ({ getService }: FtrProviderContext) {
const svlCommonApi = getService('svlCommonApi');
const svlUserManager = getService('svlUserManager');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const kibanaServer = getService('kibanaServer');
let roleAuthc: RoleCredentials;

describe('_bulk_delete', () => {
const endpoint = '/internal/kibana/management/saved_objects/_bulk_delete';
const validObject = { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab' };
const invalidObject = { type: 'wigwags', id: 'foo' };

before(async () => {
roleAuthc = await svlUserManager.createApiKeyForRole('admin');
});

after(async () => {
await svlUserManager.invalidateApiKeyForRole(roleAuthc);
});

beforeEach(() =>
kibanaServer.importExport.load(
'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json'
)
);
afterEach(() =>
kibanaServer.importExport.unload(
'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json'
)
);

function expectSuccess(index: number, objs: SavedObjectWithMetadata[]) {
const { type, id, error } = objs[index];
expect(type).to.eql(validObject.type);
expect(id).to.eql(validObject.id);
expect(error).to.equal(undefined);
}

function expectBadRequest(index: number, objs: SavedObjectWithMetadata[]) {
const { type, id, error } = objs[index];
expect(type).to.eql(invalidObject.type);
expect(id).to.eql(invalidObject.id);
expect(error).to.eql({
message: `Unsupported saved object type: '${invalidObject.type}': Bad Request`,
statusCode: 400,
error: 'Bad Request',
});
}

it('should return 200 for an existing object', async () =>
await supertestWithoutAuth
.post(endpoint)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([validObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(1);
expectSuccess(0, body);
}));

it('should return error for invalid object type', async () =>
await supertestWithoutAuth
.post(endpoint)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([invalidObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(1);
expectBadRequest(0, body);
}));

it('should return mix of successes and errors', async () =>
await supertestWithoutAuth
.post(endpoint)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([validObject, invalidObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(2);
expectSuccess(0, body);
expectBadRequest(1, body);
}));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { SavedObjectWithMetadata } from '@kbn/saved-objects-management-plugin/common';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { RoleCredentials } from '../../../../shared/services';

export default function ({ getService }: FtrProviderContext) {
const svlCommonApi = getService('svlCommonApi');
const svlUserManager = getService('svlUserManager');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const kibanaServer = getService('kibanaServer');
let roleAuthc: RoleCredentials;

const URL = '/api/kibana/management/saved_objects/_bulk_get';
const validObject = { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab' };
const invalidObject = { type: 'wigwags', id: 'foo' };

describe('_bulk_get', () => {
before(async () => {
roleAuthc = await svlUserManager.createApiKeyForRole('admin');
});

after(async () => {
await svlUserManager.invalidateApiKeyForRole(roleAuthc);
});

describe('get objects in bulk', () => {
before(() =>
kibanaServer.importExport.load(
'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json'
)
);
after(() =>
kibanaServer.importExport.unload(
'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json'
)
);

function expectSuccess(index: number, objs: SavedObjectWithMetadata[]) {
const { type, id, meta, error } = objs[index];
expect(type).to.eql(validObject.type);
expect(id).to.eql(validObject.id);
expect(meta).to.not.equal(undefined);
expect(error).to.equal(undefined);
}

function expectBadRequest(index: number, objs: SavedObjectWithMetadata[]) {
const { type, id, error } = objs[index];
expect(type).to.eql(invalidObject.type);
expect(id).to.eql(invalidObject.id);
expect(error).to.eql({
message: `Unsupported saved object type: '${invalidObject.type}': Bad Request`,
statusCode: 400,
error: 'Bad Request',
});
}

it('should return 200 for object that exists and inject metadata', async () =>
await supertestWithoutAuth
.post(URL)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([validObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(1);
expectSuccess(0, body);
}));

it('should return error for invalid object type', async () =>
await supertestWithoutAuth
.post(URL)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([invalidObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(1);
expectBadRequest(0, body);
}));

it('should return mix of successes and errors', async () =>
await supertestWithoutAuth
.post(URL)
.set(svlCommonApi.getInternalRequestHeader())
.set(roleAuthc.apiKeyHeader)
.send([validObject, invalidObject])
.expect(200)
.then(({ body }) => {
expect(body).to.have.length(2);
expectSuccess(0, body);
expectBadRequest(1, body);
}));
});
});
}
Loading