passbolt-browser-extension 5.17.0 → 5.18.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/.pre-commit-config.yaml +6 -2
- package/CHANGELOG.md +106 -1
- package/README.md +2 -2
- package/RELEASE_NOTES.md +3 -94
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +5 -5
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +10 -10
- package/eslint.config.mjs +3 -35
- package/jest.config.json +1 -2
- package/package.json +45 -54
- package/src/all/_locales/locales.test.js +2 -0
- package/src/all/background_page/controller/InformMenuController/InformMenuController.test.js +45 -1
- package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.js +1 -2
- package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.test.js +10 -8
- package/src/all/background_page/controller/accountRecovery/accountRecoveryValidatePublicKeyController.test.js +1 -1
- package/src/all/background_page/controller/auth/authLocalLogoutController.js +3 -14
- package/src/all/background_page/controller/auth/authLocalLogoutController.test.js +3 -3
- package/src/all/background_page/controller/auth/authLoginController.js +2 -2
- package/src/all/background_page/controller/auth/authOfflineLogoutController.js +4 -12
- package/src/all/background_page/controller/auth/authOfflineLogoutController.test.js +3 -3
- package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.js → findAndUpdateActiveSessionSessionStorageController.js} +6 -6
- package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.test.js → findAndUpdateActiveSessionSessionStorageController.test.js} +30 -30
- package/src/all/background_page/controller/auth/getOrFindActiveSessionController.test.js +22 -20
- package/src/all/background_page/controller/auth/isMfaRequiredController.js +5 -4
- package/src/all/background_page/controller/auth/isMfaRequiredController.test.js +3 -3
- package/src/all/background_page/controller/crypto/getUserKeyInfoController.test.js +1 -1
- package/src/all/background_page/controller/crypto/getUserPrivateKeyController.test.js +1 -1
- package/src/all/background_page/controller/extension/onExtensionInstalledController.js +61 -30
- package/src/all/background_page/controller/extension/onExtensionInstalledController.test.js +131 -19
- package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +46 -0
- package/src/all/background_page/controller/resource/setResourcesExpiryDateController.test.js +1 -1
- package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.js +54 -0
- package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.test.js +91 -0
- package/src/all/background_page/controller/share/shareResourcesController.test.js +2 -2
- package/src/all/background_page/controller/sso/getQualifiedSsoLoginErrorController.test.js +1 -1
- package/src/all/background_page/controller/sso/hasSsoLoginErrorController.test.js +1 -1
- package/src/all/background_page/controller/subscription/createSubscriptionKeyController.js +3 -3
- package/src/all/background_page/controller/subscription/createSubscriptionKeyController.test.js +4 -4
- package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.js +3 -3
- package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.test.js +4 -4
- package/src/all/background_page/controller/theme/findThemesController.js +52 -0
- package/src/all/background_page/controller/theme/findThemesController.test.js +68 -0
- package/src/all/background_page/controller/theme/updateThemeController.js +55 -0
- package/src/all/background_page/controller/theme/updateThemeController.test.js +76 -0
- package/src/all/background_page/controller/user/getOrFindLoggedInUserController.test.js +2 -2
- package/src/all/background_page/event/appEvents.js +1 -26
- package/src/all/background_page/event/authEvents.js +2 -2
- package/src/all/background_page/event/configEvents.js +0 -12
- package/src/all/background_page/event/informMenuEvents.js +2 -2
- package/src/all/background_page/event/quickAccessEvents.js +12 -0
- package/src/all/background_page/event/themeEvents.js +9 -21
- package/src/all/background_page/model/auth/authModel.js +3 -3
- package/src/all/background_page/model/auth/authModel.test.js +2 -2
- package/src/all/background_page/model/entity/export/exportResourcesFileEntity.js +2 -0
- package/src/all/background_page/model/entity/export/exportResourcesFileEntity.test.js +1 -0
- package/src/all/background_page/model/entity/import/importResourcesFileEntity.test.data.js +5 -0
- package/src/all/background_page/model/entity/sso/ssoLoginUrlEntity.js +1 -1
- package/src/all/background_page/model/entity/theme/themeEntity.test.data.js +12 -0
- package/src/all/background_page/model/entity/theme/themesCollection.test.data.js +10 -1
- package/src/all/background_page/model/export/resources/csvRowComposer/abstractRowComposer.js +8 -0
- package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.js +67 -0
- package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.test.js +37 -0
- package/src/all/background_page/model/export/resources/resourcesCsvExporter.js +5 -2
- package/src/all/background_page/model/export/resources/resourcesCsvExporter.test.js +3 -1
- package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.js +98 -0
- package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.test.js +145 -0
- package/src/all/background_page/model/import/resources/resourcesCsvImportParser.js +2 -0
- package/src/all/background_page/model/import/resources/resourcesCsvImportParser.test.js +19 -1
- package/src/all/background_page/model/keyring.test.js +1 -1
- package/src/all/background_page/model/multiFactorAuthentication/multiFactorAuthenticationModel.test.js +1 -1
- package/src/all/background_page/model/user/userModel.test.js +1 -1
- package/src/all/background_page/model/user.js +2 -2
- package/src/all/background_page/model/userSettings/userSettings.js +1 -1
- package/src/all/background_page/pagemod/appBootstrapPagemod.js +6 -5
- package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +7 -12
- package/src/all/background_page/pagemod/authBootstrapPagemod.js +2 -2
- package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +6 -7
- package/src/all/background_page/pagemod/pagemodManager.test.js +14 -20
- package/src/all/background_page/pagemod/webIntegrationPagemod.js +2 -2
- package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +9 -9
- package/src/all/background_page/service/accountRecovery/decryptPrivateKeyPasswordDataService.js +1 -1
- package/src/all/background_page/service/accountRecovery/decryptResponseDataService.js +1 -1
- package/src/all/background_page/service/accountRecovery/parseAccountRecoveryUrlService.js +1 -1
- package/src/all/background_page/service/accountRecovery/validateOrganizationPublicKeyService.test.js +1 -1
- package/src/all/background_page/service/activeSession/{findAndUpdateActiveSessionLocalStorageService.js → findAndUpdateActiveSessionSessionStorageService.js} +27 -60
- package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionSessionStorageService.test.js +720 -0
- package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.js +8 -8
- package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.test.js +16 -16
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.js +0 -29
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.data.js +0 -6
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.js +1 -32
- package/src/all/background_page/service/api/actionLog/actionLogApiService.test.js +1 -1
- package/src/all/background_page/service/api/comment/commentApiService.test.js +1 -1
- package/src/all/background_page/service/api/metadata/metadataKeysApiService.test.js +1 -1
- package/src/all/background_page/service/api/sessionKey/sessionKeysBundlesApiService.test.js +1 -1
- package/src/all/background_page/service/api/theme/themesApiService.js +57 -0
- package/src/all/background_page/service/api/theme/themesApiService.test.js +83 -0
- package/src/all/background_page/service/app/parseAppUrlService.js +18 -10
- package/src/all/background_page/service/app/parseAppUrlService.test.js +21 -21
- package/src/all/background_page/service/auth/localLogoutService.js +42 -0
- package/src/all/background_page/service/auth/localLogoutService.test.js +43 -0
- package/src/all/background_page/service/auth/offlineLogoutService.js +47 -0
- package/src/all/background_page/service/auth/offlineLogoutService.test.js +46 -0
- package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.js +2 -2
- package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.test.js +3 -3
- package/src/all/background_page/service/auth/parseAuthUrlService.js +11 -6
- package/src/all/background_page/service/auth/parseAuthUrlService.test.js +11 -13
- package/src/all/background_page/service/auth/postLoginOfflineService.js +3 -3
- package/src/all/background_page/service/auth/postLoginOfflineService.test.js +3 -3
- package/src/all/background_page/service/auth/postLoginService.js +3 -3
- package/src/all/background_page/service/auth/postLoginService.test.js +3 -3
- package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.js +8 -4
- package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.test.js +36 -13
- package/src/all/background_page/service/authenticationStatusService.test.js +1 -1
- package/src/all/background_page/service/clipboard/clipboardProviderService.js +0 -7
- package/src/all/background_page/service/clipboard/clipboardProviderService.test.js +0 -10
- package/src/all/background_page/service/clipboard/copyToClipboardService.js +1 -5
- package/src/all/background_page/service/crypto/decryptSsoPassphraseService.js +1 -1
- package/src/all/background_page/service/extension/onStartUpService.js +2 -2
- package/src/all/background_page/service/extension/onStartUpService.test.js +3 -3
- package/src/all/background_page/service/localStorage/localStorageService.js +4 -2
- package/src/all/background_page/service/localStorage/localStorageService.test.js +28 -12
- package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.js +40 -0
- package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.test.js +63 -0
- package/src/all/background_page/service/metadata/rotateMetadata/rotateMetadataKeyService.test.js +2 -2
- package/src/all/background_page/service/metadata/rotateMetadata/rotateResourcesMetadataKeyService.test.js +2 -2
- package/src/all/background_page/service/migrateMetadata/migrateMetadataResourcesService.test.js +2 -2
- package/src/all/background_page/service/offline/canUseOfflineStorageService.js +16 -1
- package/src/all/background_page/service/offline/canUseOfflineStorageService.test.js +14 -6
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +4 -1
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +10 -1
- package/src/all/background_page/service/offline/offlineRetentionDataFlushService.js +12 -9
- package/src/all/background_page/service/offline/offlineRetentionDataFlushService.test.js +35 -24
- package/src/all/background_page/service/rbac/getOrFindRbacService.js +4 -1
- package/src/all/background_page/service/recover/parseRecoverUrlService.js +1 -1
- package/src/all/background_page/service/resource/export/exportResourcesService.test.js +3 -0
- package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.js +30 -10
- package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.test.js +108 -9
- package/src/all/background_page/service/resource/getOrFindResourcesService.js +30 -10
- package/src/all/background_page/service/resource/getOrFindResourcesService.test.js +99 -9
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +4 -1
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +10 -2
- package/src/all/background_page/service/secret/decryptAndParseResourceSecretService.js +1 -1
- package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.js +48 -0
- package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.test.js +66 -0
- package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.js +102 -0
- package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.test.js +221 -0
- package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.js → session_storage/activeSessionSessionStorage.js} +17 -17
- package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.test.js → session_storage/activeSessionSessionStorage.test.js} +31 -34
- package/src/all/background_page/service/setup/parseSetupUrlService.js +3 -2
- package/src/all/background_page/service/setup/parseSetupUrlService.test.js +195 -24
- package/src/all/background_page/service/share/shareFoldersService.test.js +4 -4
- package/src/all/background_page/service/share/shareResourceService.test.js +4 -4
- package/src/all/background_page/service/theme/findThemesService.js +38 -0
- package/src/all/background_page/service/theme/findThemesService.test.js +63 -0
- package/src/all/background_page/service/theme/updateThemeService.js +39 -0
- package/src/all/background_page/service/theme/updateThemeService.test.js +65 -0
- package/src/all/background_page/service/toolbar/toolbarService.js +20 -10
- package/src/all/background_page/service/toolbar/toolbarService.test.js +82 -6
- package/src/all/background_page/service/user/getOrFindMeService.js +4 -1
- package/src/all/background_page/service/user/getOrFindMeService.test.js +10 -2
- package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.js +11 -6
- package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.test.js +7 -9
- package/src/all/background_page/utils/format/formDataUtils.test.js +1 -1
- package/src/all/background_page/utils/openpgp/openpgpAssertions.js +1 -1
- package/src/all/webAccessibleResources/js/themes/stylesheet.js +1 -1
- package/src/chrome-mv3/manifest.json +1 -1
- package/src/chrome-mv3/serviceWorker/service/network/requestFetchOffscreenService.js +1 -1
- package/src/chrome-mv3/serviceWorker/service/network/responseFetchOffscreenService.js +7 -4
- package/src/firefox/manifest.json +1 -1
- package/src/safari/manifest.json +1 -1
- package/test/matchers/toBeOpenpgpKeySignedBy.js +13 -14
- package/test/mocks/mockJsDomPolyfill.js +0 -2
- package/webpack/common-blocks.js +13 -13
- package/webpack/expectedBuildArtifacts.js +1 -1
- package/webpack/passboltEnvPlugin.js +1 -1
- package/webpack.common.config.js +2 -0
- package/webpack.config.js +4 -5
- package/webpack.safari-background-page.config.js +38 -31
- package/src/all/background_page/model/theme/themeModel.js +0 -66
- package/src/all/background_page/model/theme/themeModel.test.js +0 -73
- package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionLocalStorageService.test.js +0 -776
- package/src/chrome/manifest.json +0 -51
- package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.js +0 -31
- package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.test.js +0 -53
- package/webpack.chromium-mv2.config.js +0 -40
|
@@ -19,7 +19,7 @@ import GetOrFindMetadataKeysSettingsController from "../controller/metadata/getO
|
|
|
19
19
|
import GetOrFindMetadataTypesController from "../controller/metadata/getMetadataTypesSettingsController";
|
|
20
20
|
import IsApplicationOverlaidController from "../controller/applicationOverlaid/IsApplicationOverlaidController";
|
|
21
21
|
import GetResourceTypesController from "../controller/resourceType/getResourceTypesController";
|
|
22
|
-
import
|
|
22
|
+
import FindAndUpdateActiveSessionSessionStorageController from "../controller/auth/findAndUpdateActiveSessionSessionStorageController";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Listens the inform menu events
|
|
@@ -147,7 +147,7 @@ const listen = function (worker, apiClientOptions, account) {
|
|
|
147
147
|
* @param requestId {uuid} The request identifier
|
|
148
148
|
*/
|
|
149
149
|
worker.port.on("passbolt.auth.find-and-update-authentication-status", async (requestId) => {
|
|
150
|
-
const controller = new
|
|
150
|
+
const controller = new FindAndUpdateActiveSessionSessionStorageController(
|
|
151
151
|
worker,
|
|
152
152
|
requestId,
|
|
153
153
|
apiClientOptions,
|
|
@@ -22,6 +22,7 @@ import AuthLocalLogoutController from "../controller/auth/authLocalLogoutControl
|
|
|
22
22
|
import AuthLoginOfflineController from "../controller/auth/authLoginOfflineController";
|
|
23
23
|
import FindAndUpdateResourcesLocalStorageFromOPFSController from "../controller/resourceLocalStorage/findAndUpdateResourcesLocalStorageFromOPFSController";
|
|
24
24
|
import FindSecretByResourceIdFromOPFSController from "../controller/secret/findSecretByResourceIdFromOPFSController";
|
|
25
|
+
import GetSessionTimestampsController from "../controller/sessionTimestamps/getSessionTimestampsController";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Listens to the quickaccess application events
|
|
@@ -212,6 +213,17 @@ const listen = function (worker, apiClientOptions, account) {
|
|
|
212
213
|
await controller._exec();
|
|
213
214
|
});
|
|
214
215
|
|
|
216
|
+
/*
|
|
217
|
+
* Get the session timestamps (last_logged_in, last_seen_online).
|
|
218
|
+
*
|
|
219
|
+
* @listens passbolt.session-timestamps.get
|
|
220
|
+
* @param requestId {uuid} The request identifier
|
|
221
|
+
*/
|
|
222
|
+
worker.port.on("passbolt.session-timestamps.get", async (requestId) => {
|
|
223
|
+
const controller = new GetSessionTimestampsController(worker, requestId, account);
|
|
224
|
+
await controller._exec();
|
|
225
|
+
});
|
|
226
|
+
|
|
215
227
|
/**
|
|
216
228
|
* Local Logout when user was signed-in
|
|
217
229
|
* but the server is now unavailable
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
11
|
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import FindThemesController from "../controller/theme/findThemesController";
|
|
14
|
+
import UpdateThemeController from "../controller/theme/updateThemeController";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Listens the theme events
|
|
@@ -19,39 +19,27 @@ import ChangeThemeEntity from "../model/entity/theme/change/ChangeThemeEntity";
|
|
|
19
19
|
* @param {ApiClientOptions} apiClientOptions the api client options
|
|
20
20
|
*/
|
|
21
21
|
const listen = function (worker, apiClientOptions) {
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
23
|
* Find all themes
|
|
24
24
|
*
|
|
25
25
|
* @listens passbolt.themes.find-all
|
|
26
26
|
* @param requestId {uuid} The request identifier
|
|
27
27
|
*/
|
|
28
28
|
worker.port.on("passbolt.themes.find-all", async (requestId) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const themes = await themeModel.findAll();
|
|
32
|
-
worker.port.emit(requestId, "SUCCESS", themes);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(error);
|
|
35
|
-
worker.port.emit(requestId, "ERROR", error);
|
|
36
|
-
}
|
|
29
|
+
const controller = new FindThemesController(worker, requestId, apiClientOptions);
|
|
30
|
+
await controller._exec();
|
|
37
31
|
});
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
/**
|
|
40
34
|
* Change the current user theme
|
|
41
35
|
*
|
|
42
36
|
* @listens passbolt.themes.change
|
|
43
37
|
* @param requestId {uuid} The request identifier
|
|
38
|
+
* @param name {string} The theme name
|
|
44
39
|
*/
|
|
45
40
|
worker.port.on("passbolt.themes.change", async (requestId, name) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const changeThemeEntity = new ChangeThemeEntity({ name: name });
|
|
49
|
-
await themeModel.change(changeThemeEntity);
|
|
50
|
-
worker.port.emit(requestId, "SUCCESS");
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(error);
|
|
53
|
-
worker.port.emit(requestId, "ERROR", error);
|
|
54
|
-
}
|
|
41
|
+
const controller = new UpdateThemeController(worker, requestId, apiClientOptions);
|
|
42
|
+
await controller._exec(name);
|
|
55
43
|
});
|
|
56
44
|
};
|
|
57
45
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import AuthLogoutService from "passbolt-styleguide/src/shared/services/api/auth/AuthLogoutService";
|
|
14
14
|
import PostLogoutService from "../../service/auth/postLogoutService";
|
|
15
|
-
import
|
|
15
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../../service/activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
16
16
|
|
|
17
17
|
class AuthModel {
|
|
18
18
|
/**
|
|
@@ -24,7 +24,7 @@ class AuthModel {
|
|
|
24
24
|
*/
|
|
25
25
|
constructor(apiClientOptions, account) {
|
|
26
26
|
this.authLogoutService = new AuthLogoutService(apiClientOptions);
|
|
27
|
-
this.
|
|
27
|
+
this.findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
|
|
28
28
|
account,
|
|
29
29
|
apiClientOptions,
|
|
30
30
|
);
|
|
@@ -37,7 +37,7 @@ class AuthModel {
|
|
|
37
37
|
async logout() {
|
|
38
38
|
await this.authLogoutService.logout();
|
|
39
39
|
// Mark the active session as signed out, before the post-logout cleanup flushes the storages.
|
|
40
|
-
await this.
|
|
40
|
+
await this.findAndUpdateActiveSessionSessionStorageService.resetAuthentication();
|
|
41
41
|
await PostLogoutService.exec();
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -15,7 +15,7 @@ import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiC
|
|
|
15
15
|
import AuthModel from "../../model/auth/authModel";
|
|
16
16
|
import AuthLogoutService from "passbolt-styleguide/src/shared/services/api/auth/AuthLogoutService";
|
|
17
17
|
import PostLogoutService from "../../service/auth/postLogoutService";
|
|
18
|
-
import
|
|
18
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../../service/activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
19
19
|
import AccountEntity from "../entity/account/accountEntity";
|
|
20
20
|
import { defaultAccountDto } from "../entity/account/accountEntity.test.data";
|
|
21
21
|
|
|
@@ -33,7 +33,7 @@ describe("AuthModel", () => {
|
|
|
33
33
|
|
|
34
34
|
const logoutServiceSpy = jest.spyOn(AuthLogoutService.prototype, "logout").mockImplementation(() => {});
|
|
35
35
|
const resetAuthenticationSpy = jest
|
|
36
|
-
.spyOn(
|
|
36
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "resetAuthentication")
|
|
37
37
|
.mockResolvedValue();
|
|
38
38
|
const postLogoutSpy = jest.spyOn(PostLogoutService, "exec");
|
|
39
39
|
|
|
@@ -27,6 +27,7 @@ export const FORMAT_CSV_SAFARI = "csv-safari";
|
|
|
27
27
|
export const FORMAT_CSV_DASHLANE = "csv-dashlane";
|
|
28
28
|
export const FORMAT_CSV_NORDPASS = "csv-nordpass";
|
|
29
29
|
export const FORMAT_CSV_LOGMEONCE = "csv-logmeonce";
|
|
30
|
+
export const FORMAT_CSV_NETWRIX = "csv-netwrix";
|
|
30
31
|
|
|
31
32
|
const SUPPORTED_FORMAT = [
|
|
32
33
|
FORMAT_KDBX,
|
|
@@ -41,6 +42,7 @@ const SUPPORTED_FORMAT = [
|
|
|
41
42
|
FORMAT_CSV_DASHLANE,
|
|
42
43
|
FORMAT_CSV_NORDPASS,
|
|
43
44
|
FORMAT_CSV_LOGMEONCE,
|
|
45
|
+
FORMAT_CSV_NETWRIX,
|
|
44
46
|
];
|
|
45
47
|
|
|
46
48
|
class ExportResourcesFileEntity extends EntityV2 {
|
|
@@ -47,6 +47,7 @@ describe("ExportResourcesFileEntity", () => {
|
|
|
47
47
|
"csv-dashlane",
|
|
48
48
|
"csv-nordpass",
|
|
49
49
|
"csv-logmeonce",
|
|
50
|
+
"csv-netwrix",
|
|
50
51
|
];
|
|
51
52
|
const unexpectedValues = ["1", "false", "test"];
|
|
52
53
|
assertEntityProperty.enumeration(ExportResourcesFileEntity, "format", expectedValues, unexpectedValues);
|
|
@@ -114,6 +114,11 @@ export const logMeOnceCsvFile = [
|
|
|
114
114
|
'"Password 1","https://url1.com","Description 1","Folder 1","Username 1","Password 1",""',
|
|
115
115
|
].join("\r\n");
|
|
116
116
|
|
|
117
|
+
export const netwrixCsvFile = [
|
|
118
|
+
'"DataTags";"Description";"User name";"Password";"Internet address";"Email address"',
|
|
119
|
+
'"";"Password 1";"Username 1";"Password 1";"https://url1.com";""',
|
|
120
|
+
].join("\r\n");
|
|
121
|
+
|
|
117
122
|
export const KdbxCsvFile = [
|
|
118
123
|
'"Title","Username","URL","Password","Notes","Group","TOTP"',
|
|
119
124
|
'"Password 1","Username 1","https://url1.com","Password 1","Description 1","Folder 1","otpauth://totp/Password%201%3AUsername%201?secret=THISISASECRET&issuer=https%253A%252F%252Furl1.com&algorithm=SHA1&digits=6&period=30"',
|
|
@@ -77,7 +77,7 @@ class SsoLoginUrlEntity extends Entity {
|
|
|
77
77
|
url = new URL(value);
|
|
78
78
|
} catch (error) {
|
|
79
79
|
console.error(error);
|
|
80
|
-
throw new Error("The url should be a valid url.");
|
|
80
|
+
throw new Error("The url should be a valid url.", { cause: error });
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (ssoProvider === OAuth2SsoSettingsEntity.PROVIDER_ID || ssoProvider === AdfsSsoSettingsEntity.PROVIDER_ID) {
|
|
@@ -36,3 +36,15 @@ export const solarisedDarkThemeDto = (data = {}) => ({
|
|
|
36
36
|
name: "solarised_dark",
|
|
37
37
|
...data,
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
export const sakuraThemeDto = (data = {}) => ({
|
|
41
|
+
id: uuidv4(),
|
|
42
|
+
name: "sakura",
|
|
43
|
+
...data,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const layetteThemeDto = (data = {}) => ({
|
|
47
|
+
id: uuidv4(),
|
|
48
|
+
name: "layette",
|
|
49
|
+
...data,
|
|
50
|
+
});
|
|
@@ -12,11 +12,20 @@
|
|
|
12
12
|
* @since 5.7.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
defaultThemeDto,
|
|
17
|
+
midgarThemeDto,
|
|
18
|
+
solarisedDarkThemeDto,
|
|
19
|
+
solarisedThemeDto,
|
|
20
|
+
sakuraThemeDto,
|
|
21
|
+
layetteThemeDto,
|
|
22
|
+
} from "./themeEntity.test.data";
|
|
16
23
|
|
|
17
24
|
export const defaultThemeCollectionDtos = () => [
|
|
18
25
|
defaultThemeDto(),
|
|
19
26
|
midgarThemeDto(),
|
|
20
27
|
solarisedThemeDto(),
|
|
21
28
|
solarisedDarkThemeDto(),
|
|
29
|
+
sakuraThemeDto(),
|
|
30
|
+
layetteThemeDto(),
|
|
22
31
|
];
|
package/src/all/background_page/model/export/resources/csvRowComposer/abstractRowComposer.js
CHANGED
|
@@ -20,6 +20,14 @@ class AbstractRowComposer {
|
|
|
20
20
|
throw new Error("format should be overridden by the inherited class.");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Get the csv delimiter
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
static get delimiter() {
|
|
28
|
+
return ",";
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* Get the row composer properties mapping.
|
|
25
33
|
* Key values object where key represents the passbolt entity property name and the value represents the CSV property name.
|
package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
import CsvNetwrixRowParser from "../../../import/resources/csvRowParser/csvNetwrixRowParser";
|
|
15
|
+
import AbstractRowComposer from "./abstractRowComposer";
|
|
16
|
+
|
|
17
|
+
const FORMAT = "csv-netwrix";
|
|
18
|
+
|
|
19
|
+
class CsvNetwrixRowComposer extends AbstractRowComposer {
|
|
20
|
+
/**
|
|
21
|
+
* Get the composer supported format name
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
static get format() {
|
|
25
|
+
return FORMAT;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the csv delimiter. Netwrix uses semicolons.
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
static get delimiter() {
|
|
33
|
+
return ";";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the row composer properties mapping.
|
|
38
|
+
* Key values object where key represents the passbolt entity property name and the value represents the CSV property name.
|
|
39
|
+
* @returns {object}
|
|
40
|
+
*/
|
|
41
|
+
static get mapping() {
|
|
42
|
+
return CsvNetwrixRowParser.mapping;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Compose a csv row
|
|
47
|
+
* Tags and email are not exported and are left empty.
|
|
48
|
+
* @param {ExternalResourceEntity} externalResourceEntity The resource to use to compose the row
|
|
49
|
+
* @returns {object}
|
|
50
|
+
*/
|
|
51
|
+
static compose(externalResourceEntity) {
|
|
52
|
+
const row = {};
|
|
53
|
+
const externalResourceDto = externalResourceEntity.toDto();
|
|
54
|
+
for (const propertyName in this.mapping) {
|
|
55
|
+
if (propertyName === "uris") {
|
|
56
|
+
row[this.mapping[propertyName]] = externalResourceDto.uris?.length > 0 ? externalResourceDto.uris[0] : "";
|
|
57
|
+
} else if (propertyName === "tags" || propertyName === "email") {
|
|
58
|
+
row[this.mapping[propertyName]] = "";
|
|
59
|
+
} else {
|
|
60
|
+
row[this.mapping[propertyName]] = externalResourceDto[propertyName] || "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return row;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default CsvNetwrixRowComposer;
|
package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.test.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
import ExternalResourceEntity from "../../../entity/resource/external/externalResourceEntity";
|
|
15
|
+
import CsvNetwrixRowComposer from "./csvNetwrixRowComposer";
|
|
16
|
+
describe("CsvNetwrixRowComposer", () => {
|
|
17
|
+
it("can compose netwrix csv row", () => {
|
|
18
|
+
const dto = {
|
|
19
|
+
name: "Password 1",
|
|
20
|
+
username: "Username 1",
|
|
21
|
+
uris: ["https://url1.com"],
|
|
22
|
+
secret_clear: "Secret 1",
|
|
23
|
+
description: "Description 1",
|
|
24
|
+
folder_parent_path: "Folder 1",
|
|
25
|
+
};
|
|
26
|
+
const externalResourceEntity = new ExternalResourceEntity(dto);
|
|
27
|
+
const csvRow = CsvNetwrixRowComposer.compose(externalResourceEntity);
|
|
28
|
+
expect(csvRow).toEqual({
|
|
29
|
+
DataTags: "",
|
|
30
|
+
Description: externalResourceEntity.name,
|
|
31
|
+
"User name": externalResourceEntity.username,
|
|
32
|
+
Password: externalResourceEntity.secretClear,
|
|
33
|
+
"Internet address": externalResourceEntity.uris[0],
|
|
34
|
+
"Email address": "",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -22,6 +22,7 @@ import CsvSafariRowComposer from "./csvRowComposer/csvSafariRowComposer";
|
|
|
22
22
|
import CsvDashlaneRowComposer from "./csvRowComposer/csvDashlaneRowComposer";
|
|
23
23
|
import CsvNordpassRowComposer from "./csvRowComposer/csvNordpassRowComposer";
|
|
24
24
|
import CsvLogMeOnceRowComposer from "./csvRowComposer/csvLogMeOnceRowComposer";
|
|
25
|
+
import CsvNetwrixRowComposer from "./csvRowComposer/csvNetwrixRowComposer";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Register of csv row parsers
|
|
@@ -38,6 +39,7 @@ const register = [
|
|
|
38
39
|
CsvDashlaneRowComposer,
|
|
39
40
|
CsvNordpassRowComposer,
|
|
40
41
|
CsvLogMeOnceRowComposer,
|
|
42
|
+
CsvNetwrixRowComposer,
|
|
41
43
|
];
|
|
42
44
|
|
|
43
45
|
class ResourcesCsvExporter {
|
|
@@ -69,9 +71,10 @@ class ResourcesCsvExporter {
|
|
|
69
71
|
const data = this.exportResources(RowComposer);
|
|
70
72
|
// Insert the header manually, Papaparse doesn't insert it if there is not content to write.
|
|
71
73
|
const headerColumns = Object.values(RowComposer.mapping);
|
|
72
|
-
|
|
74
|
+
const delimiter = RowComposer.delimiter;
|
|
75
|
+
let file = `"${headerColumns.join(`"${delimiter}"`)}"\r\n`;
|
|
73
76
|
// Unparse the content and add it to the result.
|
|
74
|
-
file = file + PapaParse.unparse(data, { header: false, quotes: true, columns: headerColumns });
|
|
77
|
+
file = file + PapaParse.unparse(data, { header: false, quotes: true, columns: headerColumns, delimiter });
|
|
75
78
|
this.exportEntity.file = file;
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -22,10 +22,11 @@ import CsvSafariRowComposer from "./csvRowComposer/csvSafariRowComposer";
|
|
|
22
22
|
import CsvDashlaneRowComposer from "./csvRowComposer/csvDashlaneRowComposer";
|
|
23
23
|
import CsvNordpassRowComposer from "./csvRowComposer/csvNordpassRowComposer";
|
|
24
24
|
import CsvLogMeOnceRowComposer from "./csvRowComposer/csvLogMeOnceRowComposer";
|
|
25
|
+
import CsvNetwrixRowComposer from "./csvRowComposer/csvNetwrixRowComposer";
|
|
25
26
|
|
|
26
27
|
describe("ResourcesCsvExporter", () => {
|
|
27
28
|
it("should be aware of the supported row parsers", () => {
|
|
28
|
-
expect(ResourcesCsvExporter.register).toHaveLength(
|
|
29
|
+
expect(ResourcesCsvExporter.register).toHaveLength(11);
|
|
29
30
|
const supportedRowComposers = [
|
|
30
31
|
Csv1PasswordRowComposer,
|
|
31
32
|
CsvKdbxRowComposer,
|
|
@@ -37,6 +38,7 @@ describe("ResourcesCsvExporter", () => {
|
|
|
37
38
|
CsvDashlaneRowComposer,
|
|
38
39
|
CsvNordpassRowComposer,
|
|
39
40
|
CsvLogMeOnceRowComposer,
|
|
41
|
+
CsvNetwrixRowComposer,
|
|
40
42
|
];
|
|
41
43
|
expect(ResourcesCsvExporter.register).toEqual(expect.arrayContaining(supportedRowComposers));
|
|
42
44
|
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
import ExternalResourceEntity from "../../../entity/resource/external/externalResourceEntity";
|
|
15
|
+
import ResourcesTypeImportParser from "../resourcesTypeImportParser";
|
|
16
|
+
import AbstractCsvRowParser from "./abstractCsvRowParser";
|
|
17
|
+
import ImportError from "../../../../error/importError";
|
|
18
|
+
|
|
19
|
+
class CsvNetwrixRowParser extends AbstractCsvRowParser {
|
|
20
|
+
/**
|
|
21
|
+
* Get the row parser properties mapping.
|
|
22
|
+
* Netwrix names the entry title "Description".
|
|
23
|
+
* The order of the properties matters, it defines the order of the columns when exporting.
|
|
24
|
+
* @returns {object}
|
|
25
|
+
*/
|
|
26
|
+
static get mapping() {
|
|
27
|
+
return {
|
|
28
|
+
tags: "DataTags",
|
|
29
|
+
name: "Description",
|
|
30
|
+
username: "User name",
|
|
31
|
+
secret_clear: "Password",
|
|
32
|
+
uris: "Internet address",
|
|
33
|
+
email: "Email address",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parse a csv row
|
|
39
|
+
* @param {object} data the csv row data
|
|
40
|
+
* @param {ImportResourcesFileEntity} importEntity The import entity
|
|
41
|
+
* @param {ResourceTypesCollection} resourceTypesCollection (Optional) The available resource types
|
|
42
|
+
* @param {MetadataTypesSettingsEntity} metadataTypesSettings The metadata types from the organization
|
|
43
|
+
* @returns {ExternalResourceEntity}
|
|
44
|
+
*/
|
|
45
|
+
static parse(data, importEntity, resourceTypesCollection, metadataTypesSettings) {
|
|
46
|
+
const externalResourceDto = {};
|
|
47
|
+
|
|
48
|
+
for (const propertyName of ["name", "username", "secret_clear"]) {
|
|
49
|
+
if (data[this.mapping[propertyName]]) {
|
|
50
|
+
externalResourceDto[propertyName] = data[this.mapping[propertyName]];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (data[this.mapping.uris]) {
|
|
54
|
+
externalResourceDto.uris = [data[this.mapping.uris]];
|
|
55
|
+
}
|
|
56
|
+
// Tags are not supported by the import, the email is used as username only if the latter is not defined.
|
|
57
|
+
if (!externalResourceDto.username && data[this.mapping.email]) {
|
|
58
|
+
externalResourceDto.username = data[this.mapping.email];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
resourceTypesCollection.filterByResourceTypeVersion(metadataTypesSettings.defaultResourceTypes);
|
|
62
|
+
ResourcesTypeImportParser.parsePinCode(externalResourceDto, resourceTypesCollection);
|
|
63
|
+
const scores = ResourcesTypeImportParser.getScores(externalResourceDto, resourceTypesCollection);
|
|
64
|
+
let resourceType = ResourcesTypeImportParser.findMatchingResourceType(resourceTypesCollection, scores);
|
|
65
|
+
|
|
66
|
+
if (!resourceType) {
|
|
67
|
+
resourceType = ResourcesTypeImportParser.findPartialResourceType(resourceTypesCollection, scores);
|
|
68
|
+
if (resourceType) {
|
|
69
|
+
importEntity.importResourcesWarnings.push(
|
|
70
|
+
new ImportError(
|
|
71
|
+
"Resource partially imported",
|
|
72
|
+
externalResourceDto,
|
|
73
|
+
new Error("We used the closest resource type supported."),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (!resourceType) {
|
|
78
|
+
resourceType = ResourcesTypeImportParser.fallbackDefaulResourceType(
|
|
79
|
+
resourceTypesCollection,
|
|
80
|
+
metadataTypesSettings,
|
|
81
|
+
);
|
|
82
|
+
importEntity.importResourcesWarnings.push(
|
|
83
|
+
new ImportError(
|
|
84
|
+
"Imported with default content type",
|
|
85
|
+
externalResourceDto,
|
|
86
|
+
new Error("No resource type associated to this row."),
|
|
87
|
+
),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
externalResourceDto.resource_type_id = resourceType.id;
|
|
93
|
+
|
|
94
|
+
return new ExternalResourceEntity(externalResourceDto);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default CsvNetwrixRowParser;
|
package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.test.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
import CsvNetwrixRowParser from "./csvNetwrixRowParser";
|
|
15
|
+
import ExternalResourceEntity from "../../../entity/resource/external/externalResourceEntity";
|
|
16
|
+
import ResourceTypesCollection from "passbolt-styleguide/src/shared/models/entity/resourceType/resourceTypesCollection";
|
|
17
|
+
import { resourceTypesCollectionDto } from "passbolt-styleguide/src/shared/models/entity/resourceType/resourceTypesCollection.test.data";
|
|
18
|
+
import {
|
|
19
|
+
defaultMetadataTypesSettingsV4Dto,
|
|
20
|
+
defaultMetadataTypesSettingsV50FreshDto,
|
|
21
|
+
} from "passbolt-styleguide/src/shared/models/entity/metadata/metadataTypesSettingsEntity.test.data";
|
|
22
|
+
import MetadataTypesSettingsEntity from "passbolt-styleguide/src/shared/models/entity/metadata/metadataTypesSettingsEntity";
|
|
23
|
+
import {
|
|
24
|
+
RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION_SLUG,
|
|
25
|
+
RESOURCE_TYPE_V5_DEFAULT_SLUG,
|
|
26
|
+
} from "passbolt-styleguide/src/shared/models/entity/resourceType/resourceTypeSchemasDefinition";
|
|
27
|
+
import ImportResourcesFileEntity from "../../../entity/import/importResourcesFileEntity";
|
|
28
|
+
import BinaryConvert from "../../../../utils/format/binaryConvert";
|
|
29
|
+
|
|
30
|
+
describe("CsvNetwrixRowParser", () => {
|
|
31
|
+
const buildImportEntity = (data) =>
|
|
32
|
+
new ImportResourcesFileEntity({ ref: "import-ref", file_type: "csv", file: btoa(BinaryConvert.toBinary(data)) });
|
|
33
|
+
|
|
34
|
+
it("can parse netwrix csv", () => {
|
|
35
|
+
expect.assertions(4);
|
|
36
|
+
|
|
37
|
+
// minimum required fields
|
|
38
|
+
let fields = ["Description", "Password"];
|
|
39
|
+
expect(CsvNetwrixRowParser.canParse(fields)).toEqual(2);
|
|
40
|
+
// all fields
|
|
41
|
+
fields = ["DataTags", "Description", "User name", "Password", "Internet address", "Email address"];
|
|
42
|
+
expect(CsvNetwrixRowParser.canParse(fields)).toEqual(4);
|
|
43
|
+
// Missing one required field
|
|
44
|
+
fields = ["DataTags", "User name", "Password", "Internet address", "Email address"];
|
|
45
|
+
expect(CsvNetwrixRowParser.canParse(fields)).toEqual(0);
|
|
46
|
+
// additional fields not supported
|
|
47
|
+
fields = ["Description", "Password", "Unsupported field"];
|
|
48
|
+
expect(CsvNetwrixRowParser.canParse(fields)).toEqual(2);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("parses resource of type password-and-description with all properties from csv row", () => {
|
|
52
|
+
expect.assertions(2);
|
|
53
|
+
|
|
54
|
+
const data = {
|
|
55
|
+
DataTags: "Tag1|Tag2|Tag3",
|
|
56
|
+
Description: "Google",
|
|
57
|
+
"User name": "Hans.Mustermann",
|
|
58
|
+
Password: "Secret 1",
|
|
59
|
+
"Internet address": "https://www.google.de",
|
|
60
|
+
"Email address": "hans@mustermann.de",
|
|
61
|
+
};
|
|
62
|
+
const importEntity = buildImportEntity(data);
|
|
63
|
+
const resourceTypesCollection = new ResourceTypesCollection(resourceTypesCollectionDto());
|
|
64
|
+
const metadataTypesSettings = new MetadataTypesSettingsEntity(defaultMetadataTypesSettingsV4Dto());
|
|
65
|
+
const expectedResourceType = resourceTypesCollection.items.find(
|
|
66
|
+
(resourceType) => resourceType.slug === RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION_SLUG,
|
|
67
|
+
);
|
|
68
|
+
const expectedEntity = new ExternalResourceEntity({
|
|
69
|
+
name: "Google",
|
|
70
|
+
username: "Hans.Mustermann",
|
|
71
|
+
uris: ["https://www.google.de"],
|
|
72
|
+
resource_type_id: expectedResourceType.id,
|
|
73
|
+
secret_clear: "Secret 1",
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const externalResourceEntity = CsvNetwrixRowParser.parse(
|
|
77
|
+
data,
|
|
78
|
+
importEntity,
|
|
79
|
+
resourceTypesCollection,
|
|
80
|
+
metadataTypesSettings,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect(externalResourceEntity).toBeInstanceOf(ExternalResourceEntity);
|
|
84
|
+
expect(externalResourceEntity.toDto()).toEqual(expectedEntity.toDto());
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("parses resource of type default-v5 with all properties from csv row", () => {
|
|
88
|
+
expect.assertions(2);
|
|
89
|
+
|
|
90
|
+
const data = {
|
|
91
|
+
DataTags: "",
|
|
92
|
+
Description: "Google",
|
|
93
|
+
"User name": "Hans.Mustermann",
|
|
94
|
+
Password: "Secret 1",
|
|
95
|
+
"Internet address": "https://www.google.de",
|
|
96
|
+
"Email address": "hans@mustermann.de",
|
|
97
|
+
};
|
|
98
|
+
const importEntity = buildImportEntity(data);
|
|
99
|
+
const resourceTypesCollection = new ResourceTypesCollection(resourceTypesCollectionDto());
|
|
100
|
+
const metadataTypesSettings = new MetadataTypesSettingsEntity(defaultMetadataTypesSettingsV50FreshDto());
|
|
101
|
+
const expectedResourceType = resourceTypesCollection.items.find(
|
|
102
|
+
(resourceType) => resourceType.slug === RESOURCE_TYPE_V5_DEFAULT_SLUG,
|
|
103
|
+
);
|
|
104
|
+
const expectedEntity = new ExternalResourceEntity({
|
|
105
|
+
name: "Google",
|
|
106
|
+
username: "Hans.Mustermann",
|
|
107
|
+
uris: ["https://www.google.de"],
|
|
108
|
+
resource_type_id: expectedResourceType.id,
|
|
109
|
+
secret_clear: "Secret 1",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const externalResourceEntity = CsvNetwrixRowParser.parse(
|
|
113
|
+
data,
|
|
114
|
+
importEntity,
|
|
115
|
+
resourceTypesCollection,
|
|
116
|
+
metadataTypesSettings,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(externalResourceEntity).toBeInstanceOf(ExternalResourceEntity);
|
|
120
|
+
expect(externalResourceEntity.toDto()).toEqual(expectedEntity.toDto());
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("uses the email address as username if the user name is empty", () => {
|
|
124
|
+
expect.assertions(1);
|
|
125
|
+
|
|
126
|
+
const data = {
|
|
127
|
+
Description: "Google",
|
|
128
|
+
"User name": "",
|
|
129
|
+
Password: "Secret 1",
|
|
130
|
+
"Email address": "hans@mustermann.de",
|
|
131
|
+
};
|
|
132
|
+
const importEntity = buildImportEntity(data);
|
|
133
|
+
const resourceTypesCollection = new ResourceTypesCollection(resourceTypesCollectionDto());
|
|
134
|
+
const metadataTypesSettings = new MetadataTypesSettingsEntity(defaultMetadataTypesSettingsV50FreshDto());
|
|
135
|
+
|
|
136
|
+
const externalResourceEntity = CsvNetwrixRowParser.parse(
|
|
137
|
+
data,
|
|
138
|
+
importEntity,
|
|
139
|
+
resourceTypesCollection,
|
|
140
|
+
metadataTypesSettings,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
expect(externalResourceEntity.username).toEqual("hans@mustermann.de");
|
|
144
|
+
});
|
|
145
|
+
});
|