mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
0b7747bef0
Replaces (and appropriately refactors) a number of endpoints that were removed long ago when we decided to kill the UI with the fleetctl release. We turned out not to do this, and now need to restore these missing endpoints. This is not a straight up replacement of the existing code because of refactoring to the DB schemas that was also done in the migration. Most of the replaced code was removed in #1670 and #1686. Fixes #1811, fixes #1810
90 lines
1.9 KiB
JavaScript
90 lines
1.9 KiB
JavaScript
import createRequestMock from 'test/mocks/create_request_mock';
|
|
|
|
const errorResponse = {
|
|
message: 'Resource not found',
|
|
errors: [
|
|
{
|
|
name: 'base',
|
|
reason: 'Resource not found',
|
|
},
|
|
],
|
|
};
|
|
|
|
export default {
|
|
create: {
|
|
valid: (bearerToken, params) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: '/api/v1/kolide/queries',
|
|
method: 'post',
|
|
params,
|
|
response: { query: params },
|
|
responseStatus: 201,
|
|
});
|
|
},
|
|
},
|
|
destroy: {
|
|
valid: (bearerToken, { id }) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: `/api/v1/kolide/queries/id/${id}`,
|
|
method: 'delete',
|
|
response: {},
|
|
});
|
|
},
|
|
},
|
|
load: {
|
|
invalid: (bearerToken, id) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: `/api/v1/kolide/queries/${id}`,
|
|
method: 'get',
|
|
response: errorResponse,
|
|
responseStatus: 404,
|
|
});
|
|
},
|
|
valid: (bearerToken, id) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: `/api/v1/kolide/queries/${id}`,
|
|
method: 'get',
|
|
response: { query: { id } },
|
|
});
|
|
},
|
|
},
|
|
loadAll: {
|
|
valid: (bearerToken) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: '/api/v1/kolide/queries',
|
|
method: 'get',
|
|
response: { queries: [] },
|
|
});
|
|
},
|
|
},
|
|
run: {
|
|
valid: (bearerToken, params) => {
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint: '/api/v1/kolide/queries/run',
|
|
method: 'post',
|
|
params,
|
|
response: { campaign: { id: 1 } },
|
|
});
|
|
},
|
|
},
|
|
update: {
|
|
valid: (bearerToken, query, params) => {
|
|
const endpoint = `/api/v1/kolide/queries/${query.id}`;
|
|
|
|
return createRequestMock({
|
|
bearerToken,
|
|
endpoint,
|
|
method: 'patch',
|
|
params,
|
|
response: { query: { ...query, ...params } },
|
|
});
|
|
},
|
|
},
|
|
};
|