mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ftr] migrating 'saved_objects_management/bulk' API integration test to deployment-agnostic one (#192070)
## Summary _The goal is to consolidate 2 existing test files with identical logic into a single, deployment-agnostic test file:_ Files to be replaced: - test/api_integration/apis/saved_objects_management/bulk_delete.ts - test/api_integration/apis/saved_objects_management/bulk_get.ts - x-pack/test_serverless/api_integration/test_suites/common/saved_objects_management/bulk_delete.ts - x-pack/test_serverless/api_integration/test_suites/common/saved_objects_management/bulk_get.ts New test file: - x-pack/test/api_integration/deployment_agnostic/apis/saved_objects_management/bulk_delete.ts - x-pack/test/api_integration/deployment_agnostic/apis/saved_objects_management/bulk_get.ts The migration leverages the serverless test file as a basis for the new deployment-agnostic test. Necessary modifications are minimal and include FTR context provider & its services to ensure compatibility across different environments. Lastly new file has to be loaded into both the serverless and stateful config files under `x-pack/test/api_integration/deployment_agnostic/configs` This approach ensures that the test logic remains consistent while reducing redundancy and maintenance effort. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4d28bd6203
commit
4cd23a1df7
10 changed files with 45 additions and 50 deletions
|
@ -12,8 +12,6 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('saved objects management apis', () => {
|
||||
loadTestFile(require.resolve('./find'));
|
||||
loadTestFile(require.resolve('./bulk_delete'));
|
||||
loadTestFile(require.resolve('./bulk_get'));
|
||||
loadTestFile(require.resolve('./relationships'));
|
||||
loadTestFile(require.resolve('./scroll_count'));
|
||||
});
|
||||
|
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
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';
|
||||
import { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context';
|
||||
import { SupertestWithRoleScopeType } from '../../services';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const svlCommonApi = getService('svlCommonApi');
|
||||
const svlUserManager = getService('svlUserManager');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
let roleAuthc: RoleCredentials;
|
||||
const roleScopedSupertest = getService('roleScopedSupertest');
|
||||
let supertestWithAdminScope: SupertestWithRoleScopeType;
|
||||
|
||||
describe('_bulk_delete', () => {
|
||||
const endpoint = '/internal/kibana/management/saved_objects/_bulk_delete';
|
||||
|
@ -23,11 +21,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const invalidObject = { type: 'wigwags', id: 'foo' };
|
||||
|
||||
before(async () => {
|
||||
roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('admin');
|
||||
supertestWithAdminScope = await roleScopedSupertest.getSupertestWithRoleScope('admin', {
|
||||
withInternalHeaders: true,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await svlUserManager.invalidateM2mApiKeyWithRoleScope(roleAuthc);
|
||||
await supertestWithAdminScope.destroy();
|
||||
});
|
||||
|
||||
beforeEach(() =>
|
||||
|
@ -60,21 +60,14 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
}
|
||||
|
||||
it('should return 200 for an existing object', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
.post(endpoint)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([validObject])
|
||||
.expect(200);
|
||||
const { body } = await supertestWithAdminScope.post(endpoint).send([validObject]).expect(200);
|
||||
expect(body).to.have.length(1);
|
||||
expectSuccess(0, body);
|
||||
});
|
||||
|
||||
it('should return error for invalid object type', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
const { body } = await supertestWithAdminScope
|
||||
.post(endpoint)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([invalidObject])
|
||||
.expect(200);
|
||||
expect(body).to.have.length(1);
|
||||
|
@ -82,10 +75,8 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should return mix of successes and errors', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
const { body } = await supertestWithAdminScope
|
||||
.post(endpoint)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([validObject, invalidObject])
|
||||
.expect(200);
|
||||
expect(body).to.have.length(2);
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
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';
|
||||
import { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context';
|
||||
import { SupertestWithRoleScopeType } from '../../services';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const svlCommonApi = getService('svlCommonApi');
|
||||
const svlUserManager = getService('svlUserManager');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
let roleAuthc: RoleCredentials;
|
||||
const roleScopedSupertest = getService('roleScopedSupertest');
|
||||
let supertestWithAdminScope: SupertestWithRoleScopeType;
|
||||
|
||||
const URL = '/api/kibana/management/saved_objects/_bulk_get';
|
||||
const validObject = { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab' };
|
||||
|
@ -23,11 +21,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
describe('_bulk_get', () => {
|
||||
before(async () => {
|
||||
roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('admin');
|
||||
supertestWithAdminScope = await roleScopedSupertest.getSupertestWithRoleScope('admin', {
|
||||
withInternalHeaders: true,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await svlUserManager.invalidateM2mApiKeyWithRoleScope(roleAuthc);
|
||||
await supertestWithAdminScope.destroy();
|
||||
});
|
||||
|
||||
describe('get objects in bulk', () => {
|
||||
|
@ -62,32 +62,20 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
}
|
||||
|
||||
it('should return 200 for object that exists and inject metadata', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
.post(URL)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([validObject])
|
||||
.expect(200);
|
||||
const { body } = await supertestWithAdminScope.post(URL).send([validObject]).expect(200);
|
||||
expect(body).to.have.length(1);
|
||||
expectSuccess(0, body);
|
||||
});
|
||||
|
||||
it('should return error for invalid object type', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
.post(URL)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([invalidObject])
|
||||
.expect(200);
|
||||
const { body } = await supertestWithAdminScope.post(URL).send([invalidObject]).expect(200);
|
||||
expect(body).to.have.length(1);
|
||||
expectBadRequest(0, body);
|
||||
});
|
||||
|
||||
it('should return mix of successes and errors', async () => {
|
||||
const { body } = await supertestWithoutAuth
|
||||
const { body } = await supertestWithAdminScope
|
||||
.post(URL)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.send([validObject, invalidObject])
|
||||
.expect(200);
|
||||
expect(body).to.have.length(2);
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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 { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) {
|
||||
describe('saved objects management apis', () => {
|
||||
loadTestFile(require.resolve('./bulk_get'));
|
||||
loadTestFile(require.resolve('./bulk_delete'));
|
||||
});
|
||||
}
|
|
@ -12,6 +12,7 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext)
|
|||
loadTestFile(require.resolve('../../apis/console'));
|
||||
loadTestFile(require.resolve('../../apis/core'));
|
||||
loadTestFile(require.resolve('../../apis/painless_lab'));
|
||||
loadTestFile(require.resolve('../../apis/saved_objects_management'));
|
||||
loadTestFile(require.resolve('../../apis/observability/alerting'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,5 +11,6 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext)
|
|||
// load new search and platform deployment-agnostic test here
|
||||
loadTestFile(require.resolve('../../apis/console'));
|
||||
loadTestFile(require.resolve('../../apis/core'));
|
||||
loadTestFile(require.resolve('../../apis/saved_objects_management'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,5 +12,6 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext)
|
|||
loadTestFile(require.resolve('../../apis/console'));
|
||||
loadTestFile(require.resolve('../../apis/core'));
|
||||
loadTestFile(require.resolve('../../apis/painless_lab'));
|
||||
loadTestFile(require.resolve('../../apis/saved_objects_management'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,5 +13,6 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext)
|
|||
loadTestFile(require.resolve('../../apis/console'));
|
||||
loadTestFile(require.resolve('../../apis/core'));
|
||||
loadTestFile(require.resolve('../../apis/painless_lab'));
|
||||
loadTestFile(require.resolve('../../apis/saved_objects_management'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@
|
|||
"@kbn/security-solution-plugin/public/management/cypress",
|
||||
"@kbn/management-settings-ids",
|
||||
"@kbn/mock-idp-utils",
|
||||
"@kbn/cloud-security-posture-common"
|
||||
"@kbn/cloud-security-posture-common",
|
||||
"@kbn/saved-objects-management-plugin"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
|
|||
this.tags(['esGate']);
|
||||
|
||||
loadTestFile(require.resolve('./find'));
|
||||
loadTestFile(require.resolve('./bulk_get'));
|
||||
loadTestFile(require.resolve('./bulk_delete'));
|
||||
loadTestFile(require.resolve('./scroll_count'));
|
||||
loadTestFile(require.resolve('./relationships'));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue