@getjones/test-infra 4.4.14 → 4.4.15
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/factory/users/users.js +1 -1
- package/src/saas/internal-api/policyFile/api/policy.file.api.js +8 -2
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +35 -1
- package/src/saas/internal-api/users/api/users.service.js +21 -6
- package/src/saas/internal-api/users/models/users.model.js +2 -1
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ const roles = {
|
|
|
17
17
|
const inviteSaasUser = async (username, role, projectIds, context, { hasCompleteAccessPermission } = {}) => {
|
|
18
18
|
const userResponse = await users.services.getUserByEmail(username, context);
|
|
19
19
|
|
|
20
|
-
if (userResponse.data && userResponse.data.
|
|
20
|
+
if (userResponse.data && userResponse.data.id) {
|
|
21
21
|
const { projectPermissions } = userResponse.data;
|
|
22
22
|
const projectPermissionsIds = projectPermissions.map(projectPermission => projectPermission.projectId);
|
|
23
23
|
|
|
@@ -4,7 +4,8 @@ const { backendUrl } = require('../../../../env').getEnv();
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getPolicyFilesForVendorReport: requestId => `${backendUrl}/saas/request/${requestId}/policy-files`,
|
|
6
6
|
getPreSignedUrlByPolicyId: policyFileId => `${backendUrl}/saas/policy-file/${policyFileId}`,
|
|
7
|
-
getAuditPolicyFilesByAuditId: (recordId, auditId) => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/${auditId}/policy-files
|
|
7
|
+
getAuditPolicyFilesByAuditId: (recordId, auditId) => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/${auditId}/policy-files`,
|
|
8
|
+
getPolicyFilesRequireAudit: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/policy-files-to-audit`
|
|
8
9
|
};
|
|
9
10
|
const getPolicyFilesForVendorReport = async (requestId, context) => {
|
|
10
11
|
return requests.getRequestHandler(Endpoints.getPolicyFilesForVendorReport(requestId), {}, context);
|
|
@@ -18,8 +19,13 @@ const getAuditPolicyFiles = async (recordId, auditId, context) => {
|
|
|
18
19
|
return requests.getRequestHandler(Endpoints.getAuditPolicyFilesByAuditId(recordId, auditId), {}, context);
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
const getPolicyFilesRequireAudit = async (recordId, context) => {
|
|
23
|
+
return requests.getRequestHandler(Endpoints.getPolicyFilesRequireAudit(recordId), {}, context);
|
|
24
|
+
};
|
|
25
|
+
|
|
21
26
|
module.exports = {
|
|
22
27
|
getPolicyFilesForVendorReport,
|
|
23
28
|
getPreSignedUrlByPolicyId,
|
|
24
|
-
getAuditPolicyFiles
|
|
29
|
+
getAuditPolicyFiles,
|
|
30
|
+
getPolicyFilesRequireAudit
|
|
25
31
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const policyFileApi = require('./policy.file.api');
|
|
2
|
+
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
2
3
|
|
|
3
4
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
4
5
|
|
|
@@ -32,8 +33,41 @@ const getAuditPolicyFiles = async (recordId, auditId, context) => {
|
|
|
32
33
|
return getAuditPolicyFilesResponse;
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const getPolicyFilesIfExist = async (recordId, context) => {
|
|
37
|
+
let retries = 10;
|
|
38
|
+
let policiesToReviewResponse;
|
|
39
|
+
let policyFiles = [];
|
|
40
|
+
|
|
41
|
+
while (policyFiles.length === 0 && retries > 0) {
|
|
42
|
+
//Busy wait for it takes time to get policy file to review
|
|
43
|
+
await timeUtils.waitFor(0.5).seconds;
|
|
44
|
+
|
|
45
|
+
policiesToReviewResponse = await policyFileApi.getPolicyFilesRequireAudit(recordId, context);
|
|
46
|
+
policyFiles = policiesToReviewResponse.data;
|
|
47
|
+
|
|
48
|
+
retries--;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (policyFiles.length === 0) {
|
|
52
|
+
throw new Error(`No policy files to review where found for record ${recordId}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return policiesToReviewResponse;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getPolicyFilesRequireAudit = async (recordId, context) => {
|
|
59
|
+
const getPolicyFilesResponse = await getPolicyFilesIfExist(recordId, context);
|
|
60
|
+
|
|
61
|
+
if (getPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
|
|
62
|
+
throw new Error('Failed to get policy files that require audit');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return getPolicyFilesResponse;
|
|
66
|
+
};
|
|
67
|
+
|
|
35
68
|
module.exports = {
|
|
36
69
|
getPolicyFilesForVendorReport,
|
|
37
70
|
getPreSignedUrlByPolicyId,
|
|
38
|
-
getAuditPolicyFiles
|
|
71
|
+
getAuditPolicyFiles,
|
|
72
|
+
getPolicyFilesRequireAudit
|
|
39
73
|
};
|
|
@@ -24,11 +24,23 @@ const editUserRole = async (userId, data, context) => {
|
|
|
24
24
|
return userAPI.editUserRole(userId, data, context);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const editUserProjectsByModel = async (editUserModel, context) => {
|
|
28
28
|
validateType(editUserModel, EditUserModel);
|
|
29
29
|
return userAPI.editUserProjects([editUserModel], context);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const editUserProjects = async (userId, userEmail, role, projectsIds, context, { hasCompleteAccessPermission } = {}) => {
|
|
33
|
+
const editUserModel = new EditUserModel(userId, userEmail, role, projectsIds, hasCompleteAccessPermission);
|
|
34
|
+
|
|
35
|
+
const response = await editUserProjectsByModel(editUserModel, context);
|
|
36
|
+
|
|
37
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
38
|
+
throw new Error('Failed to edit user projects');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
|
|
32
44
|
const getUsersByProjectId = async (projectId, context) => {
|
|
33
45
|
return userAPI.getUsersByProjectId(projectId, context);
|
|
34
46
|
};
|
|
@@ -57,7 +69,7 @@ const getEnabledAndDisabledByEmail = async (email, context) => {
|
|
|
57
69
|
return response.data;
|
|
58
70
|
};
|
|
59
71
|
|
|
60
|
-
const getOrCreateUser = async (email, role, projectsIds, context, { fullName = role, password = credentials.strongPassword } = {}) => {
|
|
72
|
+
const getOrCreateUser = async (email, role, projectsIds, context, { fullName = role, password = credentials.strongPassword, expectError, hasCompleteAccessPermission } = {}) => {
|
|
61
73
|
let userResponse = await getUserByEmail(email, context);
|
|
62
74
|
|
|
63
75
|
if (userResponse.data !== '' && userResponse.status === httpResponseStatusCodes.OK) {
|
|
@@ -66,16 +78,18 @@ const getOrCreateUser = async (email, role, projectsIds, context, { fullName = r
|
|
|
66
78
|
|
|
67
79
|
projectsIds = projectsIds.filter(projectId => !projectPermissionsIds.includes(projectId));
|
|
68
80
|
|
|
69
|
-
if (userResponse.data && userResponse.data.
|
|
81
|
+
if (userResponse.data && userResponse.data.id && userResponse.data.isVerified && !projectsIds.length) {
|
|
70
82
|
return userResponse.data;
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
const inviteUserModel = new InviteUserModel(email, role, projectsIds);
|
|
86
|
+
const inviteUserModel = new InviteUserModel(email, role, projectsIds, hasCompleteAccessPermission);
|
|
75
87
|
const inviteResponse = await inviteUser([inviteUserModel], context);
|
|
76
88
|
|
|
77
|
-
if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
89
|
+
if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT && !expectError) {
|
|
78
90
|
throw new Error(`Failed to invite user with email: ${email}\n${inviteResponse}`);
|
|
91
|
+
} else if (expectError) {
|
|
92
|
+
return inviteResponse;
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
userResponse = await getUserByEmail(email, context);
|
|
@@ -126,7 +140,7 @@ const removeAllUserTraceFromDb = (userId, context) => {
|
|
|
126
140
|
|
|
127
141
|
const deleteUserByEmail = async (userEmail, context) => {
|
|
128
142
|
const { data: user } = await getUserByEmail(userEmail, context);
|
|
129
|
-
return user ? deleteUser(user.
|
|
143
|
+
return user ? deleteUser(user.id, context) : null;
|
|
130
144
|
};
|
|
131
145
|
|
|
132
146
|
const reinviteUser = (userId, context) => {
|
|
@@ -232,6 +246,7 @@ module.exports = {
|
|
|
232
246
|
removeAllUserTraceFromDb,
|
|
233
247
|
editUserRole,
|
|
234
248
|
editUserProjects,
|
|
249
|
+
editUserProjectsByModel,
|
|
235
250
|
reinviteUser,
|
|
236
251
|
editUserEmailNotificationsSettings,
|
|
237
252
|
sendForgetPasswordMail,
|
|
@@ -17,11 +17,12 @@ class SignupUserModel {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
class EditUserModel {
|
|
20
|
-
constructor(subUserId, email, role, projects = []) {
|
|
20
|
+
constructor(subUserId, email, role, projects = [], hasCompleteAccessPermission) {
|
|
21
21
|
this.subUserId = subUserId;
|
|
22
22
|
this.email = email;
|
|
23
23
|
this.role = role;
|
|
24
24
|
this.projects = projects;
|
|
25
|
+
this.hasCompleteAccessPermission = hasCompleteAccessPermission;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|