@getjones/test-infra 2.8.10 → 2.8.11

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "2.8.10",
3
+ "version": "2.8.11",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ const DEFAULT_POLICY_DATE = '24/05/2030';
6
6
  const DEFAULT_AM_SCORE = 'A';
7
7
 
8
8
  //Excluded from creating global record: 'ABC-12345-XYZ', 'ABC-123-XYZ', 'ABC-123'. When GR is needed - use different GL number.
9
- const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
9
+ const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
10
10
 
11
11
  const {
12
12
  certificateIssueDate,
@@ -4,6 +4,8 @@ const { backendUrl } = require('../../../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  getAccount: `${backendUrl}/saas/accounts`,
6
6
  create: `${backendUrl}/saas/createaccount`,
7
+ createInnerSystemAccount: `${backendUrl}/saas/superuser/user`,
8
+ getInnerSystemAccountsPerRole: `${backendUrl}/saas/users`,
7
9
  delete: `${backendUrl}/saas/account`,
8
10
  edit: accountId => `${backendUrl}/saas/account/${accountId}/settings`
9
11
  };
@@ -12,6 +14,15 @@ const create = (account, context) => {
12
14
  return requests.postRequestHandler(Endpoints.create, account, context);
13
15
  };
14
16
 
17
+ const createInnerSystemAccount = (innerSystemUser, icsContext) => {
18
+ return requests.postRequestHandler(Endpoints.createInnerSystemAccount, innerSystemUser, icsContext);
19
+ };
20
+
21
+ const getInnerSystemAccountsPerRole = (roles, icsContext) => {
22
+ const params = { roles };
23
+ return requests.getRequestHandler(Endpoints.getInnerSystemAccountsPerRole, params, icsContext);
24
+ };
25
+
15
26
  const deleteAccount = (accountId, context) => {
16
27
  return requests.deleteRequestHandler(Endpoints.delete, context, {}, { 'userId': accountId });
17
28
  };
@@ -25,4 +36,4 @@ const getByName = (accountName, context) => {
25
36
  return requests.getRequestHandler(Endpoints.getAccount, params, context);
26
37
  };
27
38
 
28
- module.exports = { create, getByName, deleteAccount, updateAccountSettings };
39
+ module.exports = { create, getByName, deleteAccount, updateAccountSettings, createInnerSystemAccount, getInnerSystemAccountsPerRole };
@@ -1,7 +1,11 @@
1
1
  const env = require('../../../../../env');
2
2
  const accountsAPI = require('./accounts.core.api');
3
3
  const CreateAccountModel = require('../../models/core/create.account.model');
4
+ const CreateInnerSystemAccountModel = require('../../models/core/create.inner.system.account.model');
4
5
  const { validateType } = require('../../../../../common/validations/typeValidations');
6
+ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
7
+ const { ROLES } = require('../../../../../../../../src/saas/internal-api/common/users/consts');
8
+ const userTypes = require('../../../../../common/consts/userTypes');
5
9
 
6
10
  const { accountCreationSecret } = env.getEnv();
7
11
 
@@ -16,6 +20,48 @@ const createAccount = async (createAccountModel, context) => {
16
20
  return accountsAPI.create(createAccountModel, context);
17
21
  };
18
22
 
23
+ const createInnerSystemAccount = async (innerSystemCreateAccountModel, icsContext) => {
24
+ validateType(innerSystemCreateAccountModel, CreateInnerSystemAccountModel);
25
+ const response = await accountsAPI.createInnerSystemAccount(innerSystemCreateAccountModel, icsContext);
26
+
27
+ if (response.status !== httpResponseStatusCodes.OK) {
28
+ throw Error(`Create inner system account failed\n${response}`);
29
+ }
30
+
31
+ return response.data;
32
+ };
33
+
34
+ const getInnerSystemAccountsPerRole = async icsContext => {
35
+ const roles = `${userTypes.ICS},${ROLES.auditor},${ROLES.operator}`;
36
+ const response = await accountsAPI.getInnerSystemAccountsPerRole(roles, icsContext);
37
+
38
+ if (response.status !== httpResponseStatusCodes.OK) {
39
+ throw Error(`Get inner system accounts failed\n${response}`);
40
+ }
41
+
42
+ return response.data;
43
+ };
44
+
45
+ const getOrCreateInnerSystemAccount = async (innerSystemCreateAccountModel, role, icsContext) => {
46
+ const accountEmail = innerSystemCreateAccountModel.email;
47
+ const account = await getInnerSystemAccountByEmail(accountEmail, role, icsContext);
48
+
49
+ if (account) {
50
+ return account;
51
+ }
52
+
53
+ await createInnerSystemAccount(innerSystemCreateAccountModel, icsContext);
54
+ return getInnerSystemAccountByEmail(accountEmail, role, icsContext);
55
+ };
56
+
57
+ const getInnerSystemAccountByEmail = async (accountEmail, role, icsContext) => {
58
+ const accountsPerRole = await getInnerSystemAccountsPerRole(icsContext);
59
+ const accountsOfRole = accountsPerRole[role];
60
+ const account = accountsOfRole.find(({ email }) => email === accountEmail);
61
+
62
+ return account;
63
+ };
64
+
19
65
  const getAccount = async (accountName, context) => {
20
66
  const response = await accountsAPI.getByName(accountName, context);
21
67
 
@@ -73,5 +119,6 @@ module.exports = {
73
119
  getAccountId,
74
120
  createAccount,
75
121
  deleteAccountByName,
76
- deleteAccountById
122
+ deleteAccountById,
123
+ getOrCreateInnerSystemAccount
77
124
  };
@@ -1,5 +1,6 @@
1
1
  const CreateAccountModel = require('./models/core/create.account.model');
2
- const coreModels = { CreateAccountModel };
2
+ const CreateInnerSystemAccountModel = require('./models/core/create.inner.system.account.model');
3
+ const coreModels = { CreateAccountModel, CreateInnerSystemAccountModel };
3
4
 
4
5
  const UpdateAccountSettingsModel = require('./models/settings/update.settings.model');
5
6
  const settingsModels = { UpdateAccountSettingsModel };
@@ -0,0 +1,18 @@
1
+ const env = require('../../../../../env');
2
+ const { credentials } = env.getEnv();
3
+
4
+ class CreateInnerSystemAccountModel {
5
+ constructor({
6
+ fullName = '',
7
+ email = '',
8
+ password = credentials.strongPassword,
9
+ userRole
10
+ }) {
11
+ this.fullName = fullName;
12
+ this.email = email;
13
+ this.password = password;
14
+ this.role = userRole;
15
+ }
16
+ }
17
+
18
+ module.exports = CreateInnerSystemAccountModel;
@@ -4,6 +4,7 @@ const EMAIL_TYPES = {
4
4
  COMPLIANT: 'compliant',
5
5
  NOT_COMPLIANT: 'notCompliant',
6
6
  SEND_GAPS: 'sendGaps',
7
+ SEND_GAPS_TENANT: 'sendGapsForTenant',
7
8
  REQUEST_NEW_COI_EXPIRED: 'requestNewCoiExpired',
8
9
  FIRST_REMINDER: 'firstReminder',
9
10
  SECOND_REMINDER: 'secondReminder',
@@ -20,14 +21,14 @@ const EMAIL_TYPES = {
20
21
 
21
22
  const EMAIL_SUBJECT = {
22
23
  compliant: ({ recordCompanyName }) => `Compliant COI - ${recordCompanyName}`,
24
+ sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName} - `, //For this email type, guest is the same as vendor
25
+ sendGapsForTenant: ({ requesterName }) => `New Insurance Docs Required for leased space at ${requesterName} - `,
23
26
  notCompliant: ({ recordCompanyName, requesterName }) => `Please Review COI Gaps - ${recordCompanyName} (${requesterName})`,
24
27
  wrongCoi: ({ recordCompanyName, requesterName }) => `Incorrect File Submission - COI Still Required for ${recordCompanyName} - ${requesterName}`,
25
- sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName}`, //doesn't includes text for guest or tenant
26
28
  sendGapsRecordFullName: ({ requesterName, recordFirstName, recordLastName }) => `New Insurance Docs Required for ${requesterName} - ${recordFirstName} ${recordLastName}`,
27
29
  requestNewCoiExpired: ({ recordCompanyName }) => `${recordCompanyName}'s COI is`,
28
30
  firstReminder: ({ requesterName }) => `We are still awaiting the Insurance Docs for ${requesterName}`,
29
- secondReminder: ({ requesterName }) => `We are still awaiting the Insurance Docs for ${requesterName}`,
30
- secondReminderAccountRequirement: ({ requesterName }) => `${requesterName} still needs your Insurance Docs`,
31
+ secondReminder: ({ requesterName }) => `${requesterName} still needs`,
31
32
  finalReminder: ({ recordCompanyName, requesterName }) => `Missing ${recordCompanyName}'s Insurance Docs for ${requesterName}`,
32
33
  aboutToExpirePM: ({ recordCompanyName }) => `Insurance Policy of ${recordCompanyName} expires Soon`,
33
34
  aboutToExpireMonthAutoRenewal: ({ requesterName }) => `Your COI for ${requesterName} expires in 30 days`,
@@ -37,6 +38,7 @@ const EMAIL_SUBJECT = {
37
38
  sameDayExpirationPMAutoRenewal: ({ recordCompanyName }) => `COI expired for ${recordCompanyName} at`,
38
39
  requirementsUpdatedNotification: ({ requesterName }) => `Updated Requirements - Your Insurance Docs are needed for ${requesterName}`,
39
40
  updatedRequirementsSubjectPrefix: () => 'Updated Requirements - ',
41
+ fraudAuditorReview: ({ recordCompanyName, requesterName }) => `Authentication check for ${recordCompanyName} at ${requesterName}`,
40
42
  requestNewCoi: ({ recordCompanyName, requesterName, isExpired }) => `${recordCompanyName}'s COI is ${isExpired ? 'expired' : 'about to expire'} - ${requesterName}`,
41
43
  malwareCoiFound: 'COI upload failed to pass security scan',
42
44
  thankYou: 'Thank you for submitting your COI'
@@ -14,7 +14,8 @@ const Endpoints = {
14
14
  getUserEncryptedData: (email, userRole) => `${backendUrl}/saas/team-member/email/${email}/role/${userRole}/signup-data`,
15
15
  signupUser: `${backendUrl}/_saas/guests/signup`,
16
16
  removeAllUserTraceFromDb: userId => `${backendUrl}/saas/user/automation/${userId}`,
17
- userEmailNotificationsSettings: `${backendUrl}/saas/account/notification/set`
17
+ userEmailNotificationsSettings: `${backendUrl}/saas/account/notification/set`,
18
+ sendForgetPasswordMail: `${backendUrl}/_saas/forgotPassword`
18
19
  };
19
20
 
20
21
  const invite = (invitedUser, context, { disableSendMail = true } = {}) => {
@@ -68,6 +69,11 @@ const editUserEmailNotificationsSettings = (userId, notificationSettingsModel, c
68
69
  return requests.postRequestHandler(Endpoints.userEmailNotificationsSettings, notificationSettingsModel, context, {}, params);
69
70
  };
70
71
 
72
+ const sendForgetPasswordMail = userEmail => {
73
+ const body = { email: userEmail };
74
+ return requests.postRequestHandler(Endpoints.sendForgetPasswordMail, body);
75
+ };
76
+
71
77
  module.exports = {
72
78
  invite,
73
79
  signupUser,
@@ -80,5 +86,6 @@ module.exports = {
80
86
  editUserRole,
81
87
  editUserProjects,
82
88
  reinviteUser,
83
- editUserEmailNotificationsSettings
89
+ editUserEmailNotificationsSettings,
90
+ sendForgetPasswordMail
84
91
  };
@@ -91,6 +91,10 @@ const editUserEmailNotificationsSettings = (userId, notificationSettingsModel, c
91
91
  return userAPI.editUserEmailNotificationsSettings(userId, notificationSettingsModel, context);
92
92
  };
93
93
 
94
+ const sendForgetPasswordMail = userEmail => {
95
+ return userAPI.sendForgetPasswordMail(userEmail);
96
+ };
97
+
94
98
  module.exports = {
95
99
  inviteUser,
96
100
  signupUser,
@@ -104,5 +108,6 @@ module.exports = {
104
108
  editUserRole,
105
109
  editUserProjects,
106
110
  reinviteUser,
107
- editUserEmailNotificationsSettings
111
+ editUserEmailNotificationsSettings,
112
+ sendForgetPasswordMail
108
113
  };
Binary file