mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
[ResponseOps][Cases] Delete get status deprecated API (#208208)
## Summary Resolves https://github.com/elastic/kibana/issues/207341 ### Checklist Check the PR satisfies following conditions. - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### Release note Removed deprecated get case status API --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ef96cd5d0b
commit
bbc3944d31
16 changed files with 0 additions and 716 deletions
|
@ -6636,37 +6636,6 @@ paths:
|
|||
summary: Get case creators
|
||||
tags:
|
||||
- cases
|
||||
/api/cases/status:
|
||||
get:
|
||||
deprecated: true
|
||||
description: |
|
||||
Returns the number of cases that are open, closed, and in progress. Deprecated in 8.1.0. This API is deprecated and will be removed in a future release; use the find cases API instead. You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.
|
||||
operationId: getCaseStatusDefaultSpace
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/Cases_owner_filter'
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
count_closed_cases:
|
||||
type: integer
|
||||
count_in_progress_cases:
|
||||
type: integer
|
||||
count_open_cases:
|
||||
type: integer
|
||||
description: Indicates a successful call.
|
||||
'401':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Cases_4xx_response'
|
||||
description: Authorization information is missing or invalid.
|
||||
summary: Get case status summary
|
||||
tags:
|
||||
- cases
|
||||
/api/cases/tags:
|
||||
get:
|
||||
description: |
|
||||
|
|
|
@ -54,7 +54,6 @@ export const CASE_COMMENT_DETAILS_URL = `${CASE_DETAILS_URL}/comments/{comment_i
|
|||
export const CASE_COMMENT_DELETE_URL = `${CASE_DETAILS_URL}/comments/{comment_id}` as const;
|
||||
export const CASE_PUSH_URL = `${CASE_DETAILS_URL}/connector/{connector_id}/_push` as const;
|
||||
export const CASE_REPORTERS_URL = `${CASES_URL}/reporters` as const;
|
||||
export const CASE_STATUS_URL = `${CASES_URL}/status` as const;
|
||||
export const CASE_TAGS_URL = `${CASES_URL}/tags` as const;
|
||||
export const CASE_USER_ACTIONS_URL = `${CASE_DETAILS_URL}/user_actions` as const;
|
||||
export const CASE_FIND_USER_ACTIONS_URL = `${CASE_USER_ACTIONS_URL}/_find` as const;
|
||||
|
|
|
@ -1117,55 +1117,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/cases/status": {
|
||||
"get": {
|
||||
"summary": "Get case status summary",
|
||||
"operationId": "getCaseStatusDefaultSpace",
|
||||
"description": "Returns the number of cases that are open, closed, and in progress. Deprecated in 8.1.0. This API is deprecated and will be removed in a future release; use the find cases API instead. You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.\n",
|
||||
"deprecated": true,
|
||||
"tags": [
|
||||
"cases"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/owner_filter"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Indicates a successful call.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"count_closed_cases": {
|
||||
"type": "integer"
|
||||
},
|
||||
"count_in_progress_cases": {
|
||||
"type": "integer"
|
||||
},
|
||||
"count_open_cases": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Authorization information is missing or invalid.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/4xx_response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/cases/tags": {
|
||||
"get": {
|
||||
"summary": "Get case tags",
|
||||
|
|
|
@ -750,37 +750,6 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/4xx_response'
|
||||
/api/cases/status:
|
||||
get:
|
||||
summary: Get case status summary
|
||||
operationId: getCaseStatusDefaultSpace
|
||||
description: |
|
||||
Returns the number of cases that are open, closed, and in progress. Deprecated in 8.1.0. This API is deprecated and will be removed in a future release; use the find cases API instead. You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.
|
||||
deprecated: true
|
||||
tags:
|
||||
- cases
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/owner_filter'
|
||||
responses:
|
||||
'200':
|
||||
description: Indicates a successful call.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
count_closed_cases:
|
||||
type: integer
|
||||
count_in_progress_cases:
|
||||
type: integer
|
||||
count_open_cases:
|
||||
type: integer
|
||||
'401':
|
||||
description: Authorization information is missing or invalid.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/4xx_response'
|
||||
/api/cases/tags:
|
||||
get:
|
||||
summary: Get case tags
|
||||
|
|
|
@ -27,8 +27,6 @@ paths:
|
|||
$ref: paths/api@cases@configure@{configurationid}.yaml
|
||||
'/api/cases/reporters':
|
||||
$ref: 'paths/api@cases@reporters.yaml'
|
||||
'/api/cases/status':
|
||||
$ref: 'paths/api@cases@status.yaml'
|
||||
'/api/cases/tags':
|
||||
$ref: 'paths/api@cases@tags.yaml'
|
||||
'/api/cases/{caseId}':
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
get:
|
||||
summary: Get case status summary
|
||||
operationId: getCaseStatusDefaultSpace
|
||||
description: >
|
||||
Returns the number of cases that are open, closed, and in progress.
|
||||
Deprecated in 8.1.0. This API is deprecated and will be removed in a future release; use the find cases API instead.
|
||||
You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.
|
||||
deprecated: true
|
||||
tags:
|
||||
- cases
|
||||
parameters:
|
||||
- $ref: '../components/parameters/owner_filter.yaml'
|
||||
responses:
|
||||
'200':
|
||||
description: Indicates a successful call.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
count_closed_cases:
|
||||
type: integer
|
||||
count_in_progress_cases:
|
||||
type: integer
|
||||
count_open_cases:
|
||||
type: integer
|
||||
'401':
|
||||
description: Authorization information is missing or invalid.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '../components/schemas/4xx_response.yaml'
|
|
@ -14,7 +14,6 @@ import { patchCaseRoute } from './cases/patch_cases';
|
|||
import { postCaseRoute } from './cases/post_case';
|
||||
import { pushCaseRoute } from './cases/push_case';
|
||||
import { getReportersRoute } from './cases/reporters/get_reporters';
|
||||
import { getStatusRoute } from './stats/get_status';
|
||||
import type { CaseRoute } from './types';
|
||||
import { getTagsRoute } from './cases/tags/get_tags';
|
||||
import { deleteAllCommentsRoute } from './comments/delete_all_comments';
|
||||
|
@ -47,7 +46,6 @@ export const getExternalRoutes = ({
|
|||
postCaseRoute,
|
||||
pushCaseRoute,
|
||||
findUserActionsRoute,
|
||||
getStatusRoute({ isServerless, docLinks }),
|
||||
getCasesByAlertIdRoute,
|
||||
getReportersRoute,
|
||||
getTagsRoute,
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* 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 { getStatusRoute } from './get_status';
|
||||
import { docLinksServiceMock } from '@kbn/core/server/mocks';
|
||||
|
||||
describe('getStatusRoute', () => {
|
||||
const docLinks = docLinksServiceMock.createSetupContract();
|
||||
|
||||
it('marks the endpoint internal in serverless', async () => {
|
||||
const router = getStatusRoute({ isServerless: true, docLinks });
|
||||
|
||||
expect(router.routerOptions?.access).toBe('internal');
|
||||
expect(router.routerOptions?.deprecated).toMatchInlineSnapshot(
|
||||
{
|
||||
documentationUrl: expect.stringMatching(/#breaking-201004$/),
|
||||
},
|
||||
`
|
||||
Object {
|
||||
"documentationUrl": StringMatching /#breaking-201004\\$/,
|
||||
"reason": Object {
|
||||
"type": "remove",
|
||||
},
|
||||
"severity": "warning",
|
||||
}
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
it('marks the endpoint public in non-serverless', async () => {
|
||||
const router = getStatusRoute({ isServerless: false, docLinks });
|
||||
|
||||
expect(router.routerOptions?.access).toBe('public');
|
||||
});
|
||||
});
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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 type { DocLinksServiceSetup } from '@kbn/core/server';
|
||||
import type { CaseRoute } from '../types';
|
||||
|
||||
import { CASE_STATUS_URL } from '../../../../common/constants';
|
||||
import { createCaseError } from '../../../common/error';
|
||||
import { createCasesRoute } from '../create_cases_route';
|
||||
import type { statsApiV1 } from '../../../../common/types/api';
|
||||
import { DEFAULT_CASES_ROUTE_SECURITY } from '../constants';
|
||||
|
||||
/**
|
||||
* @deprecated since version 8.1.0
|
||||
*/
|
||||
export const getStatusRoute = ({
|
||||
isServerless,
|
||||
docLinks,
|
||||
}: {
|
||||
isServerless?: boolean;
|
||||
docLinks: DocLinksServiceSetup;
|
||||
}): CaseRoute =>
|
||||
createCasesRoute({
|
||||
method: 'get',
|
||||
path: CASE_STATUS_URL,
|
||||
security: DEFAULT_CASES_ROUTE_SECURITY,
|
||||
options: { deprecated: true },
|
||||
routerOptions: {
|
||||
access: isServerless ? 'internal' : 'public',
|
||||
summary: `Get case status summary`,
|
||||
tags: ['oas-tag:cases'],
|
||||
description:
|
||||
'Returns the number of cases that are open, closed, and in progress in the default space.',
|
||||
// You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.
|
||||
deprecated: {
|
||||
documentationUrl: docLinks.links.cases.legacyApiDeprecations,
|
||||
severity: 'warning',
|
||||
reason: {
|
||||
type: 'remove',
|
||||
},
|
||||
},
|
||||
},
|
||||
handler: async ({ context, request, response }) => {
|
||||
try {
|
||||
const caseContext = await context.cases;
|
||||
const client = await caseContext.getCasesClient();
|
||||
|
||||
const res: statsApiV1.CasesStatusResponse = await client.metrics.getStatusTotalsByType(
|
||||
request.query as statsApiV1.CasesStatusRequest
|
||||
);
|
||||
|
||||
return response.ok({
|
||||
body: res,
|
||||
});
|
||||
} catch (error) {
|
||||
throw createCaseError({
|
||||
message: `Failed to get status stats in route: ${error}`,
|
||||
error,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
|
@ -20,7 +20,6 @@ import {
|
|||
CASE_CONFIGURE_SAVED_OBJECT,
|
||||
CASE_REPORTERS_URL,
|
||||
CASE_SAVED_OBJECT,
|
||||
CASE_STATUS_URL,
|
||||
CASE_TAGS_URL,
|
||||
CASE_USER_ACTION_SAVED_OBJECT,
|
||||
INTERNAL_CASE_METRICS_URL,
|
||||
|
@ -48,7 +47,6 @@ import {
|
|||
CasesBulkGetResponse,
|
||||
CasesFindResponse,
|
||||
CasesPatchRequest,
|
||||
CasesStatusResponse,
|
||||
CustomFieldPutRequest,
|
||||
GetRelatedCasesByAlertResponse,
|
||||
SimilarCasesSearchRequest,
|
||||
|
@ -450,26 +448,6 @@ export const updateCase = async ({
|
|||
return cases;
|
||||
};
|
||||
|
||||
export const getAllCasesStatuses = async ({
|
||||
supertest,
|
||||
expectedHttpCode = 200,
|
||||
auth = { user: superUser, space: null },
|
||||
query = {},
|
||||
}: {
|
||||
supertest: SuperTest.Agent;
|
||||
expectedHttpCode?: number;
|
||||
auth?: { user: User; space: string | null };
|
||||
query?: Record<string, unknown>;
|
||||
}): Promise<CasesStatusResponse> => {
|
||||
const { body: statuses } = await supertest
|
||||
.get(`${getSpaceUrlPrefix(auth.space)}${CASE_STATUS_URL}`)
|
||||
.auth(auth.user.username, auth.user.password)
|
||||
.query({ ...query })
|
||||
.expect(expectedHttpCode);
|
||||
|
||||
return statuses;
|
||||
};
|
||||
|
||||
export const getCase = async ({
|
||||
supertest,
|
||||
caseId,
|
||||
|
|
|
@ -1,295 +0,0 @@
|
|||
/*
|
||||
* 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 { CaseStatuses } from '@kbn/cases-plugin/common/types/domain';
|
||||
import { CASE_STATUS_URL } from '@kbn/cases-plugin/common/constants';
|
||||
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
|
||||
|
||||
import { getPostCaseRequest, postCaseReq } from '../../../../../common/lib/mock';
|
||||
import {
|
||||
createCase,
|
||||
updateCase,
|
||||
getAllCasesStatuses,
|
||||
deleteAllCaseItems,
|
||||
superUserSpace1Auth,
|
||||
extractWarningValueFromWarningHeader,
|
||||
} from '../../../../../common/lib/api';
|
||||
import {
|
||||
globalRead,
|
||||
noKibanaPrivileges,
|
||||
obsOnlyRead,
|
||||
obsSecRead,
|
||||
secOnly,
|
||||
secOnlyRead,
|
||||
superUser,
|
||||
} from '../../../../../common/lib/authentication/users';
|
||||
import { assertWarningHeader } from '../../../../../common/lib/validation';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default ({ getService }: FtrProviderContext): void => {
|
||||
const supertest = getService('supertest');
|
||||
const es = getService('es');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
|
||||
describe('get_status', () => {
|
||||
it('should return case statuses', async () => {
|
||||
const [, inProgressCase, postedCase] = await Promise.all([
|
||||
createCase(supertest, postCaseReq),
|
||||
createCase(supertest, postCaseReq),
|
||||
createCase(supertest, postCaseReq),
|
||||
]);
|
||||
|
||||
await updateCase({
|
||||
supertest,
|
||||
params: {
|
||||
cases: [
|
||||
{
|
||||
id: inProgressCase.id,
|
||||
version: inProgressCase.version,
|
||||
status: CaseStatuses['in-progress'],
|
||||
},
|
||||
{
|
||||
id: postedCase.id,
|
||||
version: postedCase.version,
|
||||
status: CaseStatuses.closed,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const statuses = await getAllCasesStatuses({ supertest });
|
||||
|
||||
expect(statuses).to.eql({
|
||||
count_open_cases: 1,
|
||||
count_closed_cases: 1,
|
||||
count_in_progress_cases: 1,
|
||||
});
|
||||
});
|
||||
|
||||
describe('range queries', () => {
|
||||
before(async () => {
|
||||
await deleteAllCaseItems(es);
|
||||
await kibanaServer.importExport.load(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/cases/8.2.0/cases_various_dates.json'
|
||||
);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await kibanaServer.importExport.unload(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/cases/8.2.0/cases_various_dates.json'
|
||||
);
|
||||
await deleteAllCaseItems(es);
|
||||
});
|
||||
|
||||
it('returns all cases without a range filter', async () => {
|
||||
const statuses = await getAllCasesStatuses({ supertest });
|
||||
|
||||
expect(statuses).to.eql({
|
||||
count_open_cases: 3,
|
||||
count_closed_cases: 0,
|
||||
count_in_progress_cases: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('respects the range parameters', async () => {
|
||||
const queries = [
|
||||
{ expectedCases: 2, query: { from: '2022-03-16' } },
|
||||
{ expectedCases: 2, query: { to: '2022-03-21' } },
|
||||
{ expectedCases: 2, query: { from: '2022-03-15', to: '2022-03-21' } },
|
||||
];
|
||||
|
||||
for (const query of queries) {
|
||||
const statuses = await getAllCasesStatuses({ supertest, query: query.query });
|
||||
expect(statuses).to.eql({
|
||||
count_open_cases: query.expectedCases,
|
||||
count_closed_cases: 0,
|
||||
count_in_progress_cases: 0,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('escapes correctly', async () => {
|
||||
const statuses = await getAllCasesStatuses({
|
||||
supertest,
|
||||
query: { from: '2022-03-15T10:16:56.252Z', to: '2022-03-20T10:16:56.252' },
|
||||
});
|
||||
|
||||
expect(statuses).to.eql({
|
||||
count_open_cases: 2,
|
||||
count_closed_cases: 0,
|
||||
count_in_progress_cases: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('rbac', () => {
|
||||
afterEach(async () => {
|
||||
await deleteAllCaseItems(es);
|
||||
});
|
||||
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
|
||||
it('should return the correct status stats', async () => {
|
||||
/**
|
||||
* Owner: Sec
|
||||
* open: 0, in-prog: 1, closed: 1
|
||||
* Owner: Obs
|
||||
* open: 1, in-prog: 1
|
||||
*/
|
||||
const [inProgressSec, closedSec, , inProgressObs] = await Promise.all([
|
||||
createCase(supertestWithoutAuth, getPostCaseRequest(), 200, {
|
||||
user: superUser,
|
||||
space: 'space1',
|
||||
}),
|
||||
createCase(supertestWithoutAuth, getPostCaseRequest(), 200, {
|
||||
user: superUser,
|
||||
space: 'space1',
|
||||
}),
|
||||
createCase(
|
||||
supertestWithoutAuth,
|
||||
getPostCaseRequest({ owner: 'observabilityFixture' }),
|
||||
200,
|
||||
superUserSpace1Auth
|
||||
),
|
||||
createCase(
|
||||
supertestWithoutAuth,
|
||||
getPostCaseRequest({ owner: 'observabilityFixture' }),
|
||||
200,
|
||||
superUserSpace1Auth
|
||||
),
|
||||
]);
|
||||
|
||||
await updateCase({
|
||||
supertest: supertestWithoutAuth,
|
||||
params: {
|
||||
cases: [
|
||||
{
|
||||
id: inProgressSec.id,
|
||||
version: inProgressSec.version,
|
||||
status: CaseStatuses['in-progress'],
|
||||
},
|
||||
{
|
||||
id: closedSec.id,
|
||||
version: closedSec.version,
|
||||
status: CaseStatuses.closed,
|
||||
},
|
||||
{
|
||||
id: inProgressObs.id,
|
||||
version: inProgressObs.version,
|
||||
status: CaseStatuses['in-progress'],
|
||||
},
|
||||
],
|
||||
},
|
||||
auth: superUserSpace1Auth,
|
||||
});
|
||||
|
||||
for (const scenario of [
|
||||
{ user: globalRead, stats: { open: 1, inProgress: 2, closed: 1 } },
|
||||
{ user: superUser, stats: { open: 1, inProgress: 2, closed: 1 } },
|
||||
{ user: secOnlyRead, stats: { open: 0, inProgress: 1, closed: 1 } },
|
||||
{ user: obsOnlyRead, stats: { open: 1, inProgress: 1, closed: 0 } },
|
||||
{ user: obsSecRead, stats: { open: 1, inProgress: 2, closed: 1 } },
|
||||
{
|
||||
user: obsSecRead,
|
||||
stats: { open: 1, inProgress: 1, closed: 0 },
|
||||
owner: 'observabilityFixture',
|
||||
},
|
||||
{
|
||||
user: obsSecRead,
|
||||
stats: { open: 1, inProgress: 2, closed: 1 },
|
||||
owner: ['observabilityFixture', 'securitySolutionFixture'],
|
||||
},
|
||||
]) {
|
||||
const statuses = await getAllCasesStatuses({
|
||||
supertest: supertestWithoutAuth,
|
||||
auth: { user: scenario.user, space: 'space1' },
|
||||
query: {
|
||||
owner: scenario.owner,
|
||||
},
|
||||
});
|
||||
|
||||
expect(statuses).to.eql({
|
||||
count_open_cases: scenario.stats.open,
|
||||
count_closed_cases: scenario.stats.closed,
|
||||
count_in_progress_cases: scenario.stats.inProgress,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
for (const scenario of [
|
||||
{ user: noKibanaPrivileges, space: 'space1' },
|
||||
{ user: secOnly, space: 'space2' },
|
||||
]) {
|
||||
it(`should return a 403 when retrieving the statuses when the user ${
|
||||
scenario.user.username
|
||||
} with role(s) ${scenario.user.roles.join()} and space ${scenario.space}`, async () => {
|
||||
await createCase(supertestWithoutAuth, getPostCaseRequest(), 200, {
|
||||
user: superUser,
|
||||
space: scenario.space,
|
||||
});
|
||||
|
||||
await getAllCasesStatuses({
|
||||
supertest: supertestWithoutAuth,
|
||||
auth: { user: scenario.user, space: scenario.space },
|
||||
expectedHttpCode: 403,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('range queries', () => {
|
||||
before(async () => {
|
||||
await kibanaServer.importExport.load(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/cases/8.2.0/cases_various_dates.json',
|
||||
{ space: 'space1' }
|
||||
);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await kibanaServer.importExport.unload(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/cases/8.2.0/cases_various_dates.json',
|
||||
{ space: 'space1' }
|
||||
);
|
||||
await deleteAllCaseItems(es);
|
||||
});
|
||||
|
||||
it('should respect the owner filter when using range queries', async () => {
|
||||
const res = await getAllCasesStatuses({
|
||||
supertest: supertestWithoutAuth,
|
||||
query: {
|
||||
from: '2022-03-15',
|
||||
to: '2022-03-21',
|
||||
},
|
||||
auth: {
|
||||
user: secOnly,
|
||||
space: 'space1',
|
||||
},
|
||||
});
|
||||
|
||||
expect(res).to.eql({
|
||||
count_open_cases: 1,
|
||||
count_closed_cases: 0,
|
||||
count_in_progress_cases: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deprecations', () => {
|
||||
it('should return a warning header', async () => {
|
||||
await createCase(supertest, postCaseReq);
|
||||
const res = await supertest.get(CASE_STATUS_URL).expect(200);
|
||||
const warningHeader = res.header.warning;
|
||||
|
||||
assertWarningHeader(warningHeader);
|
||||
|
||||
const warningValue = extractWarningValueFromWarningHeader(warningHeader);
|
||||
expect(warningValue).to.be('Deprecated endpoint');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
|
@ -31,7 +31,6 @@ export default ({ loadTestFile }: FtrProviderContext): void => {
|
|||
loadTestFile(require.resolve('./cases/post_case'));
|
||||
loadTestFile(require.resolve('./cases/resolve_case'));
|
||||
loadTestFile(require.resolve('./cases/reporters/get_reporters'));
|
||||
loadTestFile(require.resolve('./cases/status/get_status'));
|
||||
loadTestFile(require.resolve('./cases/tags/get_tags'));
|
||||
loadTestFile(require.resolve('./cases/categories/get_categories'));
|
||||
loadTestFile(require.resolve('./user_actions/find_user_actions'));
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* 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 { CaseStatuses } from '@kbn/cases-plugin/common/types/domain';
|
||||
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
|
||||
|
||||
import { postCaseReq } from '../../../../../common/lib/mock';
|
||||
import {
|
||||
createCase,
|
||||
updateCase,
|
||||
getAllCasesStatuses,
|
||||
deleteAllCaseItems,
|
||||
getAuthWithSuperUser,
|
||||
} from '../../../../../common/lib/api';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default ({ getService }: FtrProviderContext): void => {
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const es = getService('es');
|
||||
const authSpace1 = getAuthWithSuperUser();
|
||||
const authSpace2 = getAuthWithSuperUser('space2');
|
||||
|
||||
describe('get_status', () => {
|
||||
afterEach(async () => {
|
||||
await deleteAllCaseItems(es);
|
||||
});
|
||||
|
||||
it('should return case statuses in space1', async () => {
|
||||
/**
|
||||
* space1:
|
||||
* open: 1
|
||||
* in progress: 1
|
||||
* closed: 0
|
||||
* space2:
|
||||
* closed: 1
|
||||
*/
|
||||
const [, inProgressCase, postedCase] = await Promise.all([
|
||||
createCase(supertestWithoutAuth, postCaseReq, 200, authSpace1),
|
||||
createCase(supertestWithoutAuth, postCaseReq, 200, authSpace1),
|
||||
createCase(supertestWithoutAuth, postCaseReq, 200, authSpace2),
|
||||
]);
|
||||
|
||||
await updateCase({
|
||||
supertest: supertestWithoutAuth,
|
||||
params: {
|
||||
cases: [
|
||||
{
|
||||
id: inProgressCase.id,
|
||||
version: inProgressCase.version,
|
||||
status: CaseStatuses['in-progress'],
|
||||
},
|
||||
],
|
||||
},
|
||||
auth: authSpace1,
|
||||
});
|
||||
|
||||
await updateCase({
|
||||
supertest: supertestWithoutAuth,
|
||||
params: {
|
||||
cases: [
|
||||
{
|
||||
id: postedCase.id,
|
||||
version: postedCase.version,
|
||||
status: CaseStatuses.closed,
|
||||
},
|
||||
],
|
||||
},
|
||||
auth: authSpace2,
|
||||
});
|
||||
|
||||
const statusesSpace1 = await getAllCasesStatuses({
|
||||
supertest: supertestWithoutAuth,
|
||||
auth: authSpace1,
|
||||
});
|
||||
const statusesSpace2 = await getAllCasesStatuses({
|
||||
supertest: supertestWithoutAuth,
|
||||
auth: authSpace2,
|
||||
});
|
||||
|
||||
expect(statusesSpace1).to.eql({
|
||||
count_open_cases: 1,
|
||||
count_closed_cases: 0,
|
||||
count_in_progress_cases: 1,
|
||||
});
|
||||
|
||||
expect(statusesSpace2).to.eql({
|
||||
count_open_cases: 0,
|
||||
count_closed_cases: 1,
|
||||
count_in_progress_cases: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
|
@ -23,7 +23,6 @@ export default ({ loadTestFile }: FtrProviderContext): void => {
|
|||
loadTestFile(require.resolve('./cases/patch_cases'));
|
||||
loadTestFile(require.resolve('./cases/post_case'));
|
||||
loadTestFile(require.resolve('./cases/reporters/get_reporters'));
|
||||
loadTestFile(require.resolve('./cases/status/get_status'));
|
||||
loadTestFile(require.resolve('./cases/tags/get_tags'));
|
||||
loadTestFile(require.resolve('./configure/get_configure'));
|
||||
loadTestFile(require.resolve('./configure/patch_configure'));
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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 { CASE_STATUS_URL } from '@kbn/cases-plugin/common/constants';
|
||||
import type { RoleCredentials } from '../../../../shared/services';
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default ({ getService }: FtrProviderContext): void => {
|
||||
const svlCases = getService('svlCases');
|
||||
const svlUserManager = getService('svlUserManager');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const svlCommonApi = getService('svlCommonApi');
|
||||
|
||||
describe('get_status', () => {
|
||||
let roleAuthc: RoleCredentials;
|
||||
|
||||
before(async () => {
|
||||
roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('admin');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await svlUserManager.invalidateM2mApiKeyWithRoleScope(roleAuthc);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await svlCases.api.deleteCases();
|
||||
});
|
||||
|
||||
it('should fetch the status correctly with internal request headers', async () => {
|
||||
await supertestWithoutAuth
|
||||
.get(CASE_STATUS_URL)
|
||||
.set(svlCommonApi.getInternalRequestHeader())
|
||||
.set(roleAuthc.apiKeyHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('should not fetch the status correctly with no internal request headers', async () => {
|
||||
await supertestWithoutAuth.get(CASE_STATUS_URL).set(roleAuthc.apiKeyHeader).expect(400);
|
||||
});
|
||||
});
|
||||
};
|
|
@ -12,6 +12,5 @@ export default function ({ loadTestFile }: FtrProviderContext) {
|
|||
loadTestFile(require.resolve('./get_case'));
|
||||
loadTestFile(require.resolve('./find_cases'));
|
||||
loadTestFile(require.resolve('./post_case'));
|
||||
loadTestFile(require.resolve('./get_status'));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue