@tomei/sso 0.64.1 → 0.65.1-test.1
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 +130 -40
- 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/user.js +1 -1
- package/dist/src/components/login-user/user.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 -87
- package/sampledotenv +7 -7
- package/src/components/login-user/user.ts +1 -1
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +23 -23
- package/coverage/clover.xml +0 -1380
- package/coverage/coverage-final.json +0 -39
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.repository.ts.html +0 -160
- package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.ts.html +0 -919
- package/coverage/lcov-report/components/group-object-privilege/index.html +0 -131
- package/coverage/lcov-report/components/group-privilege/group-privilege.repository.ts.html +0 -172
- package/coverage/lcov-report/components/group-privilege/group-privilege.ts.html +0 -337
- package/coverage/lcov-report/components/group-privilege/index.html +0 -131
- package/coverage/lcov-report/components/group-system-access/group-system-access.repository.ts.html +0 -214
- package/coverage/lcov-report/components/group-system-access/group-system-access.ts.html +0 -355
- package/coverage/lcov-report/components/group-system-access/index.html +0 -131
- package/coverage/lcov-report/components/password-hash/index.html +0 -116
- package/coverage/lcov-report/components/password-hash/password-hash.service.ts.html +0 -127
- package/coverage/lcov-report/components/system-privilege/index.html +0 -116
- package/coverage/lcov-report/components/system-privilege/system-privilege.repository.ts.html +0 -139
- package/coverage/lcov-report/components/user-group/index.html +0 -131
- package/coverage/lcov-report/components/user-group/user-group.repository.ts.html +0 -142
- package/coverage/lcov-report/components/user-group/user-group.ts.html +0 -2377
- package/coverage/lcov-report/components/user-object-privilege/index.html +0 -131
- package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.repository.ts.html +0 -118
- package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.ts.html +0 -322
- package/coverage/lcov-report/components/user-privilege/index.html +0 -131
- package/coverage/lcov-report/components/user-privilege/user-privilege.repository.ts.html +0 -160
- package/coverage/lcov-report/components/user-privilege/user-privilege.ts.html +0 -2071
- package/coverage/lcov-report/components/user-system-access/index.html +0 -131
- package/coverage/lcov-report/components/user-system-access/user-system-access.repository.ts.html +0 -208
- package/coverage/lcov-report/components/user-system-access/user-system-access.ts.html +0 -2236
- package/coverage/lcov-report/enum/api-key.enum.ts.html +0 -100
- package/coverage/lcov-report/enum/group-type.enum.ts.html +0 -109
- package/coverage/lcov-report/enum/index.html +0 -206
- package/coverage/lcov-report/enum/index.ts.html +0 -103
- package/coverage/lcov-report/enum/login-status.enum.ts.html +0 -97
- package/coverage/lcov-report/enum/object-status.enum.ts.html +0 -97
- package/coverage/lcov-report/enum/user-status.enum.ts.html +0 -106
- package/coverage/lcov-report/enum/yn.enum.ts.html +0 -97
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -296
- package/coverage/lcov-report/models/group-object-privilege.entity.ts.html +0 -358
- package/coverage/lcov-report/models/group-privilege.entity.ts.html +0 -319
- package/coverage/lcov-report/models/group-reporting-user.entity.ts.html +0 -370
- package/coverage/lcov-report/models/group-system-access.entity.ts.html +0 -328
- package/coverage/lcov-report/models/group.entity.ts.html +0 -466
- package/coverage/lcov-report/models/index.html +0 -296
- package/coverage/lcov-report/models/staff.entity.ts.html +0 -358
- package/coverage/lcov-report/models/system-privilege.entity.ts.html +0 -355
- package/coverage/lcov-report/models/system.entity.ts.html +0 -424
- package/coverage/lcov-report/models/user-group.entity.ts.html +0 -358
- package/coverage/lcov-report/models/user-object-privilege.entity.ts.html +0 -355
- package/coverage/lcov-report/models/user-privilege.entity.ts.html +0 -319
- package/coverage/lcov-report/models/user-system-access.entity.ts.html +0 -346
- package/coverage/lcov-report/models/user.entity.ts.html +0 -685
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/redis-client/index.html +0 -116
- package/coverage/lcov-report/redis-client/redis.service.ts.html +0 -310
- package/coverage/lcov-report/session/index.html +0 -116
- package/coverage/lcov-report/session/session.service.ts.html +0 -373
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -2223
- 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
- package/sonar-project.properties +0 -23
package/coverage/test-report.xml
CHANGED
|
@@ -1,71 +1,161 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<testExecutions version="1">
|
|
3
|
-
<file path="C:\Work\sso\__tests__\unit\
|
|
4
|
-
<testCase name="
|
|
5
|
-
<testCase name="
|
|
3
|
+
<file path="C:\Work\sso\__tests__\unit\components\group-reporting-user\group-reporting-user.spec.ts">
|
|
4
|
+
<testCase name="GroupReportingUser init should initialize GroupReportingUser without GroupReportingUserId" duration="5"/>
|
|
5
|
+
<testCase name="GroupReportingUser init should initialize GroupReportingUser with valid GroupReportingUserId" duration="3"/>
|
|
6
|
+
<testCase name="GroupReportingUser init should throw ClassError when GroupReportingUser is not found" duration="12"/>
|
|
7
|
+
<testCase name="GroupReportingUser init should throw ClassError when failed to initialize GroupReportingUser" duration="4"/>
|
|
6
8
|
</file>
|
|
7
|
-
<file path="C:\Work\sso\__tests__\unit\components\user
|
|
8
|
-
<testCase name="
|
|
9
|
-
<testCase name="
|
|
10
|
-
<testCase name="
|
|
9
|
+
<file path="C:\Work\sso\__tests__\unit\components\login-user\login.spec.ts">
|
|
10
|
+
<testCase name="LoginUser init should initialize LoginUser with valid userId" duration="12"/>
|
|
11
|
+
<testCase name="LoginUser init should throw an error when user is not found" duration="12"/>
|
|
12
|
+
<testCase name="LoginUser shouldReleaseLock should return true if autoReleaseYN is "Y" and time difference is greater than minuteToAutoRelease" duration="2"/>
|
|
13
|
+
<testCase name="LoginUser shouldReleaseLock should return false if autoReleaseYN is "Y" and time difference is less than or equal to minuteToAutoRelease" duration="1"/>
|
|
14
|
+
<testCase name="LoginUser shouldReleaseLock should return false if autoReleaseYN is "N"" duration="1"/>
|
|
15
|
+
<testCase name="LoginUser releaseLock should release the lock for a user" duration="1"/>
|
|
16
|
+
<testCase name="LoginUser checkUserInfoDuplicated should throw an error if duplicate user info is found" duration="37"/>
|
|
17
|
+
<testCase name="LoginUser checkUserInfoDuplicated should not throw an error if duplicate user info is not found" duration="1"/>
|
|
18
|
+
<testCase name="LoginUser generateDefaultPassword should generate a default password with the specified length" duration="2"/>
|
|
19
|
+
<testCase name="LoginUser generateDefaultPassword should generate a default password with at least one capital letter" duration="1"/>
|
|
20
|
+
<testCase name="LoginUser generateDefaultPassword should generate a default password with at least one number" duration="1"/>
|
|
21
|
+
<testCase name="LoginUser generateDefaultPassword should generate a default password with at least one special character" duration="1"/>
|
|
22
|
+
<testCase name="LoginUser generateDefaultPassword should generate a default password without any non-acceptable characters" duration="6"/>
|
|
23
|
+
<testCase name="LoginUser setPassword should set the password for the user" duration="167"/>
|
|
24
|
+
<testCase name="LoginUser setPassword should throw an error if the password does not meet the security requirements" duration="10"/>
|
|
25
|
+
<testCase name="LoginUser incrementFailedLoginAttemptCount should increment FailedLoginAttemptCount and update user status" duration="2"/>
|
|
26
|
+
<testCase name="LoginUser incrementFailedLoginAttemptCount should throw an error if maxFailedLoginAttempts or autoReleaseYN is missing" duration="2"/>
|
|
27
|
+
<testCase name="LoginUser incrementFailedLoginAttemptCount should lock the user account if the failed login attempts exceed the maximum allowed" duration="1"/>
|
|
28
|
+
<testCase name="LoginUser incrementFailedLoginAttemptCount should permanently lock the user account if the failed login attempts exceed the maximum allowed and autoReleaseYN is N" duration="2"/>
|
|
29
|
+
<testCase name="LoginUser combineSystemAccess should combine user and group system access and remove duplicates" duration="2"/>
|
|
30
|
+
<testCase name="LoginUser checkPrivileges should return true if user has the specified privilege" duration="2"/>
|
|
31
|
+
<testCase name="LoginUser checkPrivileges should return false if user does not have the specified privilege" duration="1"/>
|
|
32
|
+
<testCase name="LoginUser checkPrivileges should throw an error if ObjectId is not set" duration="1"/>
|
|
33
|
+
<testCase name="LoginUser getObjectPrivileges should return an array of privileges" duration="2"/>
|
|
34
|
+
<testCase name="LoginUser getObjectPrivileges should throw an error if an exception occurs" duration="2"/>
|
|
35
|
+
<testCase name="LoginUser getUserPersonalPrivileges should return an array of privileges" duration="1"/>
|
|
36
|
+
<testCase name="LoginUser getUserPersonalPrivileges should throw an error if an error occurs" duration="2"/>
|
|
37
|
+
<testCase name="LoginUser getInheritedSystemAccess should return group system access with its parent group system access if applicable" duration="3"/>
|
|
11
38
|
</file>
|
|
12
|
-
<file path="C:\Work\sso\__tests__\unit\components\
|
|
13
|
-
<testCase name="
|
|
14
|
-
<testCase name="
|
|
15
|
-
<testCase name="
|
|
39
|
+
<file path="C:\Work\sso\__tests__\unit\components\system\system.spec.ts">
|
|
40
|
+
<testCase name="System init should initialize a system when SystemCode is provided" duration="7"/>
|
|
41
|
+
<testCase name="System init should throw an error when SystemCode is not found" duration="12"/>
|
|
42
|
+
<testCase name="System init should initialize a new system when SystemCode is not provided" duration="2"/>
|
|
43
|
+
<testCase name="System createSystem should create a new system" duration="4"/>
|
|
44
|
+
<testCase name="System createSystem should throw an error when user does not have permission" duration="2"/>
|
|
45
|
+
<testCase name="System createSystem should throw an error when SystemCode is missing" duration="2"/>
|
|
46
|
+
<testCase name="System createSystem should throw an error when Name is missing" duration="5"/>
|
|
47
|
+
<testCase name="System createSystem should throw an error when Description is missing" duration="2"/>
|
|
48
|
+
<testCase name="System createSystem should throw an error when failed to create system" duration="6"/>
|
|
49
|
+
<testCase name="System setSystemCode should set the SystemCode when there is no duplicate" duration="2"/>
|
|
50
|
+
<testCase name="System setSystemCode should throw an error when SystemCode already exists" duration="1"/>
|
|
51
|
+
<testCase name="System setSystemCode should throw an error when failed to check duplicate SystemCode" duration="1"/>
|
|
52
|
+
<testCase name="System findAll should find all systems based on filter" duration="2"/>
|
|
53
|
+
<testCase name="System findAll should find all systems without pagination when page and rows are not provided" duration="2"/>
|
|
54
|
+
</file>
|
|
55
|
+
<file path="C:\Work\sso\__tests__\unit\components\group-privilege\group-privilege.spec.ts">
|
|
56
|
+
<testCase name="GroupPrivilege should initialize with GroupPrivilegeAttr" duration="5"/>
|
|
57
|
+
<testCase name="GroupPrivilege should throw ClassError when GroupPrivilegeAttr is not found" duration="34"/>
|
|
58
|
+
<testCase name="GroupPrivilege should initialize with default values" duration="2"/>
|
|
59
|
+
</file>
|
|
60
|
+
<file path="C:\Work\sso\__tests__\unit\components\api-key\api-key.spec.ts">
|
|
61
|
+
<testCase name="APIKey init should return a new APIKey instance when no ApiKeyId is provided" duration="3"/>
|
|
62
|
+
<testCase name="APIKey init should initialize APIKey with valid ApiKeyId" duration="2"/>
|
|
63
|
+
<testCase name="APIKey init should throw ClassError when ApiKeyId is not found" duration="13"/>
|
|
64
|
+
<testCase name="APIKey generate should throw when user lacks API_KEY_CREATE privilege" duration="2"/>
|
|
65
|
+
<testCase name="APIKey generate should generate an API key successfully" duration="4"/>
|
|
66
|
+
<testCase name="APIKey findAll should throw when user lacks API_KEY_VIEW privilege" duration="1"/>
|
|
67
|
+
<testCase name="APIKey findAll should return paginated API keys" duration="2"/>
|
|
68
|
+
<testCase name="APIKey findAll should apply filters correctly" duration="1"/>
|
|
69
|
+
<testCase name="APIKey revoke should throw when API key is not found" duration="2"/>
|
|
70
|
+
<testCase name="APIKey revoke should revoke an API key successfully" duration="3"/>
|
|
71
|
+
</file>
|
|
72
|
+
<file path="C:\Work\sso\__tests__\unit\components\group\group.spec.ts">
|
|
73
|
+
<testCase name="Group should initialize a group with valid GroupCode" duration="6"/>
|
|
74
|
+
<testCase name="Group should throw an error when initializing a group with invalid GroupCode" duration="30"/>
|
|
75
|
+
<testCase name="Group should throw an error when initializing a group with an error" duration="1"/>
|
|
76
|
+
</file>
|
|
77
|
+
<file path="C:\Work\sso\__tests__\unit\components\system-privilege\system-privilege.spec.ts">
|
|
78
|
+
<testCase name="SystemPrivilege constructor should create a new SystemPrivilege instance" duration="3"/>
|
|
79
|
+
<testCase name="SystemPrivilege init should initialize SystemPrivilege without PrivilegeCode" duration="2"/>
|
|
80
|
+
<testCase name="SystemPrivilege init should initialize SystemPrivilege with PrivilegeCode" duration="7"/>
|
|
81
|
+
<testCase name="SystemPrivilege init should throw an error if PrivilegeCode is not found" duration="13"/>
|
|
82
|
+
</file>
|
|
83
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-group\user-group.spec.ts">
|
|
84
|
+
<testCase name="UserGroup constructor should create a new UserGroup instance" duration="3"/>
|
|
85
|
+
<testCase name="UserGroup init should initialize UserGroup with valid UserGroupId" duration="3"/>
|
|
86
|
+
<testCase name="UserGroup init should throw ClassError when UserGroupId is not found" duration="13"/>
|
|
16
87
|
</file>
|
|
17
88
|
<file path="C:\Work\sso\__tests__\unit\components\group-object-privilege\group-object-privilege.spec.ts">
|
|
18
89
|
<testCase name="GroupObjectPrivilege should create an instance of GroupObjectPrivilege" duration="2"/>
|
|
19
90
|
<testCase name="GroupObjectPrivilege should have the correct TableName" duration="1"/>
|
|
20
91
|
<testCase name="GroupObjectPrivilege should have the correct properties" duration="1"/>
|
|
21
92
|
<testCase name="GroupObjectPrivilege init should return an instance of GroupObjectPrivilege when GroupObjectPrivilegeId is provided" duration="2"/>
|
|
22
|
-
<testCase name="GroupObjectPrivilege init should throw an error when GroupObjectPrivilegeId is provided but no GroupObjectPrivilege is found" duration="
|
|
23
|
-
<testCase name="GroupObjectPrivilege init should return a new instance of GroupObjectPrivilege when GroupObjectPrivilegeId is not provided" duration="
|
|
93
|
+
<testCase name="GroupObjectPrivilege init should throw an error when GroupObjectPrivilegeId is provided but no GroupObjectPrivilege is found" duration="9"/>
|
|
94
|
+
<testCase name="GroupObjectPrivilege init should return a new instance of GroupObjectPrivilege when GroupObjectPrivilegeId is not provided" duration="4"/>
|
|
95
|
+
</file>
|
|
96
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-reporting-hierarchy\user-reporting-hierarchy.spec.ts">
|
|
97
|
+
<testCase name="UserReportingHierarchy init should return a new instance when no id is provided" duration="3"/>
|
|
98
|
+
<testCase name="UserReportingHierarchy init should initialize with valid id" duration="1"/>
|
|
99
|
+
<testCase name="UserReportingHierarchy init should throw ClassError when id is not found" duration="11"/>
|
|
100
|
+
<testCase name="UserReportingHierarchy createUserReportingHierarchy should throw when user lacks USER_REPORTING_HIERARCHY_CREATE privilege" duration="3"/>
|
|
101
|
+
<testCase name="UserReportingHierarchy createUserReportingHierarchy should throw when relationship already exists" duration="2"/>
|
|
102
|
+
<testCase name="UserReportingHierarchy createUserReportingHierarchy should throw when rank already exists" duration="1"/>
|
|
103
|
+
<testCase name="UserReportingHierarchy createUserReportingHierarchy should throw when previous rank is not yet assigned (rank > 1)" duration="1"/>
|
|
104
|
+
<testCase name="UserReportingHierarchy createUserReportingHierarchy should create hierarchy successfully" duration="2"/>
|
|
105
|
+
<testCase name="UserReportingHierarchy updateUserReportingHierarchy should throw when user lacks USER_REPORTING_HIERARCHY_UPDATE privilege" duration="2"/>
|
|
106
|
+
<testCase name="UserReportingHierarchy updateUserReportingHierarchy should update successfully" duration="2"/>
|
|
107
|
+
<testCase name="UserReportingHierarchy removeUserReportingHierarchy should throw when user lacks USER_REPORTING_HIERARCHY_REMOVE privilege" duration="1"/>
|
|
108
|
+
<testCase name="UserReportingHierarchy removeUserReportingHierarchy should remove hierarchy successfully" duration="2"/>
|
|
24
109
|
</file>
|
|
25
|
-
<file path="C:\Work\sso\__tests__\unit\components\user-
|
|
26
|
-
<testCase name="
|
|
27
|
-
<testCase name="
|
|
28
|
-
<testCase name="
|
|
110
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-privilege\user-privilege.spec.ts">
|
|
111
|
+
<testCase name="UserPrivilege constructor should create a new UserPrivilege instance" duration="3"/>
|
|
112
|
+
<testCase name="UserPrivilege init should initialize UserPrivilege with valid UserPrivilegeId" duration="4"/>
|
|
113
|
+
<testCase name="UserPrivilege init should throw ClassError when UserPrivilegeId is not found" duration="17"/>
|
|
114
|
+
</file>
|
|
115
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-password-history\user-password-history.spec.ts">
|
|
116
|
+
<testCase name="UserPasswordHistory init should return new instance when no historyId is provided" duration="7"/>
|
|
117
|
+
<testCase name="UserPasswordHistory init should initialize UserPasswordHistory with valid historyId" duration="1"/>
|
|
118
|
+
<testCase name="UserPasswordHistory init should throw ClassError when historyId is not found" duration="8"/>
|
|
119
|
+
<testCase name="UserPasswordHistory validate should return null when no password history exists" duration="2"/>
|
|
120
|
+
<testCase name="UserPasswordHistory validate should throw ClassError when password matches history" duration="1"/>
|
|
121
|
+
<testCase name="UserPasswordHistory validate should not throw when password does not match any history" duration="1"/>
|
|
122
|
+
<testCase name="UserPasswordHistory create should create a new password history record" duration="2"/>
|
|
123
|
+
<testCase name="UserPasswordHistory create should purge oldest records when history exceeds policy limit" duration="2"/>
|
|
124
|
+
<testCase name="UserPasswordHistory create should not purge when history is within policy limit" duration="2"/>
|
|
29
125
|
</file>
|
|
30
126
|
<file path="C:\Work\sso\__tests__\unit\components\group-system-access\group-system-access.spec.ts">
|
|
31
127
|
<testCase name="GroupSystemAccess should create a new GroupSystemAccess instance" duration="3"/>
|
|
32
128
|
<testCase name="GroupSystemAccess init should initialize GroupSystemAccess without GroupSystemAccessId" duration="2"/>
|
|
33
|
-
<testCase name="GroupSystemAccess init should initialize GroupSystemAccess with GroupSystemAccessId" duration="
|
|
34
|
-
<testCase name="GroupSystemAccess init should throw an error if GroupSystemAccessId is not found" duration="
|
|
129
|
+
<testCase name="GroupSystemAccess init should initialize GroupSystemAccess with GroupSystemAccessId" duration="3"/>
|
|
130
|
+
<testCase name="GroupSystemAccess init should throw an error if GroupSystemAccessId is not found" duration="34"/>
|
|
35
131
|
</file>
|
|
36
|
-
<file path="C:\Work\sso\__tests__\unit\components\user-
|
|
37
|
-
<testCase name="
|
|
38
|
-
<testCase name="
|
|
39
|
-
<testCase name="
|
|
132
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-system-access\user-system-access.spec.ts">
|
|
133
|
+
<testCase name="UserSystemAccess constructor should create a new UserSystemAccess instance" duration="4"/>
|
|
134
|
+
<testCase name="UserSystemAccess init should initialize UserSystemAccess with valid UserSystemAccessId" duration="4"/>
|
|
135
|
+
<testCase name="UserSystemAccess init should throw ClassError when UserSystemAccessId is not found" duration="6"/>
|
|
40
136
|
</file>
|
|
41
|
-
<file path="C:\Work\sso\__tests__\unit\components\
|
|
42
|
-
<testCase name="
|
|
43
|
-
<testCase name="
|
|
44
|
-
<testCase name="
|
|
137
|
+
<file path="C:\Work\sso\__tests__\unit\components\user-object-privilege\user-object-privilege.spec.ts">
|
|
138
|
+
<testCase name="UserObjectPrivilege constructor should create a new UserObjectPrivilege instance" duration="7"/>
|
|
139
|
+
<testCase name="UserObjectPrivilege init should initialize UserObjectPrivilege with valid ObjectPrivilegeId" duration="3"/>
|
|
140
|
+
<testCase name="UserObjectPrivilege init should throw ClassError when ObjectPrivilegeId is not found" duration="7"/>
|
|
45
141
|
</file>
|
|
46
142
|
<file path="C:\Work\sso\__tests__\unit\session\session.service.spec.ts">
|
|
47
|
-
<testCase name="session.service should return session service when instansiated" duration="
|
|
143
|
+
<testCase name="session.service should return session service when instansiated" duration="5"/>
|
|
48
144
|
<testCase name="session.service should able to write session data" duration="4"/>
|
|
49
|
-
<testCase name="session.service should able to refresh session data" duration="
|
|
145
|
+
<testCase name="session.service should able to refresh session data" duration="4"/>
|
|
50
146
|
</file>
|
|
51
147
|
<file path="C:\Work\sso\__tests__\unit\components\password-hash\password-hash.service.spec.ts">
|
|
52
|
-
<testCase name="password-hash.service should return hash password" duration="
|
|
148
|
+
<testCase name="password-hash.service should return hash password" duration="3"/>
|
|
53
149
|
<testCase name="password-hash.service should return true when verify password" duration="1"/>
|
|
54
150
|
</file>
|
|
151
|
+
<file path="C:\Work\sso\__tests__\unit\redis-client\redis.service.spec.ts">
|
|
152
|
+
<testCase name="redis.service should return redis service when instansiated" duration="3"/>
|
|
153
|
+
<testCase name="redis.service should able to write and read redis" duration="2"/>
|
|
154
|
+
</file>
|
|
55
155
|
<file path="C:\Work\sso\__tests__\unit\components\login-user\l.spec.ts">
|
|
56
156
|
<testCase name="SystemPrivilege should be true" duration="1"/>
|
|
57
157
|
</file>
|
|
58
158
|
<file path="C:\Work\sso\__tests__\unit\system-privilege\system-privilage.spec.ts">
|
|
59
159
|
<testCase name="SystemPrivilege should be true" duration="2"/>
|
|
60
160
|
</file>
|
|
61
|
-
<file path="C:\Work\sso\__tests__\unit\components\system-privilege\system-privilege.spec.ts">
|
|
62
|
-
</file>
|
|
63
|
-
<file path="C:\Work\sso\__tests__\unit\components\system\system.spec.ts">
|
|
64
|
-
</file>
|
|
65
|
-
<file path="C:\Work\sso\__tests__\unit\components\login-user\login.spec.ts">
|
|
66
|
-
</file>
|
|
67
|
-
<file path="C:\Work\sso\__tests__\unit\components\group-reporting-user\group-reporting-user.spec.ts">
|
|
68
|
-
</file>
|
|
69
|
-
<file path="C:\Work\sso\__tests__\unit\components\group\group.spec.ts">
|
|
70
|
-
</file>
|
|
71
161
|
</testExecutions>
|
package/create-sso-user.sql
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
-- example to create sso-user
|
|
3
|
-
CREATE USER 'sso_user'@'environment' IDENTIFIED BY 'password';
|
|
4
|
-
|
|
5
|
-
-- example to grant neccesary access to run migration
|
|
6
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_authorization_codes TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
7
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_bearer_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
8
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_building_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
9
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_buildings TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
10
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_cities TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
11
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_companies TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
12
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_countries TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
13
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_departments TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
14
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_grouproleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
15
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemaccess TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
16
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
17
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
18
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_oauth_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
19
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
20
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_sequelize_meta TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
21
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staff_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
22
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staffs TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
23
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_states TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
24
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_system_accesses TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
25
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
26
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
27
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemroleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
28
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systems TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
29
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_updated_history TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
30
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_user_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
31
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usergroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
32
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_users TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
33
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
34
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
35
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_UserUserGroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
36
|
-
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production._prisma_migrations TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-- Grant user to create, alter, drop, references on the database (required for creating shadow tables)
|
|
1
|
+
|
|
2
|
+
-- example to create sso-user
|
|
3
|
+
CREATE USER 'sso_user'@'environment' IDENTIFIED BY 'password';
|
|
4
|
+
|
|
5
|
+
-- example to grant neccesary access to run migration
|
|
6
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_authorization_codes TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
7
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_bearer_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
8
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_building_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
9
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_buildings TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
10
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_cities TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
11
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_companies TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
12
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_countries TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
13
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_departments TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
14
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_grouproleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
15
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemaccess TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
16
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
17
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
18
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_oauth_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
19
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
20
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_sequelize_meta TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
21
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staff_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
22
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staffs TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
23
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_states TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
24
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_system_accesses TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
25
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
26
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
27
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemroleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
28
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systems TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
29
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_updated_history TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
30
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_user_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
31
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usergroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
32
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_users TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
33
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
34
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
35
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_UserUserGroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
36
|
+
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production._prisma_migrations TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
-- Grant user to create, alter, drop, references on the database (required for creating shadow tables)
|
|
40
40
|
GRANT CREATE, ALTER, DROP, REFERENCES ON shadow_database.* TO 'sso_user'@'localhost' WITH GRANT OPTION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
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 api_key_1 = require("../../../../src/components/api-key/api-key");
|
|
13
|
+
const api_key_repository_1 = require("../../../../src/components/api-key/api-key.repository");
|
|
14
|
+
const login_user_1 = require("../../../../src/components/login-user/login-user");
|
|
15
|
+
const config_1 = require("@tomei/config");
|
|
16
|
+
const activity_history_1 = require("@tomei/activity-history");
|
|
17
|
+
const system_1 = require("../../../../src/components/system/system");
|
|
18
|
+
const api_key_enum_1 = require("../../../../src/enum/api-key.enum");
|
|
19
|
+
describe('APIKey', () => {
|
|
20
|
+
const loginUser = new login_user_1.LoginUser.prototype.constructor();
|
|
21
|
+
loginUser.ObjectId = '1';
|
|
22
|
+
loginUser.UserId = 1;
|
|
23
|
+
const apiKeyData = {
|
|
24
|
+
APIKeyId: 1,
|
|
25
|
+
ApiKey: 'abc123def456',
|
|
26
|
+
Name: 'Test Key',
|
|
27
|
+
SystemCode: 'TST',
|
|
28
|
+
Description: 'Test description',
|
|
29
|
+
Status: api_key_enum_1.APIKeyStatusEnum.ACTIVE,
|
|
30
|
+
ExpirationDate: new Date('2027-01-01'),
|
|
31
|
+
RevokedById: null,
|
|
32
|
+
RevokedAt: null,
|
|
33
|
+
CreatedAt: new Date('2024-01-01'),
|
|
34
|
+
CreatedById: 1,
|
|
35
|
+
get: function (opts) {
|
|
36
|
+
if (opts === null || opts === void 0 ? void 0 : opts.plain)
|
|
37
|
+
return this;
|
|
38
|
+
return this;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
jest.clearAllMocks();
|
|
43
|
+
});
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
jest
|
|
46
|
+
.spyOn(config_1.ApplicationConfig, 'getComponentConfigValue')
|
|
47
|
+
.mockReturnValue('TST');
|
|
48
|
+
jest
|
|
49
|
+
.spyOn(activity_history_1.Activity.prototype, 'create')
|
|
50
|
+
.mockResolvedValue(undefined);
|
|
51
|
+
jest
|
|
52
|
+
.spyOn(login_user_1.LoginUser.prototype, 'checkPrivileges')
|
|
53
|
+
.mockResolvedValue(true);
|
|
54
|
+
});
|
|
55
|
+
describe('init', () => {
|
|
56
|
+
it('should return a new APIKey instance when no ApiKeyId is provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const result = yield api_key_1.APIKey.init();
|
|
58
|
+
expect(result).toBeInstanceOf(api_key_1.APIKey);
|
|
59
|
+
expect(result.APIKeyId).toBeNaN();
|
|
60
|
+
}));
|
|
61
|
+
it('should initialize APIKey with valid ApiKeyId', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
jest
|
|
63
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findByPk')
|
|
64
|
+
.mockResolvedValueOnce(apiKeyData);
|
|
65
|
+
const result = yield api_key_1.APIKey.init(1);
|
|
66
|
+
expect(result).toBeInstanceOf(api_key_1.APIKey);
|
|
67
|
+
expect(result.Name).toBe('Test Key');
|
|
68
|
+
}));
|
|
69
|
+
it('should throw ClassError when ApiKeyId is not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
jest
|
|
71
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findByPk')
|
|
72
|
+
.mockResolvedValueOnce(null);
|
|
73
|
+
yield expect(api_key_1.APIKey.init(999)).rejects.toThrow('APIKey not found');
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
describe('generate', () => {
|
|
77
|
+
it('should throw when user lacks API_KEY_CREATE privilege', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
jest
|
|
79
|
+
.spyOn(login_user_1.LoginUser.prototype, 'checkPrivileges')
|
|
80
|
+
.mockResolvedValueOnce(false);
|
|
81
|
+
const apiKey = yield api_key_1.APIKey.init();
|
|
82
|
+
apiKey.SystemCode = 'TST';
|
|
83
|
+
yield expect(apiKey.generate(loginUser)).rejects.toThrow('User does not have privilege to generate API key.');
|
|
84
|
+
}));
|
|
85
|
+
it('should generate an API key successfully', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
jest
|
|
87
|
+
.spyOn(system_1.System, 'init')
|
|
88
|
+
.mockResolvedValueOnce(new system_1.System.prototype.constructor());
|
|
89
|
+
jest
|
|
90
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'create')
|
|
91
|
+
.mockResolvedValueOnce(Object.assign(Object.assign({}, apiKeyData), { APIKeyId: 1 }));
|
|
92
|
+
const apiKey = yield api_key_1.APIKey.init();
|
|
93
|
+
apiKey.SystemCode = 'TST';
|
|
94
|
+
apiKey.Name = 'Test Key';
|
|
95
|
+
apiKey.Status = api_key_enum_1.APIKeyStatusEnum.ACTIVE;
|
|
96
|
+
const result = yield apiKey.generate(loginUser);
|
|
97
|
+
expect(result).toHaveProperty('ApiKey');
|
|
98
|
+
expect(result.Name).toBe('Test Key');
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
describe('findAll', () => {
|
|
102
|
+
it('should throw when user lacks API_KEY_VIEW privilege', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
jest
|
|
104
|
+
.spyOn(login_user_1.LoginUser.prototype, 'checkPrivileges')
|
|
105
|
+
.mockResolvedValueOnce(false);
|
|
106
|
+
yield expect(api_key_1.APIKey.findAll({ page: 1, limit: 10 }, loginUser, null, {})).rejects.toThrow('User does not have privilege to generate API key.');
|
|
107
|
+
}));
|
|
108
|
+
it('should return paginated API keys', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
+
jest
|
|
110
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findAllWithPagination')
|
|
111
|
+
.mockResolvedValueOnce({
|
|
112
|
+
count: 1,
|
|
113
|
+
rows: [new api_key_1.APIKey.prototype.constructor(apiKeyData)],
|
|
114
|
+
});
|
|
115
|
+
const result = yield api_key_1.APIKey.findAll({ page: 1, limit: 10 }, loginUser, null, { SystemCode: 'TST' });
|
|
116
|
+
expect(result.total).toBe(1);
|
|
117
|
+
expect(result.ApiKeys).toHaveLength(1);
|
|
118
|
+
expect(result.page).toBe(1);
|
|
119
|
+
expect(result.limit).toBe(10);
|
|
120
|
+
}));
|
|
121
|
+
it('should apply filters correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
const spy = jest
|
|
123
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findAllWithPagination')
|
|
124
|
+
.mockResolvedValueOnce({ count: 0, rows: [] });
|
|
125
|
+
const fromDate = new Date('2024-01-01');
|
|
126
|
+
const toDate = new Date('2024-12-31');
|
|
127
|
+
yield api_key_1.APIKey.findAll({ page: 1, limit: 10 }, loginUser, null, {
|
|
128
|
+
Status: api_key_enum_1.APIKeyStatusEnum.ACTIVE,
|
|
129
|
+
ExpirationDate: { FromDate: fromDate, ToDate: toDate },
|
|
130
|
+
CreatedById: 1,
|
|
131
|
+
}, { SortBy: 'CreatedAt', SortOrder: 'ASC' });
|
|
132
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
describe('revoke', () => {
|
|
136
|
+
it('should throw when API key is not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
jest
|
|
138
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findOne')
|
|
139
|
+
.mockResolvedValueOnce(null);
|
|
140
|
+
const apiKey = yield api_key_1.APIKey.init();
|
|
141
|
+
yield expect(apiKey.revoke('nonexistent-key', loginUser, null)).rejects.toThrow('API key not found.');
|
|
142
|
+
}));
|
|
143
|
+
it('should revoke an API key successfully', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const apiKeyRecord = Object.assign(Object.assign({}, apiKeyData), { Status: api_key_enum_1.APIKeyStatusEnum.ACTIVE, RevokedAt: null, RevokedById: null, RevokedReason: null, get: (opts) => (Object.assign({}, apiKeyData)) });
|
|
145
|
+
jest
|
|
146
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'findOne')
|
|
147
|
+
.mockResolvedValueOnce(apiKeyRecord);
|
|
148
|
+
jest
|
|
149
|
+
.spyOn(api_key_repository_1.APIKeyRepository.prototype, 'update')
|
|
150
|
+
.mockResolvedValueOnce(undefined);
|
|
151
|
+
const apiKey = yield api_key_1.APIKey.init();
|
|
152
|
+
const result = yield apiKey.revoke('abc123def456', loginUser, null, 'No longer needed');
|
|
153
|
+
expect(result.Status).toBe(api_key_enum_1.APIKeyStatusEnum.REVOKED);
|
|
154
|
+
expect(result.RevokedReason).toBe('No longer needed');
|
|
155
|
+
}));
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=api-key.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/api-key/api-key.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wEAAoE;AACpE,8FAAyF;AACzF,iFAA6E;AAC7E,0CAAkD;AAClD,8DAAmD;AAEnD,qEAAkE;AA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C,IAAU,EAAE,EAAE,CAAC,mBAAM,UAAU,EAAG,GACzC,CAAC;YACF,IAAI;iBACD,KAAK,CAAC,qCAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;iBAC5C,qBAAqB,CAAC,YAAmB,CAAC,CAAC;YAC9C,IAAI;iBACD,KAAK,CAAC,qCAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC;iBAC3C,qBAAqB,CAAC,SAAgB,CAAC,CAAC;YAE3C,MAAM,MAAM,GAAG,MAAM,gBAAM,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;YAExF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,+BAAgB,CAAC,OAAO,CAAC,CAAC;YACrD,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACxD,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -14,6 +14,10 @@ const group_repository_1 = require("../../../../src/components/group/group.repos
|
|
|
14
14
|
const general_1 = require("@tomei/general");
|
|
15
15
|
const group_type_enum_1 = require("../../../../src/enum/group-type.enum");
|
|
16
16
|
describe('Group', () => {
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
process.env.REDIS_HOST = 'localhost';
|
|
19
|
+
process.env.REDIS_PORT = '6379';
|
|
20
|
+
});
|
|
17
21
|
afterEach(() => {
|
|
18
22
|
jest.clearAllMocks();
|
|
19
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/group/group.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kEAA+D;AAC/D,wFAAoF;AACpF,4CAA4C;AAC5C,0EAAqE;
|
|
1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6 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
jest.mock('../../../../src/components/login-user/login-user', () => ({
|
|
13
|
+
LoginUser: class MockLoginUser {
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
jest.mock('../../../../src/components/login-user/user', () => ({
|
|
17
|
+
User: class MockUser {
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
12
20
|
const group_reporting_user_1 = require("../../../../src/components/group-reporting-user/group-reporting-user");
|
|
13
21
|
const group_reporting_user_repository_1 = require("../../../../src/components/group-reporting-user/group-reporting-user.repository");
|
|
14
22
|
const general_1 = require("@tomei/general");
|
|
@@ -51,7 +59,7 @@ describe('GroupReportingUser', () => {
|
|
|
51
59
|
}));
|
|
52
60
|
it('should throw ClassError when failed to initialize GroupReportingUser', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
61
|
jest.spyOn(group_reporting_user_repository_1.GroupReportingUserRepository.prototype, 'findByPk').mockRejectedValue(new Error());
|
|
54
|
-
yield expect(group_reporting_user_1.GroupReportingUser.init(mockDbTransaction, '1')).rejects.toThrow(
|
|
62
|
+
yield expect(group_reporting_user_1.GroupReportingUser.init(mockDbTransaction, '1')).rejects.toThrow(Error);
|
|
55
63
|
}));
|
|
56
64
|
});
|
|
57
65
|
});
|
package/dist/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-reporting-user.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/group-reporting-user/group-reporting-user.spec.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"group-reporting-user.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/group-reporting-user/group-reporting-user.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,IAAI,CA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