@tomei/sso 0.66.0 → 0.66.1-test.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/.commitlintrc.json +22 -22
- package/.gitlab-ci.yml +237 -16
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/Jenkinsfile +57 -57
- package/README.md +23 -23
- package/__tests__/unit/components/api-key/api-key.spec.ts +201 -0
- package/__tests__/unit/components/group/group.spec.ts +85 -79
- package/__tests__/unit/components/group-object-privilege/group-object-privilege.spec.ts +88 -88
- package/__tests__/unit/components/group-privilege/group-privilege.spec.ts +68 -68
- package/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.ts +74 -66
- package/__tests__/unit/components/group-system-access/group-system-access.spec.ts +83 -83
- package/__tests__/unit/components/login-user/l.spec.ts +746 -746
- package/__tests__/unit/components/login-user/login.spec.ts +2358 -1164
- package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
- package/__tests__/unit/components/system/system.spec.ts +255 -254
- package/__tests__/unit/components/system-privilege/system-privilege.spec.ts +83 -83
- package/__tests__/unit/components/user-group/user-group.spec.ts +86 -86
- package/__tests__/unit/components/user-object-privilege/user-object-privilege.spec.ts +78 -78
- package/__tests__/unit/components/user-password-history/user-password-history.spec.ts +165 -0
- package/__tests__/unit/components/user-privilege/user-privilege.spec.ts +72 -72
- package/__tests__/unit/components/user-reporting-hierarchy/user-reporting-hierarchy.spec.ts +233 -0
- package/__tests__/unit/components/user-system-access/user-system-access.spec.ts +89 -89
- package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
- package/__tests__/unit/session/session.service.spec.ts +47 -47
- package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
- package/coverage/cobertura-coverage.xml +6837 -0
- package/coverage/test-report.xml +161 -0
- package/create-sso-user.sql +39 -39
- package/dist/__tests__/unit/components/{group-privilege/group-privilege.test.d.ts → api-key/api-key.spec.d.ts} +1 -1
- package/dist/__tests__/unit/components/api-key/api-key.spec.js +158 -0
- package/dist/__tests__/unit/components/api-key/api-key.spec.js.map +1 -0
- package/dist/__tests__/unit/components/group/group.spec.js +4 -0
- package/dist/__tests__/unit/components/group/group.spec.js.map +1 -1
- package/dist/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.js +9 -1
- package/dist/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.js.map +1 -1
- package/dist/__tests__/unit/components/login-user/login.spec.js +703 -0
- package/dist/__tests__/unit/components/login-user/login.spec.js.map +1 -1
- package/dist/__tests__/unit/components/system/system.spec.js +1 -0
- package/dist/__tests__/unit/components/system/system.spec.js.map +1 -1
- package/dist/__tests__/unit/components/user-password-history/user-password-history.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/user-password-history/user-password-history.spec.js +138 -0
- package/dist/__tests__/unit/components/user-password-history/user-password-history.spec.js.map +1 -0
- package/dist/__tests__/unit/components/user-reporting-hierarchy/user-reporting-hierarchy.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/user-reporting-hierarchy/user-reporting-hierarchy.spec.js +182 -0
- package/dist/__tests__/unit/components/user-reporting-hierarchy/user-reporting-hierarchy.spec.js.map +1 -0
- package/dist/src/components/login-user/login-user.js +64 -63
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/login-user/user.d.ts +5 -0
- package/dist/src/components/login-user/user.js +39 -0
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/components/user-password-history/user-password-history.d.ts +1 -0
- package/dist/src/components/user-password-history/user-password-history.js +41 -2
- package/dist/src/components/user-password-history/user-password-history.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- package/jest.config.js +16 -14
- package/migrations/20240314080602-create-user-table.js +124 -124
- package/migrations/20240314080603-create-user-group-table.js +85 -85
- package/migrations/20240314080604-create-user-user-group-table.js +55 -55
- package/migrations/20240314080605-create-login-history-table.js +53 -53
- package/migrations/20240527064925-create-system-table.js +78 -78
- package/migrations/20240527064926-create-system-privilege-table.js +71 -71
- package/migrations/20240527065342-create-group-table.js +93 -93
- package/migrations/20240527065633-create-group-reporting-user-table.js +76 -76
- package/migrations/20240528011551-create-group-system-access-table.js +72 -72
- package/migrations/20240528023018-user-system-access-table.js +75 -75
- package/migrations/20240528032229-user-privilege-table.js +76 -76
- package/migrations/20240528063003-create-group-privilege-table.js +76 -76
- package/migrations/20240528063051-create-group-object-privilege-table.js +84 -84
- package/migrations/20240528063107-create-user-object-privilege-table.js +84 -84
- package/migrations/20240528063108-create-api-key-table.js +85 -85
- package/migrations/20241104104802-create-building-table.js +95 -95
- package/migrations/20250108091132-add-area-manager-user-id-to-building-table.js +14 -14
- package/migrations/20250108091133-add-passcode-to-user-table.js +36 -36
- package/migrations/20250210115636-create-user-reporting-hierarchy.js +76 -76
- package/migrations/20250326043818-crate-user-password-history.js +42 -42
- package/migrations/20250610070720-added-MFBypassYN-to-sso-user.js +30 -30
- package/migrations/20250805085707-add-bulk-approval-code-to-sso-user.js +29 -0
- package/package.json +87 -90
- package/sampledotenv +7 -7
- package/src/components/login-user/login-user.ts +89 -90
- package/src/components/login-user/user.ts +68 -0
- package/src/components/user-password-history/user-password-history.ts +57 -6
- package/src/index.ts +0 -1
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +23 -23
- package/dist/__tests__/unit/components/group-privilege/group-privilege.test.js +0 -71
- package/dist/__tests__/unit/components/group-privilege/group-privilege.test.js.map +0 -1
- package/dist/__tests__/unit/components/login-user/login-user.spec.d.ts +0 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +0 -6
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +0 -1
|
@@ -2988,6 +2988,7 @@ export class User extends UserBase {
|
|
|
2988
2988
|
|
|
2989
2989
|
this.Password = passwordHash;
|
|
2990
2990
|
this.LastPasswordChangedAt = new Date();
|
|
2991
|
+
this.NeedToChangePasswordYN = YN.No;
|
|
2991
2992
|
|
|
2992
2993
|
const entityValueAfter: IUserAttr = {
|
|
2993
2994
|
UserId: this.UserId,
|
|
@@ -3022,6 +3023,7 @@ export class User extends UserBase {
|
|
|
3022
3023
|
{
|
|
3023
3024
|
Password: this.Password,
|
|
3024
3025
|
LastPasswordChangedAt: this.LastPasswordChangedAt,
|
|
3026
|
+
NeedToChangePasswordYN: this.NeedToChangePasswordYN,
|
|
3025
3027
|
},
|
|
3026
3028
|
{
|
|
3027
3029
|
where: {
|
|
@@ -3053,6 +3055,72 @@ export class User extends UserBase {
|
|
|
3053
3055
|
}
|
|
3054
3056
|
}
|
|
3055
3057
|
|
|
3058
|
+
// PASSWORD_EXPIRY_MONTHS=0 disables the policy entirely (AC#1) - checked before NeedToChangePasswordYN/history.
|
|
3059
|
+
async getPasswordExpiryStatus(dbTransaction?: any): Promise<{
|
|
3060
|
+
expired: boolean;
|
|
3061
|
+
expiringSoon: boolean;
|
|
3062
|
+
expiresInDays: number | null;
|
|
3063
|
+
}> {
|
|
3064
|
+
try {
|
|
3065
|
+
const expiryMonthsRaw = Number(process.env.PASSWORD_EXPIRY_MONTHS);
|
|
3066
|
+
const expiryMonths = Number.isFinite(expiryMonthsRaw)
|
|
3067
|
+
? Math.max(0, Math.floor(expiryMonthsRaw))
|
|
3068
|
+
: 0;
|
|
3069
|
+
|
|
3070
|
+
if (expiryMonths === 0) {
|
|
3071
|
+
return { expired: false, expiringSoon: false, expiresInDays: null };
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
// Forces first-login change for temp-password/admin-created accounts (AC#4), regardless of password age.
|
|
3075
|
+
if (this.NeedToChangePasswordYN === YN.Yes) {
|
|
3076
|
+
return { expired: true, expiringSoon: false, expiresInDays: null };
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
const warningDaysRaw = Number(process.env.PASSWORD_EXPIRY_WARNING_DAYS);
|
|
3080
|
+
const warningDays = Number.isFinite(warningDaysRaw)
|
|
3081
|
+
? Math.max(0, Math.floor(warningDaysRaw))
|
|
3082
|
+
: 14;
|
|
3083
|
+
|
|
3084
|
+
const latestHistory = await UserPasswordHistory.getLatestByUserId(
|
|
3085
|
+
dbTransaction,
|
|
3086
|
+
this.UserId,
|
|
3087
|
+
);
|
|
3088
|
+
|
|
3089
|
+
if (!latestHistory) {
|
|
3090
|
+
// Legacy/pre-existing accounts without a history row.
|
|
3091
|
+
return { expired: true, expiringSoon: false, expiresInDays: null };
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
const createdAt = latestHistory.CreatedAt;
|
|
3095
|
+
const expiryDate = new Date(
|
|
3096
|
+
Date.UTC(
|
|
3097
|
+
createdAt.getUTCFullYear(),
|
|
3098
|
+
createdAt.getUTCMonth() + expiryMonths,
|
|
3099
|
+
createdAt.getUTCDate(),
|
|
3100
|
+
createdAt.getUTCHours(),
|
|
3101
|
+
createdAt.getUTCMinutes(),
|
|
3102
|
+
createdAt.getUTCSeconds(),
|
|
3103
|
+
),
|
|
3104
|
+
);
|
|
3105
|
+
|
|
3106
|
+
const now = new Date();
|
|
3107
|
+
if (now.getTime() >= expiryDate.getTime()) {
|
|
3108
|
+
return { expired: true, expiringSoon: false, expiresInDays: null };
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
const msPerDay = 24 * 60 * 60 * 1000;
|
|
3112
|
+
const expiringSoon =
|
|
3113
|
+
now.getTime() >= expiryDate.getTime() - warningDays * msPerDay;
|
|
3114
|
+
const expiresInDays = Math.ceil(
|
|
3115
|
+
(expiryDate.getTime() - now.getTime()) / msPerDay,
|
|
3116
|
+
);
|
|
3117
|
+
|
|
3118
|
+
return { expired: false, expiringSoon, expiresInDays };
|
|
3119
|
+
} catch (error) {
|
|
3120
|
+
throw error;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3056
3124
|
async verifyPasscode(passcode: string) {
|
|
3057
3125
|
try {
|
|
3058
3126
|
// Return error if this._Userid is empty "User is not created yet."
|
|
@@ -76,16 +76,30 @@ export class UserPasswordHistory
|
|
|
76
76
|
): Promise<void> {
|
|
77
77
|
// This method used to check if password entered is valid by checking previous password history
|
|
78
78
|
try {
|
|
79
|
-
// Part 1-2: Retrieve password history policy
|
|
79
|
+
// Part 1-2: Retrieve password history policy: env var takes precedence over component config, call ComponentConfig. by passing:
|
|
80
80
|
// - ComponentName: "@tomei/sso"
|
|
81
81
|
// - ConfigKey: "passwordHistory"
|
|
82
82
|
// If no password history set, use default value 3
|
|
83
83
|
|
|
84
|
-
const
|
|
84
|
+
const envPasswordHistoryPolicy = Number(
|
|
85
|
+
process.env.PASSWORD_HISTORY_LIMIT,
|
|
86
|
+
);
|
|
87
|
+
const componentPasswordHistoryPolicy = Number(
|
|
85
88
|
ComponentConfig.getComponentConfigValue(
|
|
86
89
|
'@tomei/sso',
|
|
87
90
|
'passwordHistory',
|
|
88
|
-
)
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
const passwordHistoryPolicy =
|
|
94
|
+
(Number.isFinite(envPasswordHistoryPolicy) &&
|
|
95
|
+
envPasswordHistoryPolicy > 0
|
|
96
|
+
? Math.floor(envPasswordHistoryPolicy)
|
|
97
|
+
: 0) ||
|
|
98
|
+
(Number.isFinite(componentPasswordHistoryPolicy) &&
|
|
99
|
+
componentPasswordHistoryPolicy > 0
|
|
100
|
+
? Math.floor(componentPasswordHistoryPolicy)
|
|
101
|
+
: 0) ||
|
|
102
|
+
3;
|
|
89
103
|
|
|
90
104
|
// Part 3-4: Retrieve records from the table by using class._repo findAll() by passing:
|
|
91
105
|
// where: { UserId: params.UserId }
|
|
@@ -137,16 +151,30 @@ export class UserPasswordHistory
|
|
|
137
151
|
): Promise<void> {
|
|
138
152
|
// This method used to check if password entered is valid by checking previous password history
|
|
139
153
|
try {
|
|
140
|
-
// Part 1-2: Retrieve password history policy
|
|
154
|
+
// Part 1-2: Retrieve password history policy: env var takes precedence over component config, call ComponentConfig. by passing:
|
|
141
155
|
// - ComponentName: "@tomei/sso"
|
|
142
156
|
// - ConfigKey: "passwordHistory"
|
|
143
157
|
// If no password history set, use default value 3
|
|
144
158
|
|
|
145
|
-
const
|
|
159
|
+
const envPasswordHistoryPolicy = Number(
|
|
160
|
+
process.env.PASSWORD_HISTORY_LIMIT,
|
|
161
|
+
);
|
|
162
|
+
const componentPasswordHistoryPolicy = Number(
|
|
146
163
|
ComponentConfig.getComponentConfigValue(
|
|
147
164
|
'@tomei/sso',
|
|
148
165
|
'passwordHistory',
|
|
149
|
-
)
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
const passwordHistoryPolicy =
|
|
169
|
+
(Number.isFinite(envPasswordHistoryPolicy) &&
|
|
170
|
+
envPasswordHistoryPolicy > 0
|
|
171
|
+
? Math.floor(envPasswordHistoryPolicy)
|
|
172
|
+
: 0) ||
|
|
173
|
+
(Number.isFinite(componentPasswordHistoryPolicy) &&
|
|
174
|
+
componentPasswordHistoryPolicy > 0
|
|
175
|
+
? Math.floor(componentPasswordHistoryPolicy)
|
|
176
|
+
: 0) ||
|
|
177
|
+
3;
|
|
150
178
|
|
|
151
179
|
// Part 3: Insert new password history by calling class _repo create() method.
|
|
152
180
|
const userPasswordHistory = new UserPasswordHistory();
|
|
@@ -184,4 +212,27 @@ export class UserPasswordHistory
|
|
|
184
212
|
throw error;
|
|
185
213
|
}
|
|
186
214
|
}
|
|
215
|
+
|
|
216
|
+
// Latest history row's CreatedAt is the source of truth for password age (used by User.getPasswordExpiryStatus()).
|
|
217
|
+
public static async getLatestByUserId(
|
|
218
|
+
dbTransaction: any,
|
|
219
|
+
UserId: number,
|
|
220
|
+
): Promise<UserPasswordHistory | null> {
|
|
221
|
+
try {
|
|
222
|
+
const passwordHistory = await UserPasswordHistory._Repo.findAll({
|
|
223
|
+
where: { UserId: UserId },
|
|
224
|
+
order: [['CreatedAt', 'DESC']],
|
|
225
|
+
limit: 1,
|
|
226
|
+
transaction: dbTransaction,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
if (!passwordHistory || passwordHistory.length < 1) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return new UserPasswordHistory(passwordHistory[0].get({ plain: true }));
|
|
234
|
+
} catch (error) {
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
187
238
|
}
|
package/src/index.ts
CHANGED
package/tsconfig.build.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"include": ["**/*.ts"],
|
|
4
|
-
"exclude": ["node_modules", "__tests__", "dist", "**/*spec.ts"]
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"include": ["**/*.ts"],
|
|
4
|
+
"exclude": ["node_modules", "__tests__", "dist", "**/*spec.ts"]
|
|
5
|
+
}
|
|
6
6
|
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"target": "es6",
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"baseUrl": "./src",
|
|
14
|
-
"rootDir": "./",
|
|
15
|
-
"incremental": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"noImplicitAny": false,
|
|
18
|
-
"strictBindCallApply": false,
|
|
19
|
-
"forceConsistentCasingInFileNames": false,
|
|
20
|
-
"noFallthroughCasesInSwitch": false,
|
|
21
|
-
"strictNullChecks": false,
|
|
22
|
-
},
|
|
23
|
-
"exclude": ["node_modules", "dist"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"target": "es6",
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"baseUrl": "./src",
|
|
14
|
+
"rootDir": "./",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"noImplicitAny": false,
|
|
18
|
+
"strictBindCallApply": false,
|
|
19
|
+
"forceConsistentCasingInFileNames": false,
|
|
20
|
+
"noFallthroughCasesInSwitch": false,
|
|
21
|
+
"strictNullChecks": false,
|
|
22
|
+
},
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
24
|
}
|
|
@@ -1,71 +0,0 @@
|
|
|
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 group_privilege_1 = require("../../../../src/components/group-privilege/group-privilege");
|
|
13
|
-
const group_privilege_repository_1 = require("../../../../src/components/group-privilege/group-privilege.repository");
|
|
14
|
-
const general_1 = require("@tomei/general");
|
|
15
|
-
describe('GroupPrivilege', () => {
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
jest.restoreAllMocks();
|
|
18
|
-
});
|
|
19
|
-
it('should initialize with GroupPrivilegeAttr', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const mockGroupPrivilegeAttr = {
|
|
21
|
-
GroupPrivilegeId: 1,
|
|
22
|
-
GroupCode: 'group1',
|
|
23
|
-
PrivilegeCode: 'privilege1',
|
|
24
|
-
Status: 'active',
|
|
25
|
-
CreatedAt: new Date(),
|
|
26
|
-
UpdatedAt: new Date(),
|
|
27
|
-
CreatedById: 1,
|
|
28
|
-
UpdatedById: 1,
|
|
29
|
-
};
|
|
30
|
-
const findOneMock = jest
|
|
31
|
-
.spyOn(group_privilege_repository_1.GroupPrivilegeRepository.prototype, 'findOne')
|
|
32
|
-
.mockResolvedValueOnce({ get: jest.fn().mockReturnValue(mockGroupPrivilegeAttr) });
|
|
33
|
-
const groupPrivilege = yield group_privilege_1.GroupPrivilege.init(null, 1);
|
|
34
|
-
expect(findOneMock).toBeCalledWith({
|
|
35
|
-
where: { GroupPrivilegeId: 1 },
|
|
36
|
-
transaction: null,
|
|
37
|
-
});
|
|
38
|
-
expect(groupPrivilege).toBeInstanceOf(group_privilege_1.GroupPrivilege);
|
|
39
|
-
expect(groupPrivilege.GroupPrivilegeId).toEqual(mockGroupPrivilegeAttr.GroupPrivilegeId);
|
|
40
|
-
expect(groupPrivilege.GroupCode).toEqual(mockGroupPrivilegeAttr.GroupCode);
|
|
41
|
-
expect(groupPrivilege.PrivilegeCode).toEqual(mockGroupPrivilegeAttr.PrivilegeCode);
|
|
42
|
-
expect(groupPrivilege.Status).toEqual(mockGroupPrivilegeAttr.Status);
|
|
43
|
-
expect(groupPrivilege.CreatedAt).toEqual(mockGroupPrivilegeAttr.CreatedAt);
|
|
44
|
-
expect(groupPrivilege.UpdatedAt).toEqual(mockGroupPrivilegeAttr.UpdatedAt);
|
|
45
|
-
expect(groupPrivilege.CreatedById).toEqual(mockGroupPrivilegeAttr.CreatedById);
|
|
46
|
-
expect(groupPrivilege.UpdatedById).toEqual(mockGroupPrivilegeAttr.UpdatedById);
|
|
47
|
-
}));
|
|
48
|
-
it('should throw ClassError when GroupPrivilegeAttr is not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const findOneMock = jest
|
|
50
|
-
.spyOn(group_privilege_repository_1.GroupPrivilegeRepository.prototype, 'findOne')
|
|
51
|
-
.mockResolvedValueOnce(null);
|
|
52
|
-
yield expect(group_privilege_1.GroupPrivilege.init(null, 1)).rejects.toThrow(general_1.ClassError);
|
|
53
|
-
expect(findOneMock).toBeCalledWith({
|
|
54
|
-
where: { GroupPrivilegeId: 1 },
|
|
55
|
-
transaction: null,
|
|
56
|
-
});
|
|
57
|
-
}));
|
|
58
|
-
it('should initialize with default values', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
const groupPrivilege = yield group_privilege_1.GroupPrivilege.init();
|
|
60
|
-
expect(groupPrivilege).toBeInstanceOf(group_privilege_1.GroupPrivilege);
|
|
61
|
-
expect(groupPrivilege.GroupPrivilegeId).toBeUndefined();
|
|
62
|
-
expect(groupPrivilege.GroupCode).toBeUndefined();
|
|
63
|
-
expect(groupPrivilege.PrivilegeCode).toBeUndefined();
|
|
64
|
-
expect(groupPrivilege.Status).toBeUndefined();
|
|
65
|
-
expect(groupPrivilege.CreatedAt).toBeUndefined();
|
|
66
|
-
expect(groupPrivilege.UpdatedAt).toBeUndefined();
|
|
67
|
-
expect(groupPrivilege.CreatedById).toBeUndefined();
|
|
68
|
-
expect(groupPrivilege.UpdatedById).toBeUndefined();
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
//# sourceMappingURL=group-privilege.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-privilege.test.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/group-privilege/group-privil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AAc,CAAC,gBAAgB,CAAC,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,CAAC;QACrD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;QAC9C,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;QACnD,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;IACrD,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login-user.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/login-user/login-user.spec.ts"],"names":[],"mappings":"AAuuBA,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|