[Ingest Manager] Remove success: true as top-level API response (#73223)

* Big bang commit removing top-level success property in API response

Left in check-permissions and in array of objects returned by delete package configs

* Remove success property from  mocks

* Resolve conflict from upstream changes

* Remove success property (after upstream merge)

* Remove more 'success'es after merging in upstream

* Remove success from some tests

* Remove success from OpenAPI spec

* Revert prior try/catch. Use res.ok

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
John Schulz 2020-09-02 12:07:32 -04:00 committed by GitHub
parent 7b7b013b97
commit 71b9dedfc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 58 additions and 229 deletions

View file

@ -43,12 +43,9 @@
},
"perPage": {
"type": "number"
},
"success": {
"type": "boolean"
}
},
"required": ["items", "total", "page", "perPage", "success"]
"required": ["items", "total", "page", "perPage"]
},
"examples": {
"success": {
@ -71,8 +68,7 @@
],
"total": 1,
"page": 1,
"perPage": 50,
"success": true
"perPage": 50
}
}
}
@ -107,9 +103,6 @@
"properties": {
"item": {
"$ref": "#/components/schemas/AgentPolicy"
},
"success": {
"type": "boolean"
}
}
}
@ -159,12 +152,9 @@
"properties": {
"item": {
"$ref": "#/components/schemas/AgentPolicy"
},
"success": {
"type": "boolean"
}
},
"required": ["item", "success"]
"required": ["item"]
},
"examples": {
"success": {
@ -707,8 +697,7 @@
"revision": 2,
"updated_on": "2020-05-06T17:32:21.905Z",
"updated_by": "system"
},
"success": true
}
}
}
}
@ -733,12 +722,9 @@
"properties": {
"item": {
"$ref": "#/components/schemas/AgentPolicy"
},
"success": {
"type": "boolean"
}
},
"required": ["item", "success"]
"required": ["item"]
},
"examples": {
"example-1": {
@ -751,8 +737,7 @@
"updated_on": "Fri Feb 28 2020 16:22:31 GMT-0500 (Eastern Standard Time)",
"updated_by": "elastic",
"packagePolicies": []
},
"success": true
}
}
}
}
@ -810,12 +795,9 @@
"properties": {
"item": {
"$ref": "#/components/schemas/AgentPolicy"
},
"success": {
"type": "boolean"
}
},
"required": ["item", "success"]
"required": ["item"]
}
}
}
@ -948,12 +930,9 @@
},
"perPage": {
"type": "number"
},
"success": {
"type": "boolean"
}
},
"required": ["items", "success"]
"required": ["items"]
},
"examples": {
"example-1": {
@ -1157,8 +1136,7 @@
],
"total": 6,
"page": 1,
"perPage": 20,
"success": true
"perPage": 20
}
}
}
@ -1251,12 +1229,9 @@
"properties": {
"item": {
"$ref": "#/components/schemas/PackagePolicy"
},
"success": {
"type": "boolean"
}
},
"required": ["item", "success"]
"required": ["item"]
}
}
}
@ -1415,9 +1390,6 @@
"properties": {
"response": {
"$ref": "#/components/schemas/PackageInfo"
},
"success": {
"type": "boolean"
}
}
},
@ -1709,8 +1681,7 @@
},
"references": []
}
},
"success": true
}
}
},
"required-package": {
@ -1899,8 +1870,7 @@
},
"references": []
}
},
"success": true
}
}
}
}
@ -1950,12 +1920,9 @@
},
"required": ["id", "type"]
}
},
"success": {
"type": "boolean"
}
},
"required": ["response", "success"]
"required": ["response"]
}
}
}
@ -1994,12 +1961,9 @@
},
"required": ["id", "type"]
}
},
"success": {
"type": "boolean"
}
},
"required": ["response", "success"]
"required": ["response"]
}
}
}
@ -2678,8 +2642,7 @@
"version": "1.0.0",
"status": "not_installed"
}
],
"success": true
]
}
}
}
@ -2743,9 +2706,6 @@
"type": "object"
}
},
"success": {
"type": "boolean"
},
"total": {
"type": "number"
},
@ -2756,7 +2716,7 @@
"type": "number"
}
},
"required": ["list", "success", "total", "page", "perPage"]
"required": ["list", "total", "page", "perPage"]
},
"examples": {
"example-1": {
@ -2793,7 +2753,6 @@
"status": "online"
}
],
"success": true,
"total": 1,
"page": 1,
"perPage": 20
@ -2836,12 +2795,9 @@
"properties": {
"item": {
"type": "object"
},
"success": {
"type": "string"
}
},
"required": ["item", "success"]
"required": ["item"]
}
}
}
@ -2916,9 +2872,6 @@
"type": "string",
"enum": ["checkin"]
},
"success": {
"type": "string"
},
"actions": {
"type": "array",
"items": {
@ -2950,7 +2903,6 @@
"success": {
"value": {
"action": "checkin",
"success": true,
"actions": [
{
"agent_id": "a6f14bd2-1a2a-481c-9212-9494d064ffdf",
@ -3346,21 +3298,17 @@
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"action": {
"type": "string",
"enum": ["acks"]
}
},
"required": ["success", "action"]
"required": ["action"]
},
"examples": {
"success": {
"value": {
"action": "checkin",
"success": true
"action": "checkin"
}
}
}
@ -3417,9 +3365,6 @@
"action": {
"type": "string"
},
"success": {
"type": "boolean"
},
"item": {
"$ref": "#/components/schemas/Agent"
}
@ -3429,7 +3374,6 @@
"success": {
"value": {
"action": "created",
"success": true,
"item": {
"id": "8086fb1a-72ca-4a67-8533-09300c1639fa",
"active": true,

View file

@ -28,7 +28,6 @@ export interface GetAgentsResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}
export interface GetOneAgentRequest {
@ -39,7 +38,6 @@ export interface GetOneAgentRequest {
export interface GetOneAgentResponse {
item: Agent;
success: boolean;
}
export interface PostAgentCheckinRequest {
@ -55,7 +53,7 @@ export interface PostAgentCheckinRequest {
export interface PostAgentCheckinResponse {
action: string;
success: boolean;
actions: AgentAction[];
}
@ -72,7 +70,7 @@ export interface PostAgentEnrollRequest {
export interface PostAgentEnrollResponse {
action: string;
success: boolean;
item: Agent & { status: AgentStatus };
}
@ -87,7 +85,6 @@ export interface PostAgentAcksRequest {
export interface PostAgentAcksResponse {
action: string;
success: boolean;
}
export interface PostNewAgentActionRequest {
@ -100,7 +97,6 @@ export interface PostNewAgentActionRequest {
}
export interface PostNewAgentActionResponse {
success: boolean;
item: AgentAction;
}
@ -110,9 +106,8 @@ export interface PostAgentUnenrollRequest {
};
}
export interface PostAgentUnenrollResponse {
success: boolean;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PostAgentUnenrollResponse {}
export interface PutAgentReassignRequest {
params: {
@ -121,9 +116,8 @@ export interface PutAgentReassignRequest {
body: { policy_id: string };
}
export interface PutAgentReassignResponse {
success: boolean;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PutAgentReassignResponse {}
export interface GetOneAgentEventsRequest {
params: {
@ -141,7 +135,6 @@ export interface GetOneAgentEventsResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}
export interface DeleteAgentRequest {
@ -166,7 +159,6 @@ export interface GetAgentStatusRequest {
}
export interface GetAgentStatusResponse {
success: boolean;
results: {
events: number;
total: number;

View file

@ -19,7 +19,6 @@ export interface GetAgentPoliciesResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}
export interface GetOneAgentPolicyRequest {
@ -30,7 +29,6 @@ export interface GetOneAgentPolicyRequest {
export interface GetOneAgentPolicyResponse {
item: AgentPolicy;
success: boolean;
}
export interface CreateAgentPolicyRequest {
@ -39,7 +37,6 @@ export interface CreateAgentPolicyRequest {
export interface CreateAgentPolicyResponse {
item: AgentPolicy;
success: boolean;
}
export type UpdateAgentPolicyRequest = GetOneAgentPolicyRequest & {
@ -48,7 +45,6 @@ export type UpdateAgentPolicyRequest = GetOneAgentPolicyRequest & {
export interface UpdateAgentPolicyResponse {
item: AgentPolicy;
success: boolean;
}
export interface CopyAgentPolicyRequest {
@ -57,7 +53,6 @@ export interface CopyAgentPolicyRequest {
export interface CopyAgentPolicyResponse {
item: AgentPolicy;
success: boolean;
}
export interface DeleteAgentPolicyRequest {
@ -68,7 +63,6 @@ export interface DeleteAgentPolicyRequest {
export interface DeleteAgentPolicyResponse {
id: string;
success: boolean;
}
export interface GetFullAgentPolicyRequest {
@ -79,5 +73,4 @@ export interface GetFullAgentPolicyRequest {
export interface GetFullAgentPolicyResponse {
item: FullAgentPolicy;
success: boolean;
}

View file

@ -19,7 +19,6 @@ export interface GetEnrollmentAPIKeysResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}
export interface GetOneEnrollmentAPIKeyRequest {
@ -30,7 +29,6 @@ export interface GetOneEnrollmentAPIKeyRequest {
export interface GetOneEnrollmentAPIKeyResponse {
item: EnrollmentAPIKey;
success: boolean;
}
export interface DeleteEnrollmentAPIKeyRequest {
@ -41,7 +39,6 @@ export interface DeleteEnrollmentAPIKeyRequest {
export interface DeleteEnrollmentAPIKeyResponse {
action: string;
success: boolean;
}
export interface PostEnrollmentAPIKeyRequest {
@ -55,5 +52,4 @@ export interface PostEnrollmentAPIKeyRequest {
export interface PostEnrollmentAPIKeyResponse {
action: string;
item: EnrollmentAPIKey;
success: boolean;
}

View file

@ -20,7 +20,6 @@ export interface GetCategoriesRequest {
export interface GetCategoriesResponse {
response: CategorySummaryList;
success: boolean;
}
export interface GetPackagesRequest {
@ -39,12 +38,10 @@ export interface GetPackagesResponse {
>
>
>;
success: boolean;
}
export interface GetLimitedPackagesResponse {
response: string[];
success: boolean;
}
export interface GetFileRequest {
@ -62,7 +59,6 @@ export interface GetInfoRequest {
export interface GetInfoResponse {
response: PackageInfo;
success: boolean;
}
export interface InstallPackageRequest {
@ -73,7 +69,6 @@ export interface InstallPackageRequest {
export interface InstallPackageResponse {
response: AssetReference[];
success: boolean;
}
export interface DeletePackageRequest {
@ -84,5 +79,4 @@ export interface DeletePackageRequest {
export interface DeletePackageResponse {
response: AssetReference[];
success: boolean;
}

View file

@ -7,7 +7,6 @@ import { Output } from '../models';
export interface GetOneOutputResponse {
item: Output;
success: boolean;
}
export interface GetOneOutputRequest {
@ -28,7 +27,6 @@ export interface PutOutputRequest {
export interface PutOutputResponse {
item: Output;
success: boolean;
}
export interface GetOutputsResponse {
@ -36,5 +34,4 @@ export interface GetOutputsResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}

View file

@ -18,7 +18,6 @@ export interface GetPackagePoliciesResponse {
total: number;
page: number;
perPage: number;
success: boolean;
}
export interface GetOnePackagePolicyRequest {
@ -29,7 +28,6 @@ export interface GetOnePackagePolicyRequest {
export interface GetOnePackagePolicyResponse {
item: PackagePolicy;
success: boolean;
}
export interface CreatePackagePolicyRequest {
@ -38,7 +36,6 @@ export interface CreatePackagePolicyRequest {
export interface CreatePackagePolicyResponse {
item: PackagePolicy;
success: boolean;
}
export type UpdatePackagePolicyRequest = GetOnePackagePolicyRequest & {

View file

@ -7,7 +7,6 @@ import { Settings } from '../models';
export interface GetSettingsResponse {
item: Settings;
success: boolean;
}
export interface PutSettingsRequest {
@ -16,5 +15,4 @@ export interface PutSettingsRequest {
export interface PutSettingsResponse {
item: Settings;
success: boolean;
}

View file

@ -61,7 +61,7 @@ export const AgentPolicyCopyProvider: React.FunctionComponent<Props> = ({ childr
try {
const { data } = await sendCopyAgentPolicy(agentPolicy!.id, newAgentPolicy!);
if (data?.success) {
if (data) {
notifications.toasts.addSuccess(
i18n.translate('xpack.ingestManager.copyAgentPolicy.successNotificationTitle', {
defaultMessage: 'Agent policy copied',
@ -70,9 +70,7 @@ export const AgentPolicyCopyProvider: React.FunctionComponent<Props> = ({ childr
if (onSuccessCallback.current) {
onSuccessCallback.current(data.item);
}
}
if (!data?.success) {
} else {
notifications.toasts.addDanger(
i18n.translate('xpack.ingestManager.copyAgentPolicy.failureNotificationTitle', {
defaultMessage: "Error copying agent policy '{id}'",

View file

@ -59,7 +59,7 @@ export const AgentPolicyDeleteProvider: React.FunctionComponent<Props> = ({ chil
agentPolicyId: agentPolicy!,
});
if (data?.success) {
if (data) {
notifications.toasts.addSuccess(
i18n.translate('xpack.ingestManager.deleteAgentPolicy.successSingleNotificationTitle', {
defaultMessage: "Deleted agent policy '{id}'",
@ -69,9 +69,7 @@ export const AgentPolicyDeleteProvider: React.FunctionComponent<Props> = ({ chil
if (onSuccessCallback.current) {
onSuccessCallback.current(agentPolicy!);
}
}
if (!data?.success) {
} else {
notifications.toasts.addDanger(
i18n.translate('xpack.ingestManager.deleteAgentPolicy.failureSingleNotificationTitle', {
defaultMessage: "Error deleting agent policy '{id}'",

View file

@ -82,7 +82,7 @@ export const SettingsView = memo<{ agentPolicy: AgentPolicy }>(
namespace,
monitoring_enabled,
});
if (data?.success) {
if (data) {
notifications.toasts.addSuccess(
i18n.translate('xpack.ingestManager.editAgentPolicy.successNotificationTitle', {
defaultMessage: "Successfully updated '{name}' settings",

View file

@ -116,7 +116,7 @@ export const CreateAgentPolicyFlyout: React.FunctionComponent<Props> = ({
try {
const { data, error } = await createAgentPolicy();
setIsLoading(false);
if (data?.success) {
if (data) {
notifications.toasts.addSuccess(
i18n.translate(
'xpack.ingestManager.createAgentPolicy.successNotificationTitle',

View file

@ -122,7 +122,7 @@ async function enroll(kibanaURL: string, apiKey: string, log: ToolingLog): Promi
});
const obj: PostAgentEnrollResponse = await res.json();
if (!obj.success) {
if (!res.ok) {
log.error(JSON.stringify(obj, null, 2));
throw new Error('unable to enroll');
}

View file

@ -88,7 +88,6 @@ describe('test acks handlers', () => {
await postAgentAcksHandler(({} as unknown) as RequestHandlerContext, mockRequest, mockResponse);
expect(mockResponse.ok.mock.calls[0][0]?.body as PostAgentAcksResponse).toEqual({
action: 'acks',
success: true,
});
});
});

View file

@ -46,7 +46,6 @@ export const postAgentAcksHandlerBuilder = function (
const body: PostAgentAcksResponse = {
action: 'acks',
success: true,
};
return response.ok({ body });

View file

@ -97,6 +97,5 @@ describe('test actions handlers', () => {
?.body as unknown) as PostNewAgentActionResponse;
expect(expectedAgentActionResponse.item).toEqual(agentAction);
expect(expectedAgentActionResponse.success).toEqual(true);
});
});

View file

@ -35,7 +35,6 @@ export const postNewAgentActionHandlerBuilder = function (
});
const body: PostNewAgentActionResponse = {
success: true,
item: savedAgentAction,
};

View file

@ -43,7 +43,6 @@ export const getAgentHandler: RequestHandler<TypeOf<
...agent,
status: AgentService.getAgentStatus(agent),
},
success: true,
};
return response.ok({ body });
@ -77,7 +76,6 @@ export const getAgentEventsHandler: RequestHandler<
const body: GetOneAgentEventsResponse = {
list: items,
total,
success: true,
page,
perPage,
};
@ -107,7 +105,6 @@ export const deleteAgentHandler: RequestHandler<TypeOf<
await AgentService.deleteAgent(soClient, request.params.agentId);
const body = {
success: true,
action: 'deleted',
};
@ -144,7 +141,6 @@ export const updateAgentHandler: RequestHandler<
...agent,
status: AgentService.getAgentStatus(agent),
},
success: true,
};
return response.ok({ body });
@ -187,7 +183,6 @@ export const postAgentCheckinHandler: RequestHandler<
);
const body: PostAgentCheckinResponse = {
action: 'checkin',
success: true,
actions: actions.map((a) => ({
agent_id: agent.id,
type: a.type,
@ -248,7 +243,6 @@ export const postAgentEnrollHandler: RequestHandler<
);
const body: PostAgentEnrollResponse = {
action: 'created',
success: true,
item: {
...agent,
status: AgentService.getAgentStatus(agent),
@ -289,7 +283,6 @@ export const getAgentsHandler: RequestHandler<
...agent,
status: AgentService.getAgentStatus(agent),
})),
success: true,
total,
page,
perPage,
@ -312,9 +305,7 @@ export const putAgentsReassignHandler: RequestHandler<
try {
await AgentService.reassignAgent(soClient, request.params.agentId, request.body.policy_id);
const body: PutAgentReassignResponse = {
success: true,
};
const body: PutAgentReassignResponse = {};
return response.ok({ body });
} catch (e) {
return response.customError({
@ -336,7 +327,7 @@ export const getAgentStatusForAgentPolicyHandler: RequestHandler<
request.query.policyId
);
const body: GetAgentStatusResponse = { results, success: true };
const body: GetAgentStatusResponse = { results };
return response.ok({ body });
} catch (e) {

View file

@ -23,9 +23,7 @@ export const postAgentsUnenrollHandler: RequestHandler<
await AgentService.unenrollAgent(soClient, request.params.agentId);
}
const body: PostAgentUnenrollResponse = {
success: true,
};
const body: PostAgentUnenrollResponse = {};
return response.ok({ body });
} catch (e) {
return response.customError({

View file

@ -49,7 +49,6 @@ export const getAgentPoliciesHandler: RequestHandler<
total,
page,
perPage,
success: true,
};
await bluebird.map(
@ -82,7 +81,6 @@ export const getOneAgentPolicyHandler: RequestHandler<TypeOf<
if (agentPolicy) {
const body: GetOneAgentPolicyResponse = {
item: agentPolicy,
success: true,
};
return response.ok({
body,
@ -141,7 +139,6 @@ export const createAgentPolicyHandler: RequestHandler<
const body: CreateAgentPolicyResponse = {
item: agentPolicy,
success: true,
};
return response.ok({
@ -171,7 +168,7 @@ export const updateAgentPolicyHandler: RequestHandler<
user: user || undefined,
}
);
const body: UpdateAgentPolicyResponse = { item: agentPolicy, success: true };
const body: UpdateAgentPolicyResponse = { item: agentPolicy };
return response.ok({
body,
});
@ -199,7 +196,7 @@ export const copyAgentPolicyHandler: RequestHandler<
user: user || undefined,
}
);
const body: CopyAgentPolicyResponse = { item: agentPolicy, success: true };
const body: CopyAgentPolicyResponse = { item: agentPolicy };
return response.ok({
body,
});
@ -248,7 +245,6 @@ export const getFullAgentPolicy: RequestHandler<
if (fullAgentPolicy) {
const body: GetFullAgentPolicyResponse = {
item: fullAgentPolicy,
success: true,
};
return response.ok({
body,

View file

@ -31,7 +31,7 @@ export const getEnrollmentApiKeysHandler: RequestHandler<
perPage: request.query.perPage,
kuery: request.query.kuery,
});
const body: GetEnrollmentAPIKeysResponse = { list: items, success: true, total, page, perPage };
const body: GetEnrollmentAPIKeysResponse = { list: items, total, page, perPage };
return response.ok({ body });
} catch (e) {
@ -54,7 +54,7 @@ export const postEnrollmentApiKeyHandler: RequestHandler<
agentPolicyId: request.body.policy_id,
});
const body: PostEnrollmentAPIKeyResponse = { item: apiKey, success: true, action: 'created' };
const body: PostEnrollmentAPIKeyResponse = { item: apiKey, action: 'created' };
return response.ok({ body });
} catch (e) {
@ -78,7 +78,7 @@ export const deleteEnrollmentApiKeyHandler: RequestHandler<TypeOf<
try {
await APIKeyService.deleteEnrollmentApiKey(soClient, request.params.keyId);
const body: DeleteEnrollmentAPIKeyResponse = { action: 'deleted', success: true };
const body: DeleteEnrollmentAPIKeyResponse = { action: 'deleted' };
return response.ok({ body });
} catch (e) {
@ -100,7 +100,7 @@ export const getOneEnrollmentApiKeyHandler: RequestHandler<TypeOf<
const soClient = context.core.savedObjects.client;
try {
const apiKey = await APIKeyService.getEnrollmentAPIKey(soClient, request.params.keyId);
const body: GetOneEnrollmentAPIKeyResponse = { item: apiKey, success: true };
const body: GetOneEnrollmentAPIKeyResponse = { item: apiKey };
return response.ok({ body });
} catch (e) {

View file

@ -43,7 +43,6 @@ export const getCategoriesHandler: RequestHandler<
const res = await getCategories(request.query);
const body: GetCategoriesResponse = {
response: res,
success: true,
};
return response.ok({ body });
} catch (e) {
@ -66,7 +65,6 @@ export const getListHandler: RequestHandler<
});
const body: GetPackagesResponse = {
response: res,
success: true,
};
return response.ok({
body,
@ -85,7 +83,6 @@ export const getLimitedListHandler: RequestHandler = async (context, request, re
const res = await getLimitedPackages({ savedObjectsClient });
const body: GetLimitedPackagesResponse = {
response: res,
success: true,
};
return response.ok({
body,
@ -136,7 +133,6 @@ export const getInfoHandler: RequestHandler<TypeOf<typeof GetInfoRequestSchema.p
const res = await getPackageInfo({ savedObjectsClient, pkgName, pkgVersion });
const body: GetInfoResponse = {
response: res,
success: true,
};
return response.ok({ body });
} catch (e) {
@ -166,7 +162,6 @@ export const installPackageHandler: RequestHandler<
});
const body: InstallPackageResponse = {
response: res,
success: true,
};
return response.ok({ body });
} catch (e) {
@ -206,7 +201,6 @@ export const deletePackageHandler: RequestHandler<TypeOf<
const res = await removeInstallation({ savedObjectsClient, pkgkey, callCluster });
const body: DeletePackageResponse = {
response: res,
success: true,
};
return response.ok({ body });
} catch (e) {

View file

@ -20,7 +20,6 @@ export const getOutputsHandler: RequestHandler = async (context, request, respon
page: outputs.page,
perPage: outputs.perPage,
total: outputs.total,
success: true,
};
return response.ok({ body });
@ -41,7 +40,6 @@ export const getOneOuputHandler: RequestHandler<TypeOf<
const body: GetOneOutputResponse = {
item: output,
success: true,
};
return response.ok({ body });
@ -71,7 +69,6 @@ export const putOuputHandler: RequestHandler<
const body: GetOneOutputResponse = {
item: output,
success: true,
};
return response.ok({ body });

View file

@ -34,7 +34,6 @@ export const getPackagePoliciesHandler: RequestHandler<
total,
page,
perPage,
success: true,
},
});
} catch (e) {
@ -59,7 +58,6 @@ export const getOnePackagePolicyHandler: RequestHandler<TypeOf<
return response.ok({
body: {
item: packagePolicy,
success: true,
},
});
} else {
@ -115,7 +113,7 @@ export const createPackagePolicyHandler: RequestHandler<
const packagePolicy = await packagePolicyService.create(soClient, callCluster, newData, {
user,
});
const body: CreatePackagePolicyResponse = { item: packagePolicy, success: true };
const body: CreatePackagePolicyResponse = { item: packagePolicy };
return response.ok({
body,
});
@ -163,7 +161,7 @@ export const updatePackagePolicyHandler: RequestHandler<
{ user }
);
return response.ok({
body: { item: updatedPackagePolicy, success: true },
body: { item: updatedPackagePolicy },
});
} catch (e) {
return response.customError({

View file

@ -16,7 +16,6 @@ export const getSettingsHandler: RequestHandler = async (context, request, respo
try {
const settings = await settingsService.getSettings(soClient);
const body = {
success: true,
item: settings,
};
return response.ok({ body });
@ -47,7 +46,6 @@ export const putSettingsHandler: RequestHandler<
user: user || undefined,
});
const body = {
success: true,
item: settings,
};
return response.ok({ body });

View file

@ -380,7 +380,6 @@ class AgentPolicyService {
await this.triggerAgentPolicyUpdatedEvent(soClient, 'deleted', id);
return {
id,
success: true,
};
}

View file

@ -90,7 +90,6 @@ const endpointListApiPathHandlerMocks = ({
[INGEST_API_EPM_PACKAGES]: (): GetPackagesResponse => {
return {
response: epmPackages,
success: true,
};
},
@ -114,7 +113,6 @@ const endpointListApiPathHandlerMocks = ({
return {
items: [agentPolicy],
total: 10,
success: true,
perPage: 10,
page: 1,
};
@ -132,7 +130,6 @@ const endpointListApiPathHandlerMocks = ({
page: 1,
perPage: 10,
total: endpointPackagePolicies?.length,
success: true,
};
},
};

View file

@ -64,7 +64,6 @@ export const mockPolicyResultList: (options?: {
total,
page: requestPageIndex,
perPage: requestPageSize,
success: true,
};
return mock;
};
@ -81,7 +80,6 @@ export const policyListApiPathHandlers = (totalPolicies: number = 1) => {
[INGEST_API_EPM_PACKAGES]: (): GetPackagesResponse => {
return {
response: [generator.generateEpmPackage()],
success: true,
};
},
};

View file

@ -14,7 +14,7 @@ export default function ({ getService }: FtrProviderContext) {
describe('ingest_manager_agent_policies', () => {
describe('POST /api/ingest_manager/agent_policies', () => {
it('should work with valid values', async () => {
const { body: apiResponse } = await supertest
await supertest
.post(`/api/ingest_manager/agent_policies`)
.set('kbn-xsrf', 'xxxx')
.send({
@ -22,8 +22,6 @@ export default function ({ getService }: FtrProviderContext) {
namespace: 'default',
})
.expect(200);
expect(apiResponse.success).to.be(true);
});
it('should return a 400 with an empty namespace', async () => {
@ -61,7 +59,7 @@ export default function ({ getService }: FtrProviderContext) {
it('should work with valid values', async () => {
const {
body: { success, item },
body: { item },
} = await supertest
.post(`/api/ingest_manager/agent_policies/${TEST_POLICY_ID}/copy`)
.set('kbn-xsrf', 'xxxx')
@ -73,7 +71,6 @@ export default function ({ getService }: FtrProviderContext) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { id, updated_at, ...newPolicy } = item;
expect(success).to.be(true);
expect(newPolicy).to.eql({
name: 'Copied policy',
description: 'Test',

View file

@ -90,7 +90,6 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(apiResponse.action).to.be('acks');
expect(apiResponse.success).to.be(true);
const { body: eventResponse } = await supertest
.get(`/api/ingest_manager/fleet/agents/agent1/events`)
.set('kbn-xsrf', 'xx')

View file

@ -33,7 +33,6 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(apiResponse.success).to.be(true);
expect(apiResponse.item.data).to.eql({ data: 'action_data' });
expect(apiResponse.item.sent_at).to.be('2020-03-18T19:45:02.620Z');
});

View file

@ -102,7 +102,6 @@ export default function (providerContext: FtrProviderContext) {
.expect(200);
expect(apiResponse.action).to.be('checkin');
expect(apiResponse.success).to.be(true);
});
});
}

View file

@ -62,7 +62,6 @@ export default function (providerContext: FtrProviderContext) {
},
})
.expect(200);
expect(enrollmentResponse.success).to.eql(true);
const agentAccessAPIKey = enrollmentResponse.item.access_api_key;
@ -76,14 +75,13 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(checkinApiResponse.success).to.eql(true);
expect(checkinApiResponse.actions).length(1);
expect(checkinApiResponse.actions[0].type).be('CONFIG_CHANGE');
const policyChangeAction = checkinApiResponse.actions[0];
const defaultOutputApiKey = policyChangeAction.data.config.outputs.default.api_key;
// Ack actions
const { body: ackApiResponse } = await supertestWithoutAuth
await supertestWithoutAuth
.post(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}/acks`)
.set('Authorization', `ApiKey ${agentAccessAPIKey}`)
.set('kbn-xsrf', 'xx')
@ -102,7 +100,6 @@ export default function (providerContext: FtrProviderContext) {
],
})
.expect(200);
expect(ackApiResponse.success).to.eql(true);
// Second agent checkin
const { body: secondCheckinApiResponse } = await supertestWithoutAuth
@ -113,7 +110,6 @@ export default function (providerContext: FtrProviderContext) {
events: [],
})
.expect(200);
expect(secondCheckinApiResponse.success).to.eql(true);
expect(secondCheckinApiResponse.actions).length(0);
// Get agent
@ -121,18 +117,16 @@ export default function (providerContext: FtrProviderContext) {
.get(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}`)
.expect(200);
expect(getAgentApiResponse.success).to.eql(true);
expect(getAgentApiResponse.item.packages).to.contain(
'system',
"Agent should run the 'system' package"
);
// Unenroll agent
const { body: unenrollResponse } = await supertest
await supertest
.post(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}/unenroll`)
.set('kbn-xsrf', 'xx')
.expect(200);
expect(unenrollResponse.success).to.eql(true);
// Checkin after unenrollment
const { body: checkinAfterUnenrollResponse } = await supertestWithoutAuth
@ -144,13 +138,12 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(checkinAfterUnenrollResponse.success).to.eql(true);
expect(checkinAfterUnenrollResponse.actions).length(1);
expect(checkinAfterUnenrollResponse.actions[0].type).be('UNENROLL');
const unenrollAction = checkinAfterUnenrollResponse.actions[0];
// ack unenroll actions
const { body: ackUnenrollApiResponse } = await supertestWithoutAuth
await supertestWithoutAuth
.post(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}/acks`)
.set('Authorization', `ApiKey ${agentAccessAPIKey}`)
.set('kbn-xsrf', 'xx')
@ -168,7 +161,6 @@ export default function (providerContext: FtrProviderContext) {
],
})
.expect(200);
expect(ackUnenrollApiResponse.success).to.eql(true);
// Checkin after unenrollment acknowledged
await supertestWithoutAuth

View file

@ -68,7 +68,6 @@ export default function ({ getService }: FtrProviderContext) {
.expect(404);
expect(apiResponse).not.to.eql({
success: true,
action: 'deleted',
});
});
@ -88,7 +87,6 @@ export default function ({ getService }: FtrProviderContext) {
.set('kbn-xsrf', 'xx')
.expect(200);
expect(apiResponse).to.eql({
success: true,
action: 'deleted',
});
});

View file

@ -136,7 +136,6 @@ export default function (providerContext: FtrProviderContext) {
},
})
.expect(200);
expect(apiResponse.success).to.eql(true);
expect(apiResponse.item).to.have.keys('id', 'active', 'access_api_key', 'type', 'policy_id');
});
@ -158,7 +157,7 @@ export default function (providerContext: FtrProviderContext) {
},
})
.expect(200);
expect(apiResponse.success).to.eql(true);
const { body: privileges } = await getEsClientForAPIKey(
providerContext,
apiResponse.item.access_api_key

View file

@ -78,8 +78,7 @@ export default function ({ getService }: FtrProviderContext) {
.auth(users.fleet_admin.username, users.fleet_admin.password)
.expect(200);
expect(apiResponse).to.have.keys('success', 'page', 'total', 'list');
expect(apiResponse.success).to.eql(true);
expect(apiResponse).to.have.keys('page', 'total', 'list');
expect(apiResponse.total).to.eql(4);
});
it('should return the list of agents when requesting as a user with fleet read permissions', async () => {
@ -87,8 +86,7 @@ export default function ({ getService }: FtrProviderContext) {
.get(`/api/ingest_manager/fleet/agents`)
.auth(users.fleet_user.username, users.fleet_user.password)
.expect(200);
expect(apiResponse).to.have.keys('success', 'page', 'total', 'list');
expect(apiResponse.success).to.eql(true);
expect(apiResponse).to.have.keys('page', 'total', 'list');
expect(apiResponse.total).to.eql(4);
});
it('should not return the list of agents when requesting as a user without fleet permissions', async () => {

View file

@ -65,20 +65,17 @@ export default function (providerContext: FtrProviderContext) {
});
it('allow to unenroll using a list of ids', async () => {
const { body } = await supertest
await supertest
.post(`/api/ingest_manager/fleet/agents/agent1/unenroll`)
.set('kbn-xsrf', 'xxx')
.send({
force: true,
})
.expect(200);
expect(body).to.have.keys('success');
expect(body.success).to.be(true);
});
it('should invalidate related API keys', async () => {
const { body } = await supertest
await supertest
.post(`/api/ingest_manager/fleet/agents/agent1/unenroll`)
.set('kbn-xsrf', 'xxx')
.send({
@ -86,9 +83,6 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(body).to.have.keys('success');
expect(body.success).to.be(true);
const {
body: { api_keys: accessAPIKeys },
} = await esClient.security.getApiKey({ id: accessAPIKeyId });

View file

@ -67,13 +67,11 @@ export default function (providerContext: FtrProviderContext) {
});
it('should invalide an existing api keys', async () => {
const { body: apiResponse } = await supertest
await supertest
.delete(`/api/ingest_manager/fleet/enrollment-api-keys/${keyId}`)
.set('kbn-xsrf', 'xxx')
.expect(200);
expect(apiResponse.success).to.eql(true);
const {
body: { api_keys: apiKeys },
} = await es.security.getApiKey({ id: esApiKeyId });
@ -113,7 +111,6 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(200);
expect(apiResponse.success).to.eql(true);
expect(apiResponse.item).to.have.keys('id', 'api_key', 'api_key_id', 'name', 'policy_id');
});
@ -125,7 +122,7 @@ export default function (providerContext: FtrProviderContext) {
policy_id: 'policy1',
})
.expect(200);
expect(apiResponse.success).to.eql(true);
const { body: privileges } = await getEsClientForAPIKey(
providerContext,
apiResponse.item.api_key

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { warnAndSkipTest } from '../../helpers';
@ -34,7 +33,7 @@ export default function ({ getService }: FtrProviderContext) {
it('should work with valid values', async function () {
if (server.enabled) {
const { body: apiResponse } = await supertest
await supertest
.post(`/api/ingest_manager/package_policies`)
.set('kbn-xsrf', 'xxxx')
.send({
@ -52,8 +51,6 @@ export default function ({ getService }: FtrProviderContext) {
},
})
.expect(200);
expect(apiResponse.success).to.be(true);
} else {
warnAndSkipTest(this, log);
}

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../../helpers';
@ -75,11 +74,7 @@ export default function (providerContext: FtrProviderContext) {
});
it('should succeed with a valid id', async function () {
const { body: apiResponse } = await supertest
.get(`/api/ingest_manager/package_policies/${packagePolicyId}`)
.expect(200);
expect(apiResponse.success).to.be(true);
await supertest.get(`/api/ingest_manager/package_policies/${packagePolicyId}`).expect(200);
});
it('should return a 404 with an invalid id', async function () {

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../../helpers';
@ -77,7 +76,7 @@ export default function (providerContext: FtrProviderContext) {
});
it('should work with valid values', async function () {
const { body: apiResponse } = await supertest
await supertest
.put(`/api/ingest_manager/package_policies/${packagePolicyId}`)
.set('kbn-xsrf', 'xxxx')
.send({
@ -95,8 +94,6 @@ export default function (providerContext: FtrProviderContext) {
},
})
.expect(200);
expect(apiResponse.success).to.be(true);
});
it('should return a 500 if there is another package policy with the same name', async function () {

View file

@ -54,7 +54,6 @@ export default function (providerContext: FtrProviderContext) {
},
})
.expect(200);
expect(enrollmentResponse.success).to.eql(true);
agentAccessAPIKey = enrollmentResponse.item.access_api_key;
});