Skip to content

Commit

Permalink
RHINENG-12613: Remove unused code from fifi.js
Browse files Browse the repository at this point in the history
  • Loading branch information
marleystipich2 committed Sep 19, 2024
1 parent 675d9d3 commit fbfbc95
Showing 5 changed files with 1 addition and 930 deletions.
102 changes: 0 additions & 102 deletions src/remediations/controller.fifi.js
Original file line number Diff line number Diff line change
@@ -31,108 +31,6 @@ exports.checkExecutable = errors.async(async function (req, res) {
res.sendStatus(200);
});

exports.connection_status = errors.async(async function (req, res) {
trace.enter('controller.fifi.connection_status')

trace.event('Fetch remediation and check for rhcEnabled');
const [remediation, rhcEnabled] = await Promise.all([
queries.get(req.params.id, req.user.tenant_org_id, req.user.username),
fifi.checkRhcEnabled()
]);

if (!remediation) {
trace.leave('Remediation not found');
return notFound(res);
}

trace.event('Get smart management status')
const smartManagement = await fifi.checkSmartManagement(remediation, req.entitlements.smart_management);

if (!smartManagement) {
trace.leave('Smart management is disabled!');
throw new errors.Forbidden();
}

trace.event('Get connection status');
const status = await fifi.getConnectionStatus(
remediation,
req.identity.account_number,
req.identity.org_id,
req.entitlements.smart_management,
rhcEnabled
);

res.set('etag', etag(JSON.stringify(status)));
const result = format.connectionStatus(status);

res.json(result);

trace.leave(`Return result: ${JSON.stringify(result)}`);
});

exports.executePlaybookRuns = errors.async(async function (req, res) {
//==================================================
// get remediation by id
// get connection status of referenced systems
// createPlaybookRun
//==================================================

//--------------------------------------------------
// get remediation by id
//--------------------------------------------------
const [remediation, rhcEnabled] = await Promise.all([
queries.get(req.params.id, req.user.tenant_org_id, req.user.username),
fifi.checkRhcEnabled()
]);

if (!remediation) {
return notFound(res);
}

const smartManagement = await fifi.checkSmartManagement(remediation, req.entitlements.smart_management);

if (!smartManagement) {
throw new errors.Forbidden();
}

//--------------------------------------------------
// get connection status of referenced systems
//--------------------------------------------------
const status = await fifi.getConnectionStatus(
remediation,
req.identity.account_number,
req.identity.org_id,
req.entitlements.smart_management,
rhcEnabled
);
const currentEtag = etag(JSON.stringify(status));

res.set('etag', currentEtag);

probes.optimisticLockCheck(req.headers['if-match'], currentEtag, req.identity.org_id);
if (req.headers['if-match'] && currentEtag !== req.headers['if-match']) {
return notMatching(res);
}

//--------------------------------------------------
// createPlaybookRun
//--------------------------------------------------
const result = await fifi.createPlaybookRun(
status,
remediation,
req.user.username,
req.identity.org_id,
req.body.exclude,
req.body.response_mode
);

if (_.isNull(result)) {
throw errors.noExecutors(remediation);
}

res.status(201).send({id: result});
});

exports.cancelPlaybookRuns = errors.async(async function (req, res) {
const [executors, remediation] = await Promise.all([
queries.getRunningExecutors(req.params.id, req.params.playbook_run_id, req.user.tenant_org_id, req.user.username),
18 changes: 1 addition & 17 deletions src/remediations/fifi.integration.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ const _ = require('lodash');
const URI = require('urijs');
const queryString = require('querystring');

const { request, auth, mockDate, mockUuid, buildRbacResponse } = require('../test');
const { request, auth, mockDate, buildRbacResponse } = require('../test');
const utils = require('../middleware/identity/utils');
const configManager = require('../connectors/configManager');
const receptor = require('../connectors/receptor');
@@ -284,7 +284,6 @@ describe('FiFi', function () {
describe('playbook run', function () {
describe('GET', function () {
test('playbook_runs', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs')
.set(auth.fifi)
@@ -403,7 +402,6 @@ describe('FiFi', function () {
});

test('sort playbook_runs?sort=-updated_at', async() => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs?sort=-updated_at')
.set(auth.fifi)
@@ -443,7 +441,6 @@ describe('FiFi', function () {
});

test('sort playbook_runs?sort=updated_at', async() => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs?sort=updated_at')
.set(auth.fifi)
@@ -483,7 +480,6 @@ describe('FiFi', function () {
});

test('playbook_runs/:playbook_run_id', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb5bc')
.set(auth.fifi)
@@ -520,7 +516,6 @@ describe('FiFi', function () {
test('playbook_runs/:playbook_run_id RHC-direct status aggregation', async () => {
// remediation id: efe9fd2b-fdbd-4c74-93e7-8c69f1b668f3 is a remediation plan
// with two direct hosts for each Playbook-Dispatcher status: running, success, failure, timeout, canceled
mockUuid();
const {body, text} = await request
.get('/v1/remediations/efe9fd2b-fdbd-4c74-93e7-8c69f1b668f3/playbook_runs/8ff5717a-cce8-4738-907b-a89eaa559275')
.set(auth.testStatus)
@@ -530,7 +525,6 @@ describe('FiFi', function () {
});

test('playbook_runs/:playbook_run_id/systems', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/d12efef0-9580-4c82-b604-9888e2269c5a/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb6bc/systems')
.set(auth.fifi)
@@ -556,7 +550,6 @@ describe('FiFi', function () {
});

test('playbook_runs/:playbook_run_id/systems with RHC systems', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb5bc/systems')
.set(auth.fifi)
@@ -709,7 +702,6 @@ describe('FiFi', function () {
});

test('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb5bc/systems?sort=system_name', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/d12efef0-9580-4c82-b604-9888e2269c5a/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb6bc/systems?sort=system_name')
.set(auth.fifi)
@@ -735,7 +727,6 @@ describe('FiFi', function () {
});

test('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb5bc/systems?sort=-system_name', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/d12efef0-9580-4c82-b604-9888e2269c5a/playbook_runs/88d0ba73-0015-4e7d-a6d6-4b530cbfb6bc/systems?sort=-system_name')
.set(auth.fifi)
@@ -775,7 +766,6 @@ describe('FiFi', function () {
});

test('playbook_runs/:playbook_run_id/systems/:system with RHC system', async () => {
mockUuid();
const {body, text} = await request
.get('/v1/remediations/249f142c-2ae3-4c3f-b2ec-c8c5881f8561/playbook_runs/31a70e85-378a-4436-96e9-677cd6fba660/systems/17adc41a-a6c6-426a-a0d5-c7ba08954154')
.set(auth.fifi)
@@ -1175,7 +1165,6 @@ describe('FiFi', function () {

test.skip('check object being send to receptor connector', async function () {
mockDate();
mockUuid();
// do not create db record
base.getSandbox().stub(queries, 'insertPlaybookRun').returns();

@@ -1213,7 +1202,6 @@ describe('FiFi', function () {

test('exclude one of the connected executors', async function () {
mockDate();
mockUuid();

// do not create db record
base.getSandbox().stub(queries, 'insertRHCPlaybookRun').returns();
@@ -1406,7 +1394,6 @@ describe('FiFi', function () {

test.skip('post playbook_runs with response_mode: diff and exclude executors', async function () {
mockDate();
mockUuid();
// do not create db record
base.getSandbox().stub(queries, 'insertPlaybookRun').returns();

@@ -1432,7 +1419,6 @@ describe('FiFi', function () {

test.skip('dynamic post playbook_runs with < 200 executors', async function () {
mockDate();
mockUuid();

const spy = base.getSandbox().spy(receptor, 'postInitialRequest');
base.getSandbox().stub(config.fifi, 'text_update_full').value(false);
@@ -1470,7 +1456,6 @@ describe('FiFi', function () {

test.skip('dynamic post playbook_runs with < 400 executors', async function () {
mockDate();
mockUuid();

const spy = base.getSandbox().spy(receptor, 'postInitialRequest');
base.getSandbox().stub(config.fifi, 'text_update_full').value(false);
@@ -1508,7 +1493,6 @@ describe('FiFi', function () {

test.skip('dynamic post playbook_runs with >= 400 executors', async function () {
mockDate();
mockUuid();

const spy = base.getSandbox().spy(receptor, 'postInitialRequest');
base.getSandbox().stub(config.fifi, 'text_update_full').value(false);
Loading

0 comments on commit fbfbc95

Please sign in to comment.