@tomei/sso 0.8.1 → 0.8.2
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/Jenkinsfile +1 -1
- package/__tests__/unit/components/login-history/login-history.repository.spec.ts +88 -88
- package/__tests__/unit/components/login-user/login-user.spec.ts +731 -731
- package/__tests__/unit/components/login-user/user.repository.spec.ts +75 -75
- package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +26 -26
- package/__tests__/unit/components/system/system.repository.spec.ts +82 -82
- package/__tests__/unit/components/system-access/system-access.repository.spec.ts +72 -72
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js +0 -98
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js.map +1 -1
- package/dist/__tests__/unit/components/login-user/login-user.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +0 -659
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -1
- package/dist/__tests__/unit/components/login-user/user.repository.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/login-user/user.repository.spec.js +0 -77
- package/dist/__tests__/unit/components/login-user/user.repository.spec.js.map +1 -1
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js +0 -37
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js.map +1 -1
- package/dist/__tests__/unit/components/system/system.repository.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/system/system.repository.spec.js +0 -84
- package/dist/__tests__/unit/components/system/system.repository.spec.js.map +1 -1
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.d.ts +0 -1
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js +0 -74
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js.map +1 -1
- package/dist/src/components/login-history/login-history.repository.d.ts +4 -8
- package/dist/src/components/login-history/login-history.repository.js +5 -43
- package/dist/src/components/login-history/login-history.repository.js.map +1 -1
- package/dist/src/components/login-user/login-user.d.ts +1 -0
- package/dist/src/components/login-user/login-user.js +61 -55
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/login-user/user.repository.d.ts +4 -8
- package/dist/src/components/login-user/user.repository.js +5 -43
- package/dist/src/components/login-user/user.repository.js.map +1 -1
- package/dist/src/components/system/system.repository.d.ts +4 -8
- package/dist/src/components/system/system.repository.js +5 -43
- package/dist/src/components/system/system.repository.js.map +1 -1
- package/dist/src/components/system-access/system-access.repository.d.ts +4 -8
- package/dist/src/components/system-access/system-access.repository.js +5 -43
- package/dist/src/components/system-access/system-access.repository.js.map +1 -1
- package/dist/src/components/user-group/user-group.repository.d.ts +4 -8
- package/dist/src/components/user-group/user-group.repository.js +5 -43
- package/dist/src/components/user-group/user-group.repository.js.map +1 -1
- package/dist/src/components/user-user-group/user-user-group.repository.d.ts +4 -8
- package/dist/src/components/user-user-group/user-user-group.repository.js +5 -43
- package/dist/src/components/user-user-group/user-user-group.repository.js.map +1 -1
- package/dist/src/database.d.ts +4 -0
- package/dist/src/database.js +15 -0
- package/dist/src/database.js.map +1 -0
- package/dist/src/models/authorization-code.entity.d.ts +14 -0
- package/dist/src/models/authorization-code.entity.js +86 -0
- package/dist/src/models/authorization-code.entity.js.map +1 -0
- package/dist/src/models/bearer-token.entity.d.ts +11 -0
- package/dist/src/models/bearer-token.entity.js +72 -0
- package/dist/src/models/bearer-token.entity.js.map +1 -0
- package/dist/src/models/building-type.entity.d.ts +7 -0
- package/dist/src/models/building-type.entity.js +50 -0
- package/dist/src/models/building-type.entity.js.map +1 -0
- package/dist/src/models/building.entity.d.ts +28 -0
- package/dist/src/models/building.entity.js +218 -0
- package/dist/src/models/building.entity.js.map +1 -0
- package/dist/src/models/city.entity.d.ts +11 -0
- package/dist/src/models/city.entity.js +72 -0
- package/dist/src/models/city.entity.js.map +1 -0
- package/dist/src/models/company.entity.d.ts +18 -0
- package/dist/src/models/company.entity.js +114 -0
- package/dist/src/models/company.entity.js.map +1 -0
- package/dist/src/models/country.entity.d.ts +15 -0
- package/dist/src/models/country.entity.js +92 -0
- package/dist/src/models/country.entity.js.map +1 -0
- package/dist/src/models/department.entity.d.ts +19 -0
- package/dist/src/models/department.entity.js +112 -0
- package/dist/src/models/department.entity.js.map +1 -0
- package/dist/src/models/group-role-privilege.entity.d.ts +17 -0
- package/dist/src/models/group-role-privilege.entity.js +90 -0
- package/dist/src/models/group-role-privilege.entity.js.map +1 -0
- package/dist/src/models/group-system-access.entity.d.ts +11 -0
- package/dist/src/models/group-system-access.entity.js +62 -0
- package/dist/src/models/group-system-access.entity.js.map +1 -0
- package/dist/src/models/group-system-privilege.entity.d.ts +11 -0
- package/dist/src/models/group-system-privilege.entity.js +62 -0
- package/dist/src/models/group-system-privilege.entity.js.map +1 -0
- package/dist/src/models/group-system-role.entity.d.ts +11 -0
- package/dist/src/models/group-system-role.entity.js +62 -0
- package/dist/src/models/group-system-role.entity.js.map +1 -0
- package/dist/src/models/login-history.entity.d.ts +12 -0
- package/dist/src/models/login-history.entity.js +70 -0
- package/dist/src/models/login-history.entity.js.map +1 -0
- package/dist/src/models/oauth-token.entity.d.ts +14 -0
- package/dist/src/models/oauth-token.entity.js +86 -0
- package/dist/src/models/oauth-token.entity.js.map +1 -0
- package/dist/src/models/role.entity.d.ts +17 -0
- package/dist/src/models/role.entity.js +102 -0
- package/dist/src/models/role.entity.js.map +1 -0
- package/dist/src/models/staff-type.entity.d.ts +7 -0
- package/dist/src/models/staff-type.entity.js +50 -0
- package/dist/src/models/staff-type.entity.js.map +1 -0
- package/dist/src/models/staff.entity.d.ts +39 -0
- package/dist/src/models/staff.entity.js +250 -0
- package/dist/src/models/staff.entity.js.map +1 -0
- package/dist/src/models/state.entity.d.ts +10 -0
- package/dist/src/models/state.entity.js +64 -0
- package/dist/src/models/state.entity.js.map +1 -0
- package/dist/src/models/system-accesss.entity.d.ts +6 -0
- package/dist/src/models/system-accesss.entity.js +51 -0
- package/dist/src/models/system-accesss.entity.js.map +1 -0
- package/dist/src/models/system-privilege.entity.d.ts +16 -0
- package/dist/src/models/system-privilege.entity.js +90 -0
- package/dist/src/models/system-privilege.entity.js.map +1 -0
- package/dist/src/models/system-role-privilege.entity.d.ts +11 -0
- package/dist/src/models/system-role-privilege.entity.js +60 -0
- package/dist/src/models/system-role-privilege.entity.js.map +1 -0
- package/dist/src/models/system-role.entity.d.ts +11 -0
- package/dist/src/models/system-role.entity.js +83 -0
- package/dist/src/models/system-role.entity.js.map +1 -0
- package/dist/src/models/system.entity.d.ts +19 -0
- package/dist/src/models/system.entity.js +146 -0
- package/dist/src/models/system.entity.js.map +1 -0
- package/dist/src/models/user-group.entity.d.ts +23 -0
- package/dist/src/models/user-group.entity.js +140 -0
- package/dist/src/models/user-group.entity.js.map +1 -0
- package/dist/src/models/user-role.entity.d.ts +9 -0
- package/dist/src/models/user-role.entity.js +62 -0
- package/dist/src/models/user-role.entity.js.map +1 -0
- package/dist/src/models/user-system-privileges.entity.d.ts +13 -0
- package/dist/src/models/user-system-privileges.entity.js +80 -0
- package/dist/src/models/user-system-privileges.entity.js.map +1 -0
- package/dist/src/models/user-system-role.entity.d.ts +11 -0
- package/dist/src/models/user-system-role.entity.js +60 -0
- package/dist/src/models/user-system-role.entity.js.map +1 -0
- package/dist/src/models/user-user-group.entity.d.ts +14 -0
- package/dist/src/models/user-user-group.entity.js +73 -0
- package/dist/src/models/user-user-group.entity.js.map +1 -0
- package/dist/src/models/user.entity.d.ts +30 -0
- package/dist/src/models/user.entity.js +131 -0
- package/dist/src/models/user.entity.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/01-alter-system-privilege-table.js +13 -0
- package/migrations/02-alter-user-group-table.js +78 -0
- package/migrations/03-alter-user-system-privilege-table.js +38 -0
- package/migrations/04-create-user-user-group-table.js +55 -0
- package/migrations/05-create-login-history-table.js +49 -0
- package/package.json +8 -4
- package/src/components/login-history/login-history.repository.ts +35 -23
- package/src/components/login-user/login-user.ts +65 -65
- package/src/components/login-user/user.repository.ts +35 -23
- package/src/components/system/system.repository.ts +34 -23
- package/src/components/system-access/system-access.repository.ts +35 -23
- package/src/components/user-group/user-group.repository.ts +35 -23
- package/src/components/user-user-group/user-user-group.repository.ts +35 -23
- package/src/database.ts +15 -0
- package/src/models/authorization-code.entity.ts +71 -0
- package/src/models/bearer-token.entity.ts +59 -0
- package/src/models/building-type.entity.ts +38 -0
- package/src/models/building.entity.ts +185 -0
- package/src/models/city.entity.ts +59 -0
- package/src/models/company.entity.ts +96 -0
- package/src/models/country.entity.ts +75 -0
- package/src/models/department.entity.ts +94 -0
- package/src/models/group-role-privilege.entity.ts +73 -0
- package/src/models/group-system-access.entity.ts +49 -0
- package/src/models/group-system-privilege.entity.ts +49 -0
- package/src/models/group-system-role.entity.ts +49 -0
- package/src/models/login-history.entity.ts +56 -0
- package/src/models/oauth-token.entity.ts +71 -0
- package/src/models/role.entity.ts +85 -0
- package/src/models/staff-type.entity.ts +38 -0
- package/src/models/staff.entity.ts +213 -0
- package/src/models/state.entity.ts +52 -0
- package/src/models/system-accesss.entity.ts +40 -0
- package/src/models/system-privilege.entity.ts +75 -0
- package/src/models/system-role-privilege.entity.ts +48 -0
- package/src/models/system-role.entity.ts +68 -0
- package/src/models/system.entity.ts +122 -0
- package/src/models/user-group.entity.ts +118 -0
- package/src/models/user-role.entity.ts +50 -0
- package/src/models/user-system-privileges.entity.ts +66 -0
- package/src/models/user-system-role.entity.ts +48 -0
- package/src/models/user-user-group.entity.ts +59 -0
- package/src/models/user.entity.ts +110 -0
- package/dist/src/mail/index.d.ts +0 -2
- package/dist/src/mail/index.js +0 -19
- package/dist/src/mail/index.js.map +0 -1
- package/dist/src/mail/interfaces/index.d.ts +0 -2
- package/dist/src/mail/interfaces/index.js +0 -19
- package/dist/src/mail/interfaces/index.js.map +0 -1
- package/dist/src/mail/interfaces/send-mail.interface.d.ts +0 -8
- package/dist/src/mail/interfaces/send-mail.interface.js +0 -3
- package/dist/src/mail/interfaces/send-mail.interface.js.map +0 -1
- package/dist/src/mail/interfaces/send-new-login-alert.interface.d.ts +0 -6
- package/dist/src/mail/interfaces/send-new-login-alert.interface.js +0 -3
- package/dist/src/mail/interfaces/send-new-login-alert.interface.js.map +0 -1
- package/dist/src/mail/mail.d.ts +0 -7
- package/dist/src/mail/mail.js +0 -49
- package/dist/src/mail/mail.js.map +0 -1
- package/dist/src/mail/mail.service.d.ts +0 -7
- package/dist/src/mail/mail.service.js +0 -42
- package/dist/src/mail/mail.service.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,660 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const src_1 = require("../../../../src");
|
13
|
-
const login_user_1 = require("../../../../src/components/login-user/login-user");
|
14
|
-
const user_repository_1 = require("../../../../src/components/login-user/user.repository");
|
15
|
-
const password_hash_service_1 = require("../../../../src/components/password-hash/password-hash.service");
|
16
|
-
const mailer_1 = require("@tomei/mailer");
|
17
|
-
describe('login-user', () => {
|
18
|
-
let isSessionExist = true;
|
19
|
-
let user = {
|
20
|
-
id: 755,
|
21
|
-
email: 'ezcash+florence@tomei.com.my',
|
22
|
-
password: '$argon2id$v=19$m=4096,t=3,p=1$571ilUAi9n5g393m/NqKbQ$2bMnLtMCIVTjHWHGEDxI2wo+A3mrL3N5rTxDJ6ydPi8',
|
23
|
-
status: null,
|
24
|
-
defaultPasswordChanged: false,
|
25
|
-
firstLoginAt: new Date('2023-01-10T07:57:10.000Z'),
|
26
|
-
createdAt: new Date('2023-01-10T07:57:10.000Z'),
|
27
|
-
updatedAt: new Date('2023-01-10T08:58:15.000Z'),
|
28
|
-
groupCode: 'EZCFT',
|
29
|
-
staffs: [
|
30
|
-
{
|
31
|
-
id: 740,
|
32
|
-
staffId: 'EZC003',
|
33
|
-
fullName: 'EZC Florence',
|
34
|
-
preferredName: 'EZC Florence',
|
35
|
-
email: 'ezcash+florence@tomei.com.my',
|
36
|
-
staffTypeId: 1,
|
37
|
-
jobTitle: 'EZC Finance',
|
38
|
-
carPlate: '',
|
39
|
-
mobile: '60123456',
|
40
|
-
floor: null,
|
41
|
-
extension: null,
|
42
|
-
isCharge: false,
|
43
|
-
status: 'active',
|
44
|
-
userId: 755,
|
45
|
-
buildingId: 20,
|
46
|
-
departmentId: 110,
|
47
|
-
companyId: 70,
|
48
|
-
createdById: 74,
|
49
|
-
updatedById: 74,
|
50
|
-
createdAt: new Date('2023-01-10T07:57:10.000Z'),
|
51
|
-
updatedAt: new Date('2023-01-10T07:57:10.000Z'),
|
52
|
-
image: null,
|
53
|
-
idNo: '123123123',
|
54
|
-
fullAddress: 'Lorem Address',
|
55
|
-
},
|
56
|
-
],
|
57
|
-
userSystemPrivileges: [
|
58
|
-
{
|
59
|
-
userId: 22,
|
60
|
-
privilegeId: 'ckymxuh8t000137t011w89zgk',
|
61
|
-
isInheritedYN: 'N',
|
62
|
-
isRevokedYN: 'N',
|
63
|
-
createdAt: new Date('2022-04-18T04:07:40.000Z'),
|
64
|
-
updatedAt: new Date('2022-04-18T04:07:40.000Z'),
|
65
|
-
systemPrivilege: {
|
66
|
-
privilegeId: 'ckymxuh8t000137t011w89zgk',
|
67
|
-
systemId: 175,
|
68
|
-
code: 'Terminate Data',
|
69
|
-
module: null,
|
70
|
-
description: 'Allows the user to terminate a loan.',
|
71
|
-
createdAt: new Date(),
|
72
|
-
updatedAt: new Date(),
|
73
|
-
},
|
74
|
-
},
|
75
|
-
],
|
76
|
-
};
|
77
|
-
const system = {
|
78
|
-
id: 175,
|
79
|
-
code: 'EZC',
|
80
|
-
name: 'EzCash',
|
81
|
-
description: 'Tomei Money Lending System',
|
82
|
-
accessUrl: 'https://app.ezcash.com.my:22443/staff/login',
|
83
|
-
googlePlayUrl: '',
|
84
|
-
appleStoreUrl: '',
|
85
|
-
apiKey: 'VqS9ks2Lwvqd7HrVUMMIP2q7zaEH689HCPaEaFUQLmiRoZnt',
|
86
|
-
logo: 'https://sso-api.tomei.com.my/upload/2023/01/10/FJ3DoHdRZKjf2bGkgA4E-BrowserIcon.png',
|
87
|
-
status: 'active',
|
88
|
-
visible: true,
|
89
|
-
createdAt: new Date('2023-01-09T00:45:57.000Z'),
|
90
|
-
updatedAt: new Date('2023-01-10T06:28:56.000Z'),
|
91
|
-
apiSecret: '$argon2id$v=19$m=4096,t=3,p=1$lqxfk/ujftswf2jSEu156g$j2IShE/BZUUoH/1jrvt3GGRSy0rA8HilJvK17e6vdFY',
|
92
|
-
updatedById: 61,
|
93
|
-
createdById: 100,
|
94
|
-
};
|
95
|
-
const systemAccess = {
|
96
|
-
userId: 755,
|
97
|
-
systemId: 175,
|
98
|
-
updatedAt: new Date('2023-01-09T00:45:57.000'),
|
99
|
-
};
|
100
|
-
const session = {
|
101
|
-
systemLogins: [
|
102
|
-
{
|
103
|
-
id: '175',
|
104
|
-
code: 'EZC',
|
105
|
-
sessionId: 'ckymxuh8t000137t011w89zgk',
|
106
|
-
privileges: [
|
107
|
-
'Terminate',
|
108
|
-
'Download - Agreement',
|
109
|
-
'Disbursement - Confirmation',
|
110
|
-
'Invoice Payment Received',
|
111
|
-
'Download - Disbursement Receipt',
|
112
|
-
'Download - Stamping Receipt',
|
113
|
-
'Installment Payment Received',
|
114
|
-
'View Transaction History',
|
115
|
-
'Menu - Loans',
|
116
|
-
'Loan - Full Settlement',
|
117
|
-
'View Billing',
|
118
|
-
'Loan - Retrieve List',
|
119
|
-
'Loan - View Details',
|
120
|
-
'Loan - Retrieve Outstanding',
|
121
|
-
'Loan - View Mandate Details',
|
122
|
-
'Loan Document - Retrieve List',
|
123
|
-
'Loan Document - View',
|
124
|
-
'Loan Document - Download',
|
125
|
-
'Application - View Details',
|
126
|
-
'Simple Loan Schedule - Get Overdue Schedules',
|
127
|
-
'Simple Loan Schedule - Get Schedule Payment Details',
|
128
|
-
'Retrieve Media List',
|
129
|
-
'Retrieve Customer List',
|
130
|
-
'View Loan Activity',
|
131
|
-
'Activate Installment',
|
132
|
-
'Manual Payment Receipt',
|
133
|
-
'Customer Documents - View',
|
134
|
-
],
|
135
|
-
},
|
136
|
-
],
|
137
|
-
};
|
138
|
-
let ezcft = {
|
139
|
-
groupCode: 'EZCFT',
|
140
|
-
groupDescription: 'EZCASH FINANCE TEAM',
|
141
|
-
status: 'Active',
|
142
|
-
personInCharge: null,
|
143
|
-
fullPath: null,
|
144
|
-
parentGroupCode: 'EZCCS',
|
145
|
-
groupLevel: 2,
|
146
|
-
groupType: null,
|
147
|
-
allowInheritFromParentYN: 'Y',
|
148
|
-
createdById: '61',
|
149
|
-
createdAt: new Date(),
|
150
|
-
updatedById: '61',
|
151
|
-
updatedAt: new Date(),
|
152
|
-
departmentId: 110,
|
153
|
-
groupSystemPrivileges: [],
|
154
|
-
groupRolePrivileges: [
|
155
|
-
{
|
156
|
-
groupCode: 'EZCFT',
|
157
|
-
roleId: 'clcogtmco00013unyc4ngcnza',
|
158
|
-
privilegeId: 'clcogtntx00023unyg98a0ah0',
|
159
|
-
createdById: 74,
|
160
|
-
createdAt: new Date(),
|
161
|
-
systemId: 175,
|
162
|
-
systemPrivilege: {
|
163
|
-
privilegeId: 'clcogtntx00023unyg98a0ah0',
|
164
|
-
systemId: 175,
|
165
|
-
code: 'Terminate',
|
166
|
-
module: null,
|
167
|
-
description: 'Allows the user to terminate a loan.',
|
168
|
-
createdAt: new Date(),
|
169
|
-
updatedAt: new Date(),
|
170
|
-
},
|
171
|
-
},
|
172
|
-
{
|
173
|
-
groupCode: 'EZCFT',
|
174
|
-
roleId: 'clcogtmco00013unyc4ngcnza',
|
175
|
-
privilegeId: 'clcogtnys00043wp21ejm068j',
|
176
|
-
createdById: 74,
|
177
|
-
createdAt: new Date(),
|
178
|
-
systemId: 175,
|
179
|
-
systemPrivilege: {
|
180
|
-
privilegeId: 'clcogtnys00043wp21ejm068j',
|
181
|
-
systemId: 175,
|
182
|
-
code: 'Download - Agreement',
|
183
|
-
module: null,
|
184
|
-
description: 'Allows the user to download the agreement.',
|
185
|
-
createdAt: new Date(),
|
186
|
-
updatedAt: new Date(),
|
187
|
-
},
|
188
|
-
},
|
189
|
-
{
|
190
|
-
groupCode: 'EZCFT',
|
191
|
-
roleId: 'clcogtmco00013unyc4ngcnza',
|
192
|
-
privilegeId: 'clcogtoa100063wp2djq10roz',
|
193
|
-
createdById: 74,
|
194
|
-
createdAt: new Date(),
|
195
|
-
systemId: 175,
|
196
|
-
systemPrivilege: {
|
197
|
-
privilegeId: 'clcogtoa100063wp2djq10roz',
|
198
|
-
systemId: 175,
|
199
|
-
code: 'Disbursement - Confirmation',
|
200
|
-
module: null,
|
201
|
-
description: 'Allows the user to confirm the disbursement of the loan.',
|
202
|
-
createdAt: new Date(),
|
203
|
-
updatedAt: new Date(),
|
204
|
-
},
|
205
|
-
},
|
206
|
-
{
|
207
|
-
groupCode: 'EZCFT',
|
208
|
-
roleId: 'clcogtmco00013unyc4ngcnza',
|
209
|
-
privilegeId: 'clcogtob000053uny52atenxa',
|
210
|
-
createdById: 74,
|
211
|
-
createdAt: new Date(),
|
212
|
-
systemId: 175,
|
213
|
-
systemPrivilege: {
|
214
|
-
privilegeId: 'clcogtob000053uny52atenxa',
|
215
|
-
systemId: 175,
|
216
|
-
code: 'Invoice Payment Received',
|
217
|
-
module: null,
|
218
|
-
description: 'Allows the user to confirm payment receipt of an invoice.',
|
219
|
-
createdAt: new Date(),
|
220
|
-
updatedAt: new Date(),
|
221
|
-
},
|
222
|
-
},
|
223
|
-
],
|
224
|
-
};
|
225
|
-
const ezccs = {
|
226
|
-
groupCode: 'EZCCS',
|
227
|
-
groupDescription: 'EZCASH COMPANY SIGNER',
|
228
|
-
status: 'Active',
|
229
|
-
personInCharge: null,
|
230
|
-
fullPath: null,
|
231
|
-
parentGroupCode: 'EZCAT',
|
232
|
-
groupLevel: 1,
|
233
|
-
groupType: null,
|
234
|
-
allowInheritFromParentYN: 'Y',
|
235
|
-
createdById: '61',
|
236
|
-
createdAt: new Date(),
|
237
|
-
updatedById: '61',
|
238
|
-
updatedAt: new Date(),
|
239
|
-
departmentId: 110,
|
240
|
-
groupSystemPrivileges: [],
|
241
|
-
groupRolePrivileges: [
|
242
|
-
{
|
243
|
-
groupCode: 'EZCCS',
|
244
|
-
roleId: 'cl34552or00002vlubgs11tc9',
|
245
|
-
privilegeId: 'cldu3gd7t000g3spe55jmax51',
|
246
|
-
createdById: 700,
|
247
|
-
createdAt: new Date(),
|
248
|
-
systemId: 42,
|
249
|
-
systemPrivilege: {
|
250
|
-
privilegeId: 'cldu3gd7t000g3spe55jmax51',
|
251
|
-
systemId: 42,
|
252
|
-
code: 'View Customer',
|
253
|
-
module: null,
|
254
|
-
description: 'Allow to view customer details',
|
255
|
-
createdAt: new Date(),
|
256
|
-
updatedAt: new Date(),
|
257
|
-
},
|
258
|
-
},
|
259
|
-
{
|
260
|
-
groupCode: 'EZCCS',
|
261
|
-
roleId: 'clcogtm8000003unybenw69nl',
|
262
|
-
privilegeId: 'clcogtnsn00023wp21z5n28az',
|
263
|
-
createdById: 700,
|
264
|
-
createdAt: new Date(),
|
265
|
-
systemId: 175,
|
266
|
-
systemPrivilege: {
|
267
|
-
privilegeId: 'clcogtnsn00023wp21z5n28az',
|
268
|
-
systemId: 175,
|
269
|
-
code: 'Signer - Company',
|
270
|
-
module: null,
|
271
|
-
description: 'Allows the user to sign loan agreements on behalf of the company.',
|
272
|
-
createdAt: new Date(),
|
273
|
-
updatedAt: new Date(),
|
274
|
-
},
|
275
|
-
},
|
276
|
-
{
|
277
|
-
groupCode: 'EZCCS',
|
278
|
-
roleId: 'clcogtm8000003unybenw69nl',
|
279
|
-
privilegeId: 'clcogtnys00043wp21ejm068j',
|
280
|
-
createdById: 700,
|
281
|
-
createdAt: new Date(),
|
282
|
-
systemId: 175,
|
283
|
-
systemPrivilege: {
|
284
|
-
privilegeId: 'clcogtnys00043wp21ejm068j',
|
285
|
-
systemId: 175,
|
286
|
-
code: 'Download - Agreement',
|
287
|
-
module: null,
|
288
|
-
description: 'Allows the user to download the agreement.',
|
289
|
-
createdAt: new Date(),
|
290
|
-
updatedAt: new Date(),
|
291
|
-
},
|
292
|
-
},
|
293
|
-
{
|
294
|
-
groupCode: 'EZCCS',
|
295
|
-
roleId: 'clcogtm8000003unybenw69nl',
|
296
|
-
privilegeId: 'clcogtqb400074dn47ld564nt',
|
297
|
-
createdById: 700,
|
298
|
-
createdAt: new Date(),
|
299
|
-
systemId: 175,
|
300
|
-
systemPrivilege: {
|
301
|
-
privilegeId: 'clds7oql500003spe3hubafn6',
|
302
|
-
systemId: 175,
|
303
|
-
code: 'Loan - Retrieve List',
|
304
|
-
module: null,
|
305
|
-
description: 'Allows the user to retrieve the loan listing/search for all loans within the system.',
|
306
|
-
createdAt: new Date(),
|
307
|
-
updatedAt: new Date(),
|
308
|
-
},
|
309
|
-
},
|
310
|
-
],
|
311
|
-
};
|
312
|
-
const ezcat = {
|
313
|
-
groupCode: 'EZCAT',
|
314
|
-
groupDescription: 'EZC ATTESTATOR',
|
315
|
-
status: 'Active',
|
316
|
-
personInCharge: null,
|
317
|
-
fullPath: null,
|
318
|
-
parentGroupCode: null,
|
319
|
-
groupLevel: 0,
|
320
|
-
groupType: null,
|
321
|
-
allowInheritFromParentYN: 'Y',
|
322
|
-
createdById: '61',
|
323
|
-
createdAt: new Date(),
|
324
|
-
updatedById: '61',
|
325
|
-
updatedAt: new Date(),
|
326
|
-
departmentId: 110,
|
327
|
-
groupSystemPrivileges: [],
|
328
|
-
groupRolePrivileges: [
|
329
|
-
{
|
330
|
-
groupCode: 'EZCAT',
|
331
|
-
roleId: 'cl34552or00002vlubgs11tc9',
|
332
|
-
privilegeId: 'cldu3gd7t000g3spe55jmax51',
|
333
|
-
createdById: 700,
|
334
|
-
createdAt: new Date(),
|
335
|
-
systemId: 42,
|
336
|
-
systemPrivilege: {
|
337
|
-
privilegeId: 'cldu3gd7t000g3spe55jmax51',
|
338
|
-
systemId: 42,
|
339
|
-
code: 'View Customer',
|
340
|
-
module: null,
|
341
|
-
description: 'Allow to view customer details',
|
342
|
-
createdAt: new Date(),
|
343
|
-
updatedAt: new Date(),
|
344
|
-
},
|
345
|
-
},
|
346
|
-
{
|
347
|
-
groupCode: 'EZCAT',
|
348
|
-
roleId: 'clcogtmyx00014dn4798pel3n',
|
349
|
-
privilegeId: 'clcogtnuf00033wp27vwb1vwl',
|
350
|
-
createdById: 74,
|
351
|
-
createdAt: new Date(),
|
352
|
-
systemId: 175,
|
353
|
-
systemPrivilege: {
|
354
|
-
privilegeId: 'clcogtnuf00033wp27vwb1vwl',
|
355
|
-
systemId: 175,
|
356
|
-
code: 'Signing Session - Schedule',
|
357
|
-
module: null,
|
358
|
-
description: 'Allows the user to schedule or reschedule the signing session.',
|
359
|
-
createdAt: new Date(),
|
360
|
-
updatedAt: new Date(),
|
361
|
-
},
|
362
|
-
},
|
363
|
-
{
|
364
|
-
groupCode: 'EZCAT',
|
365
|
-
roleId: 'clcogtmyx00014dn4798pel3n',
|
366
|
-
privilegeId: 'clcogto8t00043unyd60c8j6r',
|
367
|
-
createdById: 74,
|
368
|
-
createdAt: new Date(),
|
369
|
-
systemId: 175,
|
370
|
-
systemPrivilege: {
|
371
|
-
privilegeId: 'clcogto8t00043unyd60c8j6r',
|
372
|
-
systemId: 175,
|
373
|
-
code: 'Signing Session - No Show',
|
374
|
-
module: null,
|
375
|
-
description: 'Allows the user to mark the signing session as "no show".',
|
376
|
-
createdAt: new Date(),
|
377
|
-
updatedAt: new Date(),
|
378
|
-
},
|
379
|
-
},
|
380
|
-
{
|
381
|
-
groupCode: 'EZCAT',
|
382
|
-
roleId: 'clcogtmyx00014dn4798pel3n',
|
383
|
-
privilegeId: 'clcogtobc00073wp21lanh2qw',
|
384
|
-
createdById: 74,
|
385
|
-
createdAt: new Date(),
|
386
|
-
systemId: 175,
|
387
|
-
systemPrivilege: {
|
388
|
-
privilegeId: 'clcogtobc00073wp21lanh2qw',
|
389
|
-
systemId: 175,
|
390
|
-
code: 'Setup Session',
|
391
|
-
module: null,
|
392
|
-
description: 'Allows the users to set up the predefined slots for the live attestation sessions.',
|
393
|
-
createdAt: new Date(),
|
394
|
-
updatedAt: new Date(),
|
395
|
-
},
|
396
|
-
},
|
397
|
-
],
|
398
|
-
};
|
399
|
-
let userUserGroups = [
|
400
|
-
{
|
401
|
-
userId: 755,
|
402
|
-
groupCode: 'EZCFT',
|
403
|
-
systemId: 175,
|
404
|
-
createdAt: new Date(),
|
405
|
-
updatedAt: new Date(),
|
406
|
-
userGroup: ezcft,
|
407
|
-
},
|
408
|
-
];
|
409
|
-
jest.mock('crypto', () => {
|
410
|
-
return {
|
411
|
-
randomUUID: jest.fn().mockReturnValue('ckymxuh8t000137t011w89zgk'),
|
412
|
-
};
|
413
|
-
});
|
414
|
-
jest
|
415
|
-
.spyOn(password_hash_service_1.PasswordHashService.prototype, 'verify')
|
416
|
-
.mockImplementation((password) => __awaiter(void 0, void 0, void 0, function* () {
|
417
|
-
if (password === 'Abcd@1234') {
|
418
|
-
return true;
|
419
|
-
}
|
420
|
-
else {
|
421
|
-
return false;
|
422
|
-
}
|
423
|
-
}));
|
424
|
-
jest
|
425
|
-
.spyOn(src_1.SystemRepository.prototype, 'findOne')
|
426
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
427
|
-
return system;
|
428
|
-
}));
|
429
|
-
jest.spyOn(mailer_1.Mailer.prototype, 'sendMail').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { }));
|
430
|
-
const getUserGroupFromDBMock = jest.spyOn(login_user_1.LoginUser.prototype, 'getUserGroupFromDB');
|
431
|
-
const getUserUserGroupFromDBMock = jest.spyOn(login_user_1.LoginUser.prototype, 'getUserUserGroupFromDB');
|
432
|
-
const userMock = jest.spyOn(user_repository_1.UserRepository.prototype, 'findOne');
|
433
|
-
jest.spyOn(src_1.SessionService.prototype, 'retrieveUserSession').mockImplementation((userId) => __awaiter(void 0, void 0, void 0, function* () {
|
434
|
-
if (userId && userId == '755' && isSessionExist === true) {
|
435
|
-
return session;
|
436
|
-
}
|
437
|
-
else {
|
438
|
-
return {
|
439
|
-
systemLogins: [],
|
440
|
-
};
|
441
|
-
}
|
442
|
-
}));
|
443
|
-
userMock.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
444
|
-
return user;
|
445
|
-
}));
|
446
|
-
getUserGroupFromDBMock.mockImplementation((groupCode) => __awaiter(void 0, void 0, void 0, function* () {
|
447
|
-
if (groupCode === 'EZCFT') {
|
448
|
-
return ezcft;
|
449
|
-
}
|
450
|
-
else if (groupCode === 'EZCCS') {
|
451
|
-
return ezccs;
|
452
|
-
}
|
453
|
-
else if (groupCode === 'EZCAT') {
|
454
|
-
return ezcat;
|
455
|
-
}
|
456
|
-
}));
|
457
|
-
getUserUserGroupFromDBMock.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
458
|
-
return userUserGroups;
|
459
|
-
}));
|
460
|
-
describe('login', () => {
|
461
|
-
jest
|
462
|
-
.spyOn(src_1.SystemAccessRepository.prototype, 'findOne')
|
463
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
464
|
-
return systemAccess;
|
465
|
-
}));
|
466
|
-
jest
|
467
|
-
.spyOn(src_1.LoginHistoryRepository.prototype, 'findAll')
|
468
|
-
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
469
|
-
const data = [];
|
470
|
-
return data;
|
471
|
-
}));
|
472
|
-
afterAll(() => {
|
473
|
-
jest.clearAllMocks();
|
474
|
-
});
|
475
|
-
it('should return login-user service when instansiated', () => __awaiter(void 0, void 0, void 0, function* () {
|
476
|
-
const loginUser = yield login_user_1.LoginUser.init();
|
477
|
-
expect(loginUser).toBeDefined();
|
478
|
-
}));
|
479
|
-
it('should able to do login process when no session is already available', () => __awaiter(void 0, void 0, void 0, function* () {
|
480
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
481
|
-
const result = yield loginUser.login('EZC', 'ezcash+florence@tomei.com.my', 'Abcd@1234', '1.1.1.1');
|
482
|
-
expect(result).toEqual('ckymxuh8t000137t011w89zgk');
|
483
|
-
}));
|
484
|
-
it('should able to do login process when session is already available', () => __awaiter(void 0, void 0, void 0, function* () {
|
485
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
486
|
-
const result = yield loginUser.login('EZC', 'ezcash+florence@tomei.com.my', 'Abcd@1234', '1.1.1.1');
|
487
|
-
expect(result).toEqual('ckymxuh8t000137t011w89zgk');
|
488
|
-
}));
|
489
|
-
});
|
490
|
-
describe('getPrivileges', () => {
|
491
|
-
afterAll(() => {
|
492
|
-
jest.clearAllMocks();
|
493
|
-
});
|
494
|
-
it('should be able to login when user only have one user group with level 1 or higher', () => __awaiter(void 0, void 0, void 0, function* () {
|
495
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
496
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
497
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(2);
|
498
|
-
expect(result).toEqual([
|
499
|
-
'View Customer',
|
500
|
-
'Signer - Company',
|
501
|
-
'Download - Agreement',
|
502
|
-
'Loan - Retrieve List',
|
503
|
-
'Signing Session - Schedule',
|
504
|
-
'Signing Session - No Show',
|
505
|
-
'Setup Session',
|
506
|
-
'Terminate',
|
507
|
-
'Disbursement - Confirmation',
|
508
|
-
'Invoice Payment Received',
|
509
|
-
'Terminate Data',
|
510
|
-
]);
|
511
|
-
}));
|
512
|
-
it('should be able to login when user only have multiple user user group', () => __awaiter(void 0, void 0, void 0, function* () {
|
513
|
-
const tempUserUserGroups = userUserGroups;
|
514
|
-
userUserGroups.push(userUserGroups[0]);
|
515
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
516
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
517
|
-
expect(getUserUserGroupFromDBMock).toBeCalledTimes(1);
|
518
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(4);
|
519
|
-
expect(result).toEqual([
|
520
|
-
'View Customer',
|
521
|
-
'Signer - Company',
|
522
|
-
'Download - Agreement',
|
523
|
-
'Loan - Retrieve List',
|
524
|
-
'Signing Session - Schedule',
|
525
|
-
'Signing Session - No Show',
|
526
|
-
'Setup Session',
|
527
|
-
'Terminate',
|
528
|
-
'Disbursement - Confirmation',
|
529
|
-
'Invoice Payment Received',
|
530
|
-
'Terminate Data',
|
531
|
-
]);
|
532
|
-
userUserGroups = tempUserUserGroups;
|
533
|
-
}));
|
534
|
-
it('should be able to login when user only have user privilege', () => __awaiter(void 0, void 0, void 0, function* () {
|
535
|
-
const tempUserUserGroup = userUserGroups;
|
536
|
-
userUserGroups = [];
|
537
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
538
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
539
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
540
|
-
expect(result).toEqual(['Terminate Data']);
|
541
|
-
userUserGroups = tempUserUserGroup;
|
542
|
-
}));
|
543
|
-
it('should be able to login when user only have one user group with no parent', () => __awaiter(void 0, void 0, void 0, function* () {
|
544
|
-
const tempEzcft = ezcft;
|
545
|
-
ezcft.groupLevel = 0;
|
546
|
-
const tempUser = user;
|
547
|
-
user.userSystemPrivileges = [];
|
548
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
549
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
550
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
551
|
-
expect(result).toEqual([
|
552
|
-
'Terminate',
|
553
|
-
'Download - Agreement',
|
554
|
-
'Disbursement - Confirmation',
|
555
|
-
'Invoice Payment Received',
|
556
|
-
]);
|
557
|
-
ezcft = tempEzcft;
|
558
|
-
user = tempUser;
|
559
|
-
}));
|
560
|
-
it('should be able to login when user only have one user group that cannot inherit privilege', () => __awaiter(void 0, void 0, void 0, function* () {
|
561
|
-
const tempEzcft = ezcft;
|
562
|
-
ezcft.groupLevel = 1;
|
563
|
-
ezcft.allowInheritFromParentYN = 'N';
|
564
|
-
const tempUser = user;
|
565
|
-
user.userSystemPrivileges = [];
|
566
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
567
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
568
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
569
|
-
expect(result).toEqual([
|
570
|
-
'Terminate',
|
571
|
-
'Download - Agreement',
|
572
|
-
'Disbursement - Confirmation',
|
573
|
-
'Invoice Payment Received',
|
574
|
-
]);
|
575
|
-
ezcft = tempEzcft;
|
576
|
-
user = tempUser;
|
577
|
-
}));
|
578
|
-
it('should be able to login when user dont have user privilage or user usergroup', () => __awaiter(void 0, void 0, void 0, function* () {
|
579
|
-
const tempUser = user;
|
580
|
-
user.userSystemPrivileges = [];
|
581
|
-
const tempUserUserGroup = userUserGroups;
|
582
|
-
userUserGroups = [];
|
583
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
584
|
-
const result = yield loginUser['getPrivileges']('EZC');
|
585
|
-
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
586
|
-
expect(result).toEqual([]);
|
587
|
-
userUserGroups = tempUserUserGroup;
|
588
|
-
user = tempUser;
|
589
|
-
}));
|
590
|
-
});
|
591
|
-
describe('checkPrivileges', () => {
|
592
|
-
afterEach(() => {
|
593
|
-
isSessionExist = true;
|
594
|
-
});
|
595
|
-
afterAll(() => {
|
596
|
-
jest.restoreAllMocks();
|
597
|
-
});
|
598
|
-
it('should return false if user session not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
599
|
-
isSessionExist = false;
|
600
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
601
|
-
const result = yield loginUser.checkPrivileges('EZC', 'Terminate');
|
602
|
-
expect(result).toEqual(false);
|
603
|
-
}));
|
604
|
-
it('should return false if system login not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
605
|
-
isSessionExist = false;
|
606
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
607
|
-
const result = yield loginUser.checkPrivileges('EZC', 'Terminate');
|
608
|
-
expect(result).toEqual(false);
|
609
|
-
}));
|
610
|
-
it('should return false if privilege not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
611
|
-
isSessionExist = false;
|
612
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
613
|
-
const result = yield loginUser.checkPrivileges('EZC', 'Not Terminate');
|
614
|
-
expect(result).toEqual(false);
|
615
|
-
}));
|
616
|
-
it('should return true if privilege found', () => __awaiter(void 0, void 0, void 0, function* () {
|
617
|
-
const loginUser = yield login_user_1.LoginUser.init('755');
|
618
|
-
const result = yield loginUser.checkPrivileges('EZC', 'Terminate');
|
619
|
-
expect(result).toEqual(true);
|
620
|
-
}));
|
621
|
-
});
|
622
|
-
describe('checkSession', () => {
|
623
|
-
afterEach(() => {
|
624
|
-
isSessionExist = true;
|
625
|
-
});
|
626
|
-
afterAll(() => {
|
627
|
-
jest.restoreAllMocks();
|
628
|
-
});
|
629
|
-
it('it should returns session expired if user session not found inside session storage', () => __awaiter(void 0, void 0, void 0, function* () {
|
630
|
-
try {
|
631
|
-
isSessionExist = false;
|
632
|
-
const loginUser = yield login_user_1.LoginUser.init();
|
633
|
-
yield loginUser.checkSession('EZC', session.systemLogins[0].sessionId, '755');
|
634
|
-
}
|
635
|
-
catch (error) {
|
636
|
-
expect(error.message).toEqual('Session expired.');
|
637
|
-
}
|
638
|
-
}));
|
639
|
-
it('it should returns session expired if sessionId not matched', () => __awaiter(void 0, void 0, void 0, function* () {
|
640
|
-
try {
|
641
|
-
const loginUser = yield login_user_1.LoginUser.init();
|
642
|
-
yield loginUser.checkSession('NOTEZC', session.systemLogins[0].sessionId, '755');
|
643
|
-
}
|
644
|
-
catch (error) {
|
645
|
-
expect(error.message).toEqual('Session expired.');
|
646
|
-
}
|
647
|
-
}));
|
648
|
-
it('it should refresh session time-to-live if session valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
649
|
-
jest.spyOn(src_1.SessionService.prototype, 'refreshDuration').mockImplementationOnce((userId) => __awaiter(void 0, void 0, void 0, function* () {
|
650
|
-
if (!userId || userId !== '755') {
|
651
|
-
throw new Error('Refresh session failed.');
|
652
|
-
}
|
653
|
-
}));
|
654
|
-
const loginUser = yield login_user_1.LoginUser.init();
|
655
|
-
const result = yield loginUser.checkSession('EZC', session.systemLogins[0].sessionId, '755');
|
656
|
-
expect(result).toEqual(session.systemLogins[0]);
|
657
|
-
}));
|
658
|
-
});
|
659
|
-
});
|
660
1
|
//# sourceMappingURL=login-user.spec.js.map
|