@getjones/test-infra 2.10.5 → 2.10.7
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 +1 -1
- package/src/common/consts/s3FileTypes.js +11 -0
- package/src/resources/virusFile.pdf +0 -0
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +8 -3
- package/src/saas/internal-api/agreement/api/agreement.api.js +13 -2
- package/src/saas/internal-api/agreement/api/agreement.service.js +51 -1
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +1 -1
- package/src/saas/internal-api/compliance/consts/audit.js +6 -2
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +3 -3
- package/src/saas/internal-api/uploadFiles/consts.js +1 -14
- package/src/saas/internal-api/users/api/users.service.js +3 -2
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
1
2
|
const env = require('../../../../../env');
|
|
2
3
|
const accountsAPI = require('./accounts.core.api');
|
|
3
4
|
const CreateAccountModel = require('../../models/core/create.account.model');
|
|
4
5
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
6
|
+
const httpResponseStatusCodes = require('../../../../../../../../packages/test-infra/src/common/httpResponseStatusCodes.json');
|
|
5
7
|
|
|
6
8
|
const { accountCreationSecret } = env.getEnv();
|
|
7
9
|
|
|
@@ -18,16 +20,19 @@ const createAccount = async (createAccountModel, context) => {
|
|
|
18
20
|
|
|
19
21
|
const getAccount = async (accountName, context) => {
|
|
20
22
|
const response = await accountsAPI.getByName(accountName, context);
|
|
23
|
+
expect(response.status, 'Failed to get accounts by name').to.equal(httpResponseStatusCodes.OK);
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
const existingAccounts = response.data;
|
|
26
|
+
|
|
27
|
+
if (!existingAccounts || !existingAccounts.length) {
|
|
23
28
|
return null;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
if (
|
|
31
|
+
if (existingAccounts.length > 1) {
|
|
27
32
|
throw new Error(`Got more than one account with the name: ${accountName}. IDs: ${existingAccounts.map(item => item.userId).join(', ')}`);
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
return
|
|
35
|
+
return existingAccounts[0];
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
const getOrCreateAccount = async (createAccountModel, context) => {
|
|
@@ -5,7 +5,16 @@ const AGREEMENT_API_URL = `${backendUrl}/saas/contractor/agreement`;
|
|
|
5
5
|
|
|
6
6
|
const Endpoints = {
|
|
7
7
|
create: AGREEMENT_API_URL,
|
|
8
|
-
delete: AGREEMENT_API_URL
|
|
8
|
+
delete: AGREEMENT_API_URL,
|
|
9
|
+
getAgreementPreSignedUrl: `${backendUrl}/pre-signed-url/upload/agreement`
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getAgreementPreSignedUrl = (formData, context) => {
|
|
13
|
+
return requests.postRequestHandler(Endpoints.getAgreementPreSignedUrl, formData, context, formData.getHeaders());
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const uploadAgreementToS3 = (preSignedUrl, file) => {
|
|
17
|
+
return requests.putRequestHandler(preSignedUrl, file);
|
|
9
18
|
};
|
|
10
19
|
|
|
11
20
|
const createAgreement = (createAgreementModel, context) => {
|
|
@@ -20,5 +29,7 @@ const deleteAgreement = (recordId, context) => {
|
|
|
20
29
|
|
|
21
30
|
module.exports = {
|
|
22
31
|
createAgreement,
|
|
23
|
-
deleteAgreement
|
|
32
|
+
deleteAgreement,
|
|
33
|
+
uploadAgreementToS3,
|
|
34
|
+
getAgreementPreSignedUrl
|
|
24
35
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const FormData = require('form-data');
|
|
3
|
+
|
|
1
4
|
const agreementAPI = require('./agreement.api');
|
|
2
5
|
const { CreateAgreementModel } = require('../models/create.agreement.model');
|
|
3
6
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
|
+
const { CONTRACT } = require('../../../../common/consts/s3FileTypes');
|
|
4
9
|
|
|
5
10
|
const createAgreement = (createAgreementModel, context) => {
|
|
6
11
|
validateType(createAgreementModel, CreateAgreementModel);
|
|
@@ -11,7 +16,52 @@ const deleteAgreement = (recordId, context) => {
|
|
|
11
16
|
return agreementAPI.deleteAgreement(recordId, context);
|
|
12
17
|
};
|
|
13
18
|
|
|
19
|
+
const getAgreementPreSignedUrl = (recordId, context, { filePath }) => {
|
|
20
|
+
const formData = new FormData();
|
|
21
|
+
const file = fs.createReadStream(filePath);
|
|
22
|
+
formData.append('recordId', recordId);
|
|
23
|
+
formData.append('fileType', CONTRACT);
|
|
24
|
+
formData.append('file', file);
|
|
25
|
+
|
|
26
|
+
return agreementAPI.getAgreementPreSignedUrl(formData, context);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const uploadAgreementToS3 = (preSignedUrl, file) => {
|
|
30
|
+
return agreementAPI.uploadAgreementToS3(preSignedUrl, file);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const uploadAgreement = async (
|
|
34
|
+
recordId,
|
|
35
|
+
filePath,
|
|
36
|
+
uploaderId,
|
|
37
|
+
context,
|
|
38
|
+
{ contractorDateModified } = {}
|
|
39
|
+
) => {
|
|
40
|
+
const { data: { preSignedUrl, fileName: fullFilePath } } = await getAgreementPreSignedUrl(recordId, context, { filePath });
|
|
41
|
+
|
|
42
|
+
const uploadResults = await uploadAgreementToS3(preSignedUrl, filePath);
|
|
43
|
+
|
|
44
|
+
if (uploadResults.status !== httpResponseStatusCodes.OK) {
|
|
45
|
+
throw new Error(`Failed to upload agreement to S3 for record ${recordId}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const createAgreementModel = new CreateAgreementModel({
|
|
49
|
+
contractorId: recordId,
|
|
50
|
+
contractorDateModified,
|
|
51
|
+
uploaderId,
|
|
52
|
+
signedContractName: fullFilePath
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const createResponse = await createAgreement(createAgreementModel, context);
|
|
56
|
+
|
|
57
|
+
if (createResponse.status !== httpResponseStatusCodes.OK) {
|
|
58
|
+
throw new Error(`Failed to upload agreement for record ${recordId}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return createResponse;
|
|
62
|
+
};
|
|
14
63
|
module.exports = {
|
|
15
64
|
createAgreement,
|
|
16
|
-
deleteAgreement
|
|
65
|
+
deleteAgreement,
|
|
66
|
+
uploadAgreement
|
|
17
67
|
};
|
|
@@ -3,7 +3,7 @@ const { UPLOADER_TYPE } = require('../consts/consts');
|
|
|
3
3
|
class CreateAgreementModel {
|
|
4
4
|
constructor({ contractorId, contractorDateModified, uploaderId, signedContractName, uploaderType = UPLOADER_TYPE.USER }) {
|
|
5
5
|
this.contractorId = contractorId;
|
|
6
|
-
this.contractorDateModified = contractorDateModified;
|
|
6
|
+
this.contractorDateModified = contractorDateModified || null;
|
|
7
7
|
this.uploaderId = uploaderId;
|
|
8
8
|
this.signedContractName = signedContractName;
|
|
9
9
|
this.uploaderType = uploaderType;
|
|
@@ -39,7 +39,8 @@ const POLICY_NAMES_MAP = {
|
|
|
39
39
|
agreement: 'Agreement',
|
|
40
40
|
certificateHolder: 'Certificate Holder',
|
|
41
41
|
additionalInformation: 'Additional Information',
|
|
42
|
-
additionalInsured: 'Additional Insured'
|
|
42
|
+
additionalInsured: 'Additional Insured',
|
|
43
|
+
businessInterruptionIncomeInsurance: 'Business Interruption / Income Insurance'
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
const ATTRIBUTE_NAMES_MAP = {
|
|
@@ -57,7 +58,10 @@ const ATTRIBUTE_NAMES_MAP = {
|
|
|
57
58
|
amRating: 'AMBestRating',
|
|
58
59
|
cancellationTerms: 'cancellationTerms',
|
|
59
60
|
coiAuthentication: 'COIauthentication',
|
|
60
|
-
signature: 'signature'
|
|
61
|
+
signature: 'signature',
|
|
62
|
+
indemnityPeriod: 'Indemnity Period',
|
|
63
|
+
actualLossSustained: 'Actual Loss Sustained',
|
|
64
|
+
extraExpense: 'Extra Expense'
|
|
61
65
|
};
|
|
62
66
|
|
|
63
67
|
const auditTriggerType = {
|
|
@@ -3,14 +3,14 @@ const fs = require('fs');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const FormData = require('form-data');
|
|
5
5
|
const consts = require('../consts');
|
|
6
|
-
|
|
7
|
-
const { RELATED_DOC_TYPES
|
|
6
|
+
const { DOCUMENT } = require('../../../../common/consts/s3FileTypes');
|
|
7
|
+
const { RELATED_DOC_TYPES } = consts;
|
|
8
8
|
|
|
9
9
|
const getRelatedDocPreSignedUrl = (recordId, context, { filePath }) => {
|
|
10
10
|
const formData = new FormData();
|
|
11
11
|
const file = fs.createReadStream(filePath);
|
|
12
12
|
formData.append('recordId', recordId);
|
|
13
|
-
formData.append('fileType',
|
|
13
|
+
formData.append('fileType', DOCUMENT);
|
|
14
14
|
formData.append('file', file) ;
|
|
15
15
|
|
|
16
16
|
return uploadFileApi.getRelatedDocPreSignedUrl(formData, context);
|
|
@@ -7,19 +7,6 @@ const RELATED_DOC_TYPES = {
|
|
|
7
7
|
OTHER: 'OTHER'
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
S3_FILE_TYPE = {
|
|
11
|
-
DOCUMENT: 'DOCUMENT',
|
|
12
|
-
REPORTS: 'REPORTS',
|
|
13
|
-
SNIPPET: 'SNIPPET',
|
|
14
|
-
CONTRACT: 'CONTRACT',
|
|
15
|
-
TEMPCOI: 'TEMPCOI',
|
|
16
|
-
COI: 'COI',
|
|
17
|
-
ATTACHMENT: 'ATTACHMENT',
|
|
18
|
-
OCRDATA: 'OCRDATA',
|
|
19
|
-
VENDORREPORT: 'VENDORREPORT'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
10
|
module.exports = {
|
|
23
|
-
RELATED_DOC_TYPES
|
|
24
|
-
S3_FILE_TYPE
|
|
11
|
+
RELATED_DOC_TYPES
|
|
25
12
|
};
|
|
@@ -89,7 +89,7 @@ const removeAllUserTraceFromDb = (userId, context) => {
|
|
|
89
89
|
|
|
90
90
|
const deleteUserByEmail = async (userEmail, context) => {
|
|
91
91
|
const { data: user } = await getUserByEmail(userEmail, context);
|
|
92
|
-
return deleteUser(user.subuserId, context);
|
|
92
|
+
return user ? deleteUser(user.subuserId, context) : null;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
const reinviteUser = (userId, context) => {
|
|
@@ -193,5 +193,6 @@ module.exports = {
|
|
|
193
193
|
sendForgetPasswordMail,
|
|
194
194
|
getOrCreateInnerSystemUser,
|
|
195
195
|
editUserProfile,
|
|
196
|
-
editUserSettings
|
|
196
|
+
editUserSettings,
|
|
197
|
+
getInnerSystemUserByEmail
|
|
197
198
|
};
|