diff --git a/package.json b/package.json index eda87241..c030f687 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,8 @@ "test": "NODE_ENV=test npm run db:ims && jest -i", "test:ci": "NODE_ENV=test npm run db:ims && LOG_LEVEL=fatal jest -i", "test:unit": "NODE_ENV=test jest -i --testMatch='**/?(*.)+(unit).js'", + "test:dc": "docker-compose -f build/docker-compose-unit_test.yml up --build --exit-code-from remediations", + "test:dc-down": "docker-compose -f build/docker-compose-unit_test.yml down", "test:contract": "NODE_ENV=test jest -i --testMatch='**/?(*.)+(contract).js'", "verify": "npm-run-all lint coverage" }, diff --git a/src/api/openapi.yaml b/src/api/openapi.yaml index 9543245f..7f349f40 100644 --- a/src/api/openapi.yaml +++ b/src/api/openapi.yaml @@ -1117,19 +1117,14 @@ components: properties: pending: type: integer - nullable: true running: type: integer - nullable: true success: type: integer - nullable: true failure: type: integer - nullable: true canceled: type: integer - nullable: true PlaybookRunSystemList: type: object diff --git a/src/remediations/routes.js b/src/remediations/routes.js index 027afdd0..d5b53b5b 100644 --- a/src/remediations/routes.js +++ b/src/remediations/routes.js @@ -12,78 +12,50 @@ const rbacWrite = rbac('remediations:remediation:write'); const rbacExecute = rbac('remediations:remediation:execute'); module.exports = function (router) { - router.get('/remediations', openapi('getRemediations'), rbacRead, read.list); - router.post('/remediations', openapi('createRemediation'), rbacWrite, write.create); - router.delete('/remediations', openapi('deleteRemediations'), rbacWrite, write.bulkRemove); + router.route('/remediations') + .get(openapi('getRemediations'), rbacRead, read.list) + .post(openapi('createRemediation'), rbacWrite, write.create) + .delete(openapi('deleteRemediations'), rbacWrite, write.bulkRemove); + router.get('/remediations/download', openapi('downloadPlaybooks'), rbacRead, read.downloadPlaybooks); - router.get('/remediations/:id', openapi('getRemediation'), rbacRead, read.get); - router.patch('/remediations/:id', openapi('updateRemediation'), rbacWrite, write.patch); - router.delete('/remediations/:id', openapi('deleteRemediation'), rbacWrite, write.remove); - - router.get('/remediations/:id/status', rbacRead, status.status); // TODO: openapi mw - - router.patch( - '/remediations/:id/issues/:issue', - openapi('updateRemediationIssue'), - rbacWrite, - write.patchIssue); - - router.delete( - '/remediations/:id/issues/:issue', - openapi('deleteRemediationIssue'), - rbacWrite, - write.removeIssue); - - router.get( - '/remediations/:id/issues/:issue/systems', - openapi('getRemediationIssueSystems'), - rbacRead, - read.getIssueSystems); - - router.delete( - '/remediations/:id/issues/:issue/systems/:system', - openapi('deleteRemediationIssueSystem'), - rbacWrite, - write.removeIssueSystem); - - router.get('/remediations/:id/executable', - openapi('checkExecutable'), - rbacRead, - fifi.checkExecutable); - - router.get('/remediations/:id/connection_status', - openapi('getRemediationConnectionStatus'), - rbacExecute, - fifi.connection_status); - - router.get('/remediations/:id/playbook_runs', - openapi('listPlaybookRuns'), - rbacRead, - fifi.listPlaybookRuns); - - router.post('/remediations/:id/playbook_runs', - openapi('runRemediation'), - rbacExecute, - fifi.executePlaybookRuns); - - router.get('/remediations/:id/playbook_runs/:playbook_run_id', - openapi('getPlaybookRunDetails'), - rbacRead, - fifi.getRunDetails); - - router.post('/remediations/:id/playbook_runs/:playbook_run_id/cancel', - openapi('cancelPlaybookRuns'), - rbacExecute, - fifi.cancelPlaybookRuns); - - router.get('/remediations/:id/playbook_runs/:playbook_run_id/systems', - openapi('getPlaybookRunSystems'), - rbacRead, - fifi.getSystems); - - router.get('/remediations/:id/playbook_runs/:playbook_run_id/systems/:system', - openapi('getPlaybookRunSystemDetails'), - rbacRead, - fifi.getSystemDetails); + router.route('/remediations/:id') + .get(openapi('getRemediation'), rbacRead, read.get) + .patch(openapi('updateRemediation'), rbacWrite, write.patch) + .delete(openapi('deleteRemediation'), rbacWrite, write.remove); + + router.route('/remediations/:id/status') + .get(rbacRead, status.status); // TODO: openapi mw + + router.route('/remediations/:id/issues/:issue') + .patch(openapi('updateRemediationIssue'), rbacWrite, write.patchIssue) + .delete(openapi('deleteRemediationIssue'), rbacWrite, write.removeIssue); + + router.route('/remediations/:id/issues/:issue/systems') + .get(openapi('getRemediationIssueSystems'), rbacRead, read.getIssueSystems); + + router.route('/remediations/:id/issues/:issue/systems/:system') + .delete(openapi('deleteRemediationIssueSystem'), rbacWrite, write.removeIssueSystem); + + router.route('/remediations/:id/executable') + .get(openapi('checkExecutable'), rbacRead, fifi.checkExecutable); + + router.route('/remediations/:id/connection_status') + .get(openapi('getRemediationConnectionStatus'), rbacExecute, fifi.connection_status); + + router.route('/remediations/:id/playbook_runs') + .get(openapi('listPlaybookRuns'), rbacRead, fifi.listPlaybookRuns) + .post(openapi('runRemediation'), rbacExecute, fifi.executePlaybookRuns); + + router.route('/remediations/:id/playbook_runs/:playbook_run_id') + .get(openapi('getPlaybookRunDetails'), rbacRead, fifi.getRunDetails); + + router.route('/remediations/:id/playbook_runs/:playbook_run_id/cancel') + .post(openapi('cancelPlaybookRuns'), rbacExecute, fifi.cancelPlaybookRuns); + + router.route('/remediations/:id/playbook_runs/:playbook_run_id/systems') + .get(openapi('getPlaybookRunSystems'), rbacRead, fifi.getSystems); + + router.route('/remediations/:id/playbook_runs/:playbook_run_id/systems/:system') + .get(openapi('getPlaybookRunSystemDetails'), rbacRead, fifi.getSystemDetails); };