@getjones/test-infra 2.7.12 → 2.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -113,7 +113,7 @@ const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requiremen
|
|
|
113
113
|
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context);
|
|
114
114
|
|
|
115
115
|
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
116
|
-
await compliance.services.overrideGap.
|
|
116
|
+
await compliance.services.overrideGap.waiveAllGaps(record, context);
|
|
117
117
|
|
|
118
118
|
return recordId;
|
|
119
119
|
};
|
|
@@ -2,24 +2,10 @@ const requests = require('../../../../../common/requests/cookieAuth/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
waive: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
6
|
-
retract: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
7
5
|
overrideGap: `${backendUrl}/saas/record/override-gap`,
|
|
8
6
|
retractOverride: `${backendUrl}/saas/record/retract-override`
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
const waive = async (contractorId, waiveRequestModel, context) => {
|
|
12
|
-
const status = waiveRequestModel.status;
|
|
13
|
-
delete waiveRequestModel.status;
|
|
14
|
-
return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const retract = async (contractorId, retractRequestModel, context) => {
|
|
18
|
-
const status = retractRequestModel.status;
|
|
19
|
-
delete retractRequestModel.status;
|
|
20
|
-
return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
|
|
21
|
-
};
|
|
22
|
-
|
|
23
9
|
const overrideGap = ({ overrideGapModel, isTestingBackwardCompatibility = false, context }) => {
|
|
24
10
|
const headers = {};
|
|
25
11
|
const params = { isTestingBackwardCompatibility };
|
|
@@ -30,4 +16,4 @@ const retractOverride = (retractModel, context) => {
|
|
|
30
16
|
return requests.postRequestHandler(Endpoints.retractOverride, retractModel, context);
|
|
31
17
|
};
|
|
32
18
|
|
|
33
|
-
module.exports = {
|
|
19
|
+
module.exports = { overrideGap, retractOverride };
|
|
@@ -11,16 +11,6 @@ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatu
|
|
|
11
11
|
const { credentials } = env.getEnv();
|
|
12
12
|
const userTypes = require('../../../../../common/consts/userTypes');
|
|
13
13
|
|
|
14
|
-
const waive = (waiveRequestModel, context) => {
|
|
15
|
-
validateType(waiveRequestModel, OverrideGapModel);
|
|
16
|
-
return overrideGapApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const retract = (retractRequestModel, context) => {
|
|
20
|
-
validateType(retractRequestModel, RetractOverrideGapModel);
|
|
21
|
-
return overrideGapApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
14
|
const overrideGap = ({ overrideGapModel, isTestingBackwardCompatibility = false, context }) => {
|
|
25
15
|
validateType(overrideGapModel, OverrideGapModel);
|
|
26
16
|
return overrideGapApi.overrideGap({ overrideGapModel, isTestingBackwardCompatibility, context });
|
|
@@ -31,7 +21,7 @@ const retractOverride = (retractModel, context) => {
|
|
|
31
21
|
return overrideGapApi.retractOverride(retractModel, context);
|
|
32
22
|
};
|
|
33
23
|
|
|
34
|
-
const
|
|
24
|
+
const getOverrideGapModel = (
|
|
35
25
|
record,
|
|
36
26
|
policyName,
|
|
37
27
|
attributeName,
|
|
@@ -69,7 +59,7 @@ const getWaiveModelByGap = (
|
|
|
69
59
|
} = {}) => {
|
|
70
60
|
const attributeName = auditUtil.getAttributeNameByGap(record, policyName, gap);
|
|
71
61
|
|
|
72
|
-
return
|
|
62
|
+
return getOverrideGapModel(record, policyName, attributeName, reason, note, { userId, userRole });
|
|
73
63
|
};
|
|
74
64
|
|
|
75
65
|
const getRetractModel = (record, policyName, attributeName) => {
|
|
@@ -104,12 +94,13 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
|
104
94
|
return attribute.auditId;
|
|
105
95
|
};
|
|
106
96
|
|
|
107
|
-
|
|
97
|
+
// PRIVATE METHOD - please refer to waiveAllGaps / acceptAllGaps according to your needs
|
|
98
|
+
const overrideAllGaps = async (record, context, { reason = OVERRIDE_GAP_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
108
99
|
const allWaivablePolicies = auditUtil.getAllWaivablePolicies(record, context);
|
|
109
100
|
|
|
110
101
|
for (const waivable of allWaivablePolicies) {
|
|
111
|
-
const
|
|
112
|
-
const waiveResponse = await
|
|
102
|
+
const overrideGapModel = getOverrideGapModel(record, waivable.policyName, waivable.attributeName, reason, note);
|
|
103
|
+
const waiveResponse = await overrideGap({ overrideGapModel, context });
|
|
113
104
|
|
|
114
105
|
if (waiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
115
106
|
throw Error(`Failed to waive ${waivable.policyName} - ${waivable.attributeName} for ${record.company}`);
|
|
@@ -117,11 +108,24 @@ const waiveAll = async (record, context, { reason = OVERRIDE_GAP_REASONS.BUSINES
|
|
|
117
108
|
}
|
|
118
109
|
};
|
|
119
110
|
|
|
111
|
+
const waiveAllGaps = async (record, context, { reason = OVERRIDE_GAP_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
112
|
+
const waivedReasons = new Set([OVERRIDE_GAP_REASONS.BUSINESS_DECISION, OVERRIDE_GAP_REASONS.EXECUTIVE_APPROVAL, OVERRIDE_GAP_REASONS.NO_EXPOSURE]);
|
|
113
|
+
|
|
114
|
+
if (!waivedReasons.has(reason)) {
|
|
115
|
+
throw Error(`Invalid waive reason ${reason} provided when trying to waive all gaps to waive`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await overrideAllGaps(record, context, { reason, note });
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const acceptAllGaps = async (record, context, { note = 'ACCEPTED AUTOMATICALLY' } = {}) => {
|
|
122
|
+
overrideAllGaps(record, context, { reason: OVERRIDE_GAP_REASONS.ACCEPT_NO_EXPOSURE, note });
|
|
123
|
+
};
|
|
124
|
+
|
|
120
125
|
module.exports = {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
getWaiveModel,
|
|
126
|
+
acceptAllGaps,
|
|
127
|
+
waiveAllGaps,
|
|
128
|
+
getOverrideGapModel,
|
|
125
129
|
getRetractModel,
|
|
126
130
|
getWaiveModelByGap,
|
|
127
131
|
overrideGap,
|