mirror of
https://github.com/bitwarden/browser
synced 2024-12-22 07:57:01 +01:00
[PM-328] Move common/importer
to libs/importer
(tools-migration) (#5060)
* Create and register new libs/importer Create package.json Create tsconfig Create jest.config Extend shared and root tsconfig and jest.configs Register with eslint * Move importer-related files to libs/importer * Move importer-spec-related files to libs/importer Move import.service.spec * Update package-lock.json * Set CODEOWNERS for new libs/importer * Register libs/importer with cli and fix imports * Register libs/importer with web and fix imports * Move importOption into models Rename importOptions to import-options * Fix linting issues after updating prettier * Only expose necessary files from libs/importer Fix tsconfig files - Removes the trailing /index on imports in web/cli As the spec-files no longer can access the internals via @bitwarden/importer they import by path (../src/importers) * Add barrel files to vendors with more than one importer
This commit is contained in:
parent
7cfabf053c
commit
a5a12a6723
@ -98,6 +98,10 @@
|
||||
{
|
||||
"target": "./libs/common/**/*",
|
||||
"from": "./libs/node/**/*"
|
||||
},
|
||||
{
|
||||
"target": "./libs/common/**/*",
|
||||
"from": "./libs/importer/**/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -150,6 +154,12 @@
|
||||
"rules": {
|
||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["libs/importer/src/**/*.ts"],
|
||||
"rules": {
|
||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/importer/*", "src/**/*"] }]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -26,6 +26,7 @@ apps/desktop/src/app/tools @bitwarden/team-tools-dev
|
||||
apps/web/src/app/tools @bitwarden/team-tools-dev
|
||||
libs/angular/src/tools @bitwarden/team-tools-dev
|
||||
libs/common/src/tools @bitwarden/team-tools-dev
|
||||
libs/importer @bitwarden/team-tools-dev
|
||||
|
||||
## Vault team files ##
|
||||
apps/browser/src/autofill @bitwarden/team-vault-dev
|
||||
|
1
.github/whitelist-capital-letters.txt
vendored
1
.github/whitelist-capital-letters.txt
vendored
@ -47,7 +47,6 @@
|
||||
./libs/common/src/enums/encryptedExportType.ts
|
||||
./libs/common/src/enums/linkedIdType.ts
|
||||
./libs/common/src/enums/sendType.ts
|
||||
./libs/common/src/enums/importOptions.ts
|
||||
./libs/common/src/enums/encryptionType.ts
|
||||
./libs/common/src/enums/htmlStorageLocation.ts
|
||||
./libs/common/src/enums/notificationType.ts
|
||||
|
@ -4,7 +4,6 @@ import * as path from "path";
|
||||
import * as program from "commander";
|
||||
import * as jsdom from "jsdom";
|
||||
|
||||
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
|
||||
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||
import { CollectionService } from "@bitwarden/common/admin-console/services/collection.service";
|
||||
@ -33,8 +32,6 @@ import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptog
|
||||
import { EnvironmentService } from "@bitwarden/common/services/environment.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
|
||||
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import/import.service";
|
||||
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
||||
import { NoopMessagingService } from "@bitwarden/common/services/noopMessaging.service";
|
||||
import { OrganizationUserServiceImplementation } from "@bitwarden/common/services/organization-user/organization-user.service.implementation";
|
||||
@ -56,6 +53,12 @@ import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder
|
||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
||||
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
|
||||
import { SyncService } from "@bitwarden/common/vault/services/sync/sync.service";
|
||||
import {
|
||||
ImportApiService,
|
||||
ImportApiServiceAbstraction,
|
||||
ImportService,
|
||||
ImportServiceAbstraction,
|
||||
} from "@bitwarden/importer";
|
||||
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
|
||||
|
||||
import { Program } from "./program";
|
||||
@ -98,7 +101,7 @@ export class Main {
|
||||
totpService: TotpService;
|
||||
containerService: ContainerService;
|
||||
auditService: AuditService;
|
||||
importService: ImportService;
|
||||
importService: ImportServiceAbstraction;
|
||||
importApiService: ImportApiServiceAbstraction;
|
||||
exportService: ExportService;
|
||||
searchService: SearchService;
|
||||
|
@ -1,10 +1,8 @@
|
||||
import * as program from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
|
||||
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { ImportType } from "@bitwarden/common/enums/importOptions";
|
||||
import { Importer } from "@bitwarden/common/importers/importer";
|
||||
import { ImportServiceAbstraction, Importer, ImportType } from "@bitwarden/importer";
|
||||
|
||||
import { Response } from "../models/response";
|
||||
import { MessageResponse } from "../models/response/message.response";
|
||||
@ -12,7 +10,7 @@ import { CliUtils } from "../utils";
|
||||
|
||||
export class ImportCommand {
|
||||
constructor(
|
||||
private importService: ImportService,
|
||||
private importService: ImportServiceAbstraction,
|
||||
private organizationService: OrganizationService
|
||||
) {}
|
||||
|
@ -6,11 +6,11 @@ import { Main } from "./bw";
|
||||
import { EditCommand } from "./commands/edit.command";
|
||||
import { ExportCommand } from "./commands/export.command";
|
||||
import { GetCommand } from "./commands/get.command";
|
||||
import { ImportCommand } from "./commands/import.command";
|
||||
import { ListCommand } from "./commands/list.command";
|
||||
import { RestoreCommand } from "./commands/restore.command";
|
||||
import { Response } from "./models/response";
|
||||
import { Program } from "./program";
|
||||
import { ImportCommand } from "./tools/import.command";
|
||||
import { CliUtils } from "./utils";
|
||||
import { CreateCommand } from "./vault/create.command";
|
||||
import { DeleteCommand } from "./vault/delete.command";
|
||||
|
@ -14,6 +14,7 @@
|
||||
"paths": {
|
||||
"@bitwarden/common/spec/*": ["../../libs/common/spec/*"],
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||
"@bitwarden/node/*": ["../../libs/node/src/*"]
|
||||
}
|
||||
},
|
||||
|
@ -3,13 +3,15 @@ import { NgModule } from "@angular/core";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import/import.service.abstraction";
|
||||
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
|
||||
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import/import.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
import {
|
||||
ImportService,
|
||||
ImportServiceAbstraction,
|
||||
ImportApiService,
|
||||
ImportApiServiceAbstraction,
|
||||
} from "@bitwarden/importer";
|
||||
|
||||
import { LooseComponentsModule, SharedModule } from "../../../../shared";
|
||||
|
||||
|
@ -3,12 +3,12 @@ import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ImportServiceAbstraction } from "@bitwarden/importer";
|
||||
|
||||
import { ImportComponent } from "../../../../tools/import-export/import.component";
|
||||
|
||||
@ -22,7 +22,7 @@ export class OrganizationImportComponent extends ImportComponent {
|
||||
|
||||
constructor(
|
||||
i18nService: I18nService,
|
||||
importService: ImportService,
|
||||
importService: ImportServiceAbstraction,
|
||||
router: Router,
|
||||
private route: ActivatedRoute,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
|
@ -3,13 +3,15 @@ import { NgModule } from "@angular/core";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import/import.service.abstraction";
|
||||
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
|
||||
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import/import.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
import {
|
||||
ImportService,
|
||||
ImportServiceAbstraction,
|
||||
ImportApiService,
|
||||
ImportApiServiceAbstraction,
|
||||
} from "@bitwarden/importer";
|
||||
|
||||
import { LooseComponentsModule, SharedModule } from "../../shared";
|
||||
|
||||
|
@ -6,14 +6,17 @@ import Swal, { SweetAlertIcon } from "sweetalert2";
|
||||
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums/policy-type";
|
||||
import { ImportOption, ImportType } from "@bitwarden/common/enums/importOptions";
|
||||
import { ImportError } from "@bitwarden/common/importers/import-error";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import {
|
||||
ImportOption,
|
||||
ImportType,
|
||||
ImportError,
|
||||
ImportServiceAbstraction,
|
||||
} from "@bitwarden/importer";
|
||||
|
||||
import { FilePasswordPromptComponent } from "./file-password-prompt.component";
|
||||
|
||||
@ -36,7 +39,7 @@ export class ImportComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
protected i18nService: I18nService,
|
||||
protected importService: ImportService,
|
||||
protected importService: ImportServiceAbstraction,
|
||||
protected router: Router,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected policyService: PolicyService,
|
||||
|
@ -8,7 +8,8 @@
|
||||
"@bitwarden/web-vault/*": ["src/*"],
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||
"@bitwarden/components": ["../../libs/components/src"]
|
||||
"@bitwarden/components": ["../../libs/components/src"],
|
||||
"@bitwarden/importer": ["../../libs/importer/src"]
|
||||
}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
|
@ -21,6 +21,7 @@ module.exports = {
|
||||
"<rootDir>/libs/angular/jest.config.js",
|
||||
"<rootDir>/libs/common/jest.config.js",
|
||||
"<rootDir>/libs/components/jest.config.js",
|
||||
"<rootDir>/libs/importer/jest.config.js",
|
||||
"<rootDir>/libs/node/jest.config.js",
|
||||
],
|
||||
|
||||
|
14
libs/importer/jest.config.js
Normal file
14
libs/importer/jest.config.js
Normal file
@ -0,0 +1,14 @@
|
||||
const { pathsToModuleNameMapper } = require("ts-jest");
|
||||
|
||||
const { compilerOptions } = require("../shared/tsconfig.libs");
|
||||
|
||||
const sharedConfig = require("../shared/jest.config.base");
|
||||
|
||||
module.exports = {
|
||||
...sharedConfig,
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "jsdom",
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
|
||||
prefix: "<rootDir>/",
|
||||
}),
|
||||
};
|
23
libs/importer/package.json
Normal file
23
libs/importer/package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@bitwarden/importer",
|
||||
"version": "0.0.0",
|
||||
"description": "Home for all Bitwarden importers.",
|
||||
"keywords": [
|
||||
"bitwarden"
|
||||
],
|
||||
"author": "Bitwarden Inc.",
|
||||
"homepage": "https://bitwarden.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bitwarden/clients"
|
||||
},
|
||||
"license": "GPL-3.0",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/**/*",
|
||||
"build": "npm run clean && tsc",
|
||||
"build:watch": "npm run clean && tsc -watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bitwarden/common": "file:../common"
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@ import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
|
||||
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { BitwardenJsonImporter } from "@bitwarden/common/importers/bitwarden-json-importer";
|
||||
|
||||
import { BitwardenJsonImporter } from "../src/importers";
|
||||
|
||||
import { data as passwordProtectedData } from "./test-data/bitwarden-json/password-protected.json";
|
||||
|
@ -4,9 +4,10 @@ import { Substitute, Arg, SubstituteOf } from "@fluffy-spoon/substitute";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { KdfType } from "@bitwarden/common/enums/kdfType";
|
||||
import { BitwardenPasswordProtectedImporter } from "@bitwarden/common/importers/bitwarden-password-protected-importer";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
import { ImportResult } from "@bitwarden/common/models/domain/import-result";
|
||||
|
||||
import { BitwardenPasswordProtectedImporter } from "../src/importers";
|
||||
import { ImportResult } from "../src/models/import-result";
|
||||
|
||||
import { data as emptyDecryptedData } from "./test-data/bitwarden-json/empty.json";
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { ChromeCsvImporter as Importer } from "@bitwarden/common/importers/chrome-csv-importer";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||
|
||||
import { ChromeCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as androidData } from "./test-data/chrome-csv/android-data.csv";
|
||||
import { data as simplePasswordData } from "./test-data/chrome-csv/simple-password-data.csv";
|
||||
|
||||
@ -54,7 +55,7 @@ const CipherData = [
|
||||
describe("Chrome CSV Importer", () => {
|
||||
CipherData.forEach((data) => {
|
||||
it(data.title, async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new ChromeCsvImporter();
|
||||
const result = await importer.parse(data.csv);
|
||||
expect(result != null).toBe(true);
|
||||
expect(result.ciphers.length).toBeGreaterThan(0);
|
@ -1,6 +1,7 @@
|
||||
import { DashlaneCsvImporter as Importer } from "@bitwarden/common/importers/dashlane/dashlane-csv-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
|
||||
import { DashlaneCsvImporter } from "../src/importers";
|
||||
|
||||
import { credentialsData } from "./test-data/dashlane-csv/credentials.csv";
|
||||
import { identityData } from "./test-data/dashlane-csv/id.csv";
|
||||
import { multiplePersonalInfoData } from "./test-data/dashlane-csv/multiple-personal-info.csv";
|
||||
@ -9,9 +10,9 @@ import { personalInfoData } from "./test-data/dashlane-csv/personal-info.csv";
|
||||
import { secureNoteData } from "./test-data/dashlane-csv/securenotes.csv";
|
||||
|
||||
describe("Dashlane CSV Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: DashlaneCsvImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new DashlaneCsvImporter();
|
||||
});
|
||||
|
||||
it("should parse login records", async () => {
|
@ -1,12 +1,13 @@
|
||||
import { EnpassJsonImporter as Importer } from "@bitwarden/common/importers/enpass/enpass-json-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||
|
||||
import { creditCard } from "./test-data/json/credit-card";
|
||||
import { folders } from "./test-data/json/folders";
|
||||
import { login } from "./test-data/json/login";
|
||||
import { loginAndroidUrl } from "./test-data/json/login-android-url";
|
||||
import { note } from "./test-data/json/note";
|
||||
import { EnpassJsonImporter } from "../src/importers";
|
||||
|
||||
import { creditCard } from "./test-data/enpass-json/credit-card";
|
||||
import { folders } from "./test-data/enpass-json/folders";
|
||||
import { login } from "./test-data/enpass-json/login";
|
||||
import { loginAndroidUrl } from "./test-data/enpass-json/login-android-url";
|
||||
import { note } from "./test-data/enpass-json/note";
|
||||
|
||||
function validateCustomField(fields: FieldView[], fieldName: string, expectedValue: any) {
|
||||
expect(fields).toBeDefined();
|
||||
@ -18,7 +19,7 @@ function validateCustomField(fields: FieldView[], fieldName: string, expectedVal
|
||||
|
||||
describe("Enpass JSON Importer", () => {
|
||||
it("should create folders/ nested folder and assignment", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new EnpassJsonImporter();
|
||||
const testDataString = JSON.stringify(folders);
|
||||
const result = await importer.parse(testDataString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -37,7 +38,7 @@ describe("Enpass JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse login items", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new EnpassJsonImporter();
|
||||
const testDataString = JSON.stringify(login);
|
||||
const result = await importer.parse(testDataString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -64,7 +65,7 @@ describe("Enpass JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse login items with Android Autofill information", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new EnpassJsonImporter();
|
||||
const testDataString = JSON.stringify(loginAndroidUrl);
|
||||
const result = await importer.parse(testDataString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -82,7 +83,7 @@ describe("Enpass JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse credit card items", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new EnpassJsonImporter();
|
||||
const testDataString = JSON.stringify(creditCard);
|
||||
const result = await importer.parse(testDataString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -119,7 +120,7 @@ describe("Enpass JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse notes", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new EnpassJsonImporter();
|
||||
const testDataString = JSON.stringify(note);
|
||||
const result = await importer.parse(testDataString);
|
||||
expect(result != null).toBe(true);
|
@ -1,8 +1,9 @@
|
||||
import { FirefoxCsvImporter as Importer } from "@bitwarden/common/importers/firefox-csv-importer";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||
|
||||
import { FirefoxCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as firefoxAccountsData } from "./test-data/firefox-csv/firefox-accounts-data.csv";
|
||||
import { data as simplePasswordData } from "./test-data/firefox-csv/simple-password-data.csv";
|
||||
|
||||
@ -54,7 +55,7 @@ const CipherData = [
|
||||
describe("Firefox CSV Importer", () => {
|
||||
CipherData.forEach((data) => {
|
||||
it(data.title, async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new FirefoxCsvImporter();
|
||||
const result = await importer.parse(data.csv);
|
||||
expect(result != null).toBe(true);
|
||||
expect(result.ciphers.length).toBeGreaterThan(0);
|
@ -1,17 +1,22 @@
|
||||
import { KeePass2XmlImporter as Importer } from "@bitwarden/common/importers/keepass2-xml-importer";
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
|
||||
import { TestData, TestData1, TestData2 } from "./keepass2-xml-importer-testdata";
|
||||
import { KeePass2XmlImporter } from "../src/importers";
|
||||
|
||||
import {
|
||||
TestData,
|
||||
TestData1,
|
||||
TestData2,
|
||||
} from "./test-data/keepass2-xml/keepass2-xml-importer-testdata";
|
||||
|
||||
describe("KeePass2 Xml Importer", () => {
|
||||
it("should parse XML data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new KeePass2XmlImporter();
|
||||
const result = await importer.parse(TestData);
|
||||
expect(result != null).toBe(true);
|
||||
});
|
||||
|
||||
it("parse XML should contains folders", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new KeePass2XmlImporter();
|
||||
const folder = new FolderView();
|
||||
folder.name = "Folder2";
|
||||
const actual = [folder];
|
||||
@ -21,7 +26,7 @@ describe("KeePass2 Xml Importer", () => {
|
||||
});
|
||||
|
||||
it("parse XML should contains login details", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new KeePass2XmlImporter();
|
||||
const result = await importer.parse(TestData);
|
||||
expect(result.ciphers[0].login.uri != null).toBe(true);
|
||||
expect(result.ciphers[0].login.username != null).toBe(true);
|
||||
@ -29,13 +34,13 @@ describe("KeePass2 Xml Importer", () => {
|
||||
});
|
||||
|
||||
it("should return error with missing root tag", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new KeePass2XmlImporter();
|
||||
const result = await importer.parse(TestData1);
|
||||
expect(result.errorMessage).toBe("Missing `KeePassFile > Root` node.");
|
||||
});
|
||||
|
||||
it("should return error with missing KeePassFile tag", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new KeePass2XmlImporter();
|
||||
const result = await importer.parse(TestData2);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
@ -1,12 +1,13 @@
|
||||
import { KeeperCsvImporter as Importer } from "@bitwarden/common/importers/keeper/keeper-csv-importer";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
|
||||
import { KeeperCsvImporter } from "../src/importers";
|
||||
|
||||
import { testData as TestData } from "./test-data/keeper-csv/testdata.csv";
|
||||
|
||||
describe("Keeper CSV Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: KeeperCsvImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new KeeperCsvImporter();
|
||||
});
|
||||
|
||||
it("should parse login data", async () => {
|
@ -1,14 +1,15 @@
|
||||
import { KeeperJsonImporter as Importer } from "@bitwarden/common/importers/keeper/keeper-json-importer";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
|
||||
import { KeeperJsonImporter } from "../src/importers";
|
||||
|
||||
import { testData as TestData } from "./test-data/keeper-json/testdata.json";
|
||||
|
||||
describe("Keeper Json Importer", () => {
|
||||
const testDataJson = JSON.stringify(TestData);
|
||||
|
||||
let importer: Importer;
|
||||
let importer: KeeperJsonImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new KeeperJsonImporter();
|
||||
});
|
||||
|
||||
it("should parse login data", async () => {
|
@ -1,10 +1,11 @@
|
||||
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
||||
import { LastPassCsvImporter as Importer } from "@bitwarden/common/importers/lastpass-csv-importer";
|
||||
import { ImportResult } from "@bitwarden/common/models/domain/import-result";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||
|
||||
import { LastPassCsvImporter } from "../src/importers";
|
||||
import { ImportResult } from "../src/models/import-result";
|
||||
|
||||
function baseExcept(result: ImportResult) {
|
||||
expect(result).not.toBeNull();
|
||||
expect(result.success).toBe(true);
|
||||
@ -170,7 +171,7 @@ Notes:",nomonth,,0`,
|
||||
describe("Lastpass CSV Importer", () => {
|
||||
CipherData.forEach((data) => {
|
||||
it(data.title, async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new LastPassCsvImporter();
|
||||
const result = await importer.parse(data.csv);
|
||||
expect(result != null).toBe(true);
|
||||
expect(result.ciphers.length).toBeGreaterThan(0);
|
||||
@ -192,7 +193,7 @@ describe("Lastpass CSV Importer", () => {
|
||||
const input = `url,username,password,totp,extra,name,grouping,fav
|
||||
http://example.com,someUser,myPassword,Y64VEVMBTSXCYIWRSHRNDZW62MPGVU2G,super secure notes,example.com,,0`;
|
||||
|
||||
const importer = new Importer();
|
||||
const importer = new LastPassCsvImporter();
|
||||
const result = await importer.parse(input);
|
||||
baseExcept(result);
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { MykiCsvImporter as Importer } from "@bitwarden/common/importers/myki-csv-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
|
||||
import { MykiCsvImporter } from "../src/importers";
|
||||
|
||||
import { userAccountData } from "./test-data/myki-csv/user-account.csv";
|
||||
import { userCreditCardData } from "./test-data/myki-csv/user-credit-card.csv";
|
||||
import { userIdCardData } from "./test-data/myki-csv/user-id-card.csv";
|
||||
@ -432,9 +433,9 @@ function expectTourVisa(cipher: CipherView) {
|
||||
}
|
||||
|
||||
describe("Myki CSV Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: MykiCsvImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new MykiCsvImporter();
|
||||
});
|
||||
|
||||
it("should parse userAccount records", async () => {
|
@ -1,9 +1,10 @@
|
||||
import { SecureNoteType } from "@bitwarden/common/enums/secureNoteType";
|
||||
import { NordPassCsvImporter as Importer } from "@bitwarden/common/importers/nordpass-csv-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { IdentityView } from "@bitwarden/common/vault/models/view/identity.view";
|
||||
|
||||
import { NordPassCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as creditCardData } from "./test-data/nordpass-csv/nordpass.card.csv";
|
||||
import { data as identityData } from "./test-data/nordpass-csv/nordpass.identity.csv";
|
||||
import { data as loginData } from "./test-data/nordpass-csv/nordpass.login.csv";
|
||||
@ -108,9 +109,9 @@ function expectSecureNote(cipher: CipherView) {
|
||||
}
|
||||
|
||||
describe("NordPass CSV Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: NordPassCsvImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new NordPassCsvImporter();
|
||||
});
|
||||
|
||||
it("should parse login records", async () => {
|
@ -1,5 +1,6 @@
|
||||
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
||||
import { OnePassword1PifImporter as Importer } from "@bitwarden/common/importers/onepassword/onepassword-1pif-importer";
|
||||
|
||||
import { OnePassword1PifImporter } from "../src/importers";
|
||||
|
||||
const TestData: string =
|
||||
"***aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee***\n" +
|
||||
@ -425,7 +426,7 @@ const IdentityTestData = JSON.stringify({
|
||||
|
||||
describe("1Password 1Pif Importer", () => {
|
||||
it("should parse data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PifImporter();
|
||||
const result = await importer.parse(TestData);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -438,7 +439,7 @@ describe("1Password 1Pif Importer", () => {
|
||||
});
|
||||
|
||||
it('should create concealed field as "hidden" type', async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PifImporter();
|
||||
const result = await importer.parse(TestData);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -456,7 +457,7 @@ describe("1Password 1Pif Importer", () => {
|
||||
});
|
||||
|
||||
it("should create identity records", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PifImporter();
|
||||
const result = await importer.parse(IdentityTestData);
|
||||
expect(result != null).toBe(true);
|
||||
const cipher = result.ciphers.shift();
|
||||
@ -492,7 +493,7 @@ describe("1Password 1Pif Importer", () => {
|
||||
});
|
||||
|
||||
it("should create password history", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PifImporter();
|
||||
const result = await importer.parse(TestData);
|
||||
const cipher = result.ciphers.shift();
|
||||
|
||||
@ -503,7 +504,7 @@ describe("1Password 1Pif Importer", () => {
|
||||
});
|
||||
|
||||
it("should create password history from windows opvault 1pif format", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PifImporter();
|
||||
const result = await importer.parse(WindowsOpVaultTestData);
|
||||
const cipher = result.ciphers.shift();
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
||||
import { SecureNoteType } from "@bitwarden/common/enums/secureNoteType";
|
||||
import { OnePassword1PuxImporter as Importer } from "@bitwarden/common/importers/onepassword/onepassword-1pux-importer";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||
|
||||
import { OnePassword1PuxImporter } from "../src/importers";
|
||||
|
||||
import { APICredentialsData } from "./test-data/onepassword-1pux/api-credentials";
|
||||
import { BankAccountData } from "./test-data/onepassword-1pux/bank-account";
|
||||
import { CreditCardData } from "./test-data/onepassword-1pux/credit-card";
|
||||
@ -47,7 +48,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
const SanitizedExportJson = JSON.stringify(SanitizedExport);
|
||||
|
||||
it("should parse login data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(LoginDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -70,7 +71,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse notes", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(OnePuxExampleFileJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -79,7 +80,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should set favourite if favIndex equals 1", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(OnePuxExampleFileJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -88,7 +89,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should handle custom boolean fields", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(LoginDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -106,7 +107,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should add fields of type email as custom fields", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const EmailFieldDataJson = JSON.stringify(EmailFieldData);
|
||||
const result = await importer.parse(EmailFieldDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
@ -125,7 +126,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it('should create concealed field as "hidden" type', async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(OnePuxExampleFileJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -143,7 +144,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create password history", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(OnePuxExampleFileJson);
|
||||
const cipher = result.ciphers.shift();
|
||||
|
||||
@ -154,7 +155,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create credit card records", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(CreditCardDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
const cipher = result.ciphers.shift();
|
||||
@ -186,7 +187,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create identity records", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(IdentityDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
const cipher = result.ciphers.shift();
|
||||
@ -228,7 +229,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("emails fields on identity types should be added to the identity email field", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const EmailFieldOnIdentityDataJson = JSON.stringify(EmailFieldOnIdentityData);
|
||||
const result = await importer.parse(EmailFieldOnIdentityDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
@ -246,7 +247,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("emails fields on identity types should be added to custom fields if identity.email has been filled", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const EmailFieldOnIdentityPrefilledDataJson = JSON.stringify(EmailFieldOnIdentityPrefilledData);
|
||||
const result = await importer.parse(EmailFieldOnIdentityPrefilledDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
@ -268,7 +269,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 005 - Password (Legacy)", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(PasswordData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -282,7 +283,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 100 - SoftwareLicense", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(SoftwareLicenseData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -312,7 +313,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 101 - BankAccount", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(BankAccountData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -336,7 +337,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 102 - Database", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(DatabaseData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -361,7 +362,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 103 - Drivers license", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(DriversLicenseData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -389,7 +390,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 104 - Outdoor License", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(OutdoorLicenseData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -415,7 +416,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 105 - Membership", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(MembershipData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -440,7 +441,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 106 - Passport", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(PassportData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -467,7 +468,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 107 - RewardsProgram", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(RewardsProgramData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -493,7 +494,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 108 - SSN", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(SSNData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -508,7 +509,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 109 - WirelessRouter", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(WirelessRouterData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -531,7 +532,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 110 - Server", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(ServerData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -564,7 +565,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 111 - EmailAccount", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(EmailAccountData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -595,7 +596,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 112 - API Credentials", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(APICredentialsData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -617,7 +618,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create secure notes", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(SecureNoteDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
const cipher = result.ciphers.shift();
|
||||
@ -630,7 +631,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse category 113 - Medical Record", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const jsonString = JSON.stringify(MedicalRecordData);
|
||||
const result = await importer.parse(jsonString);
|
||||
expect(result != null).toBe(true);
|
||||
@ -652,7 +653,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create folders", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
const result = await importer.parse(SanitizedExportJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -673,7 +674,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
});
|
||||
|
||||
it("should create collections if part of an organization", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePassword1PuxImporter();
|
||||
importer.organizationId = Utils.newGuid();
|
||||
const result = await importer.parse(SanitizedExportJson);
|
||||
expect(result != null).toBe(true);
|
@ -1,7 +1,8 @@
|
||||
import { OnePasswordMacCsvImporter as Importer } from "@bitwarden/common/importers/onepassword/onepassword-mac-csv-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
|
||||
import { OnePasswordMacCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as creditCardData } from "./test-data/onepassword-csv/credit-card.mac.csv";
|
||||
import { data as identityData } from "./test-data/onepassword-csv/identity.mac.csv";
|
||||
import { data as multiTypeData } from "./test-data/onepassword-csv/multiple-items.mac.csv";
|
||||
@ -40,7 +41,7 @@ function expectCreditCard(cipher: CipherView) {
|
||||
|
||||
describe("1Password mac CSV Importer", () => {
|
||||
it("should parse identity records", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePasswordMacCsvImporter();
|
||||
const result = await importer.parse(identityData);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
@ -51,7 +52,7 @@ describe("1Password mac CSV Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse credit card records", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePasswordMacCsvImporter();
|
||||
const result = await importer.parse(creditCardData);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
@ -62,7 +63,7 @@ describe("1Password mac CSV Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse csv's with multiple record type", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new OnePasswordMacCsvImporter();
|
||||
const result = await importer.parse(multiTypeData);
|
||||
|
||||
expect(result).not.toBeNull();
|
@ -1,9 +1,10 @@
|
||||
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
||||
import { OnePasswordWinCsvImporter as Importer } from "@bitwarden/common/importers/onepassword/onepassword-win-csv-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||
|
||||
import { OnePasswordWinCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as creditCardData } from "./test-data/onepassword-csv/credit-card.windows.csv";
|
||||
import { data as identityData } from "./test-data/onepassword-csv/identity.windows.csv";
|
||||
import { data as multiTypeData } from "./test-data/onepassword-csv/multiple-items.windows.csv";
|
||||
@ -49,9 +50,9 @@ function expectCreditCard(cipher: CipherView) {
|
||||
}
|
||||
|
||||
describe("1Password windows CSV Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: OnePasswordWinCsvImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new OnePasswordWinCsvImporter();
|
||||
});
|
||||
|
||||
it("should parse identity records", async () => {
|
@ -1,12 +1,12 @@
|
||||
import { PasskyJsonImporter as Importer } from "@bitwarden/common/importers/passky/passky-json-importer";
|
||||
import { PasskyJsonImporter } from "../src/importers";
|
||||
|
||||
import { testData as EncryptedData } from "./test-data/passky-json/passky-encrypted.json";
|
||||
import { testData as UnencryptedData } from "./test-data/passky-json/passky-unencrypted.json";
|
||||
|
||||
describe("Passky Json Importer", () => {
|
||||
let importer: Importer;
|
||||
let importer: PasskyJsonImporter;
|
||||
beforeEach(() => {
|
||||
importer = new Importer();
|
||||
importer = new PasskyJsonImporter();
|
||||
});
|
||||
|
||||
it("should not import encrypted backups", async () => {
|
@ -1,8 +1,9 @@
|
||||
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
||||
import { PsonoJsonImporter as Importer } from "@bitwarden/common/importers/psono/psono-json-importer";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||
|
||||
import { PsonoJsonImporter } from "../src/importers";
|
||||
|
||||
import { ApplicationPasswordsData } from "./test-data/psono-json/application-passwords";
|
||||
import { BookmarkData } from "./test-data/psono-json/bookmark.json";
|
||||
import { EmptyTestFolderData } from "./test-data/psono-json/empty-folders";
|
||||
@ -39,7 +40,7 @@ describe("PSONO JSON Importer", () => {
|
||||
const EnvVariablesDataJson = JSON.stringify(EnvVariablesData);
|
||||
|
||||
it("should parse Website/Password data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(WebsiteLoginsDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -65,7 +66,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse Application Password data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(ApplicationPasswordsDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -84,7 +85,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse bookmark data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(BookmarkDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -103,7 +104,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse notes", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(NotesDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -118,7 +119,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse TOTP", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(TOTPDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -139,7 +140,7 @@ describe("PSONO JSON Importer", () => {
|
||||
|
||||
// Skipping this test until we can save GPG into notes/custom fields
|
||||
it.skip("should parse GPG data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(GPGDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -168,7 +169,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse Environment variables data", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(EnvVariablesDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -185,7 +186,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should not create empty folders", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(EmptyTestFolderDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -193,7 +194,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should create folders", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(FoldersTestDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -204,7 +205,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should assign entries to folders", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(FoldersTestDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
@ -215,7 +216,7 @@ describe("PSONO JSON Importer", () => {
|
||||
});
|
||||
|
||||
it("should create collections if part of an organization", async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new PsonoJsonImporter();
|
||||
importer.organizationId = "someOrg";
|
||||
const result = await importer.parse(FoldersTestDataJson);
|
||||
expect(result != null).toBe(true);
|
@ -1,8 +1,9 @@
|
||||
import { SafariCsvImporter as Importer } from "@bitwarden/common/importers/safari-csv-importer";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||
|
||||
import { SafariCsvImporter } from "../src/importers";
|
||||
|
||||
import { data as oldSimplePasswordData } from "./test-data/safari-csv/old-simple-password-data.csv";
|
||||
import { data as simplePasswordData } from "./test-data/safari-csv/simple-password-data.csv";
|
||||
|
||||
@ -54,7 +55,7 @@ const CipherData = [
|
||||
describe("Safari CSV Importer", () => {
|
||||
CipherData.forEach((data) => {
|
||||
it(data.title, async () => {
|
||||
const importer = new Importer();
|
||||
const importer = new SafariCsvImporter();
|
||||
const result = await importer.parse(data.csv);
|
||||
expect(result != null).toBe(true);
|
||||
expect(result.ciphers.length).toBeGreaterThan(0);
|
@ -1,4 +1,4 @@
|
||||
import { EnpassJsonFile } from "@bitwarden/common/importers/enpass/types/enpass-json-type";
|
||||
import { EnpassJsonFile } from "../../../src/importers/enpass/types/enpass-json-type";
|
||||
|
||||
export const creditCard: EnpassJsonFile = {
|
||||
folders: [],
|
@ -1,4 +1,4 @@
|
||||
import { EnpassJsonFile } from "@bitwarden/common/importers/enpass/types/enpass-json-type";
|
||||
import { EnpassJsonFile } from "../../../src/importers/enpass/types/enpass-json-type";
|
||||
|
||||
export const folders: EnpassJsonFile = {
|
||||
folders: [
|
@ -1,4 +1,4 @@
|
||||
import { EnpassJsonFile } from "@bitwarden/common/importers/enpass/types/enpass-json-type";
|
||||
import { EnpassJsonFile } from "../../../src/importers/enpass/types/enpass-json-type";
|
||||
|
||||
import { login } from "./login";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EnpassJsonFile } from "@bitwarden/common/importers/enpass/types/enpass-json-type";
|
||||
import { EnpassJsonFile } from "../../../src/importers/enpass/types/enpass-json-type";
|
||||
|
||||
export const login: EnpassJsonFile = {
|
||||
folders: [],
|
@ -1,4 +1,4 @@
|
||||
import { EnpassJsonFile } from "@bitwarden/common/importers/enpass/types/enpass-json-type";
|
||||
import { EnpassJsonFile } from "../../../src/importers/enpass/types/enpass-json-type";
|
||||
|
||||
export const note: EnpassJsonFile = {
|
||||
folders: [],
|
@ -1,4 +1,4 @@
|
||||
import { KeeperJsonExport } from "@bitwarden/common/importers/keeper/types/keeper-json-types";
|
||||
import { KeeperJsonExport } from "../../../src/importers/keeper/types/keeper-json-types";
|
||||
|
||||
export const testData: KeeperJsonExport = {
|
||||
shared_folders: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const APICredentialsData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const BankAccountData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const CreditCardData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const DatabaseData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const DriversLicenseData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const EmailAccountData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const EmailFieldOnIdentityData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const EmailFieldOnIdentityPrefilledData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const EmailFieldData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const IdentityData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const LoginData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const MedicalRecordData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const MembershipData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const OnePuxExampleFile: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const OutdoorLicenseData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const PassportData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const PasswordData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const RewardsProgramData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const SanitizedExport: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const SecureNoteData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const ServerData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const SoftwareLicenseData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const SSNData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { ExportData } from "@bitwarden/common/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
import { ExportData } from "../../../src/importers/onepassword/types/onepassword-1pux-importer-types";
|
||||
|
||||
export const WirelessRouterData: ExportData = {
|
||||
accounts: [
|
@ -1,4 +1,4 @@
|
||||
import { PasskyJsonExport } from "@bitwarden/common/importers/passky/passky-json-types";
|
||||
import { PasskyJsonExport } from "../../../src/importers/passky/passky-json-types";
|
||||
|
||||
export const testData: PasskyJsonExport = {
|
||||
encrypted: true,
|
@ -1,4 +1,4 @@
|
||||
import { PasskyJsonExport } from "@bitwarden/common/importers/passky/passky-json-types";
|
||||
import { PasskyJsonExport } from "../../../src/importers/passky/passky-json-types";
|
||||
|
||||
export const testData: PasskyJsonExport = {
|
||||
encrypted: false,
|
@ -1,4 +1,4 @@
|
||||
import { PsonoJsonExport } from "@bitwarden/common/importers/psono/psono-json-types";
|
||||
import { PsonoJsonExport } from "../../../src/importers/psono/psono-json-types";
|
||||
|
||||
export const ApplicationPasswordsData: PsonoJsonExport = {
|
||||
folders: [],
|
@ -1,4 +1,4 @@
|
||||
import { PsonoJsonExport } from "@bitwarden/common/importers/psono/psono-json-types";
|
||||
import { PsonoJsonExport } from "../../../src/importers/psono/psono-json-types";
|
||||
|
||||
export const BookmarkData: PsonoJsonExport = {
|
||||
folders: [],
|
@ -1,4 +1,4 @@
|
||||
import { PsonoJsonExport } from "@bitwarden/common/importers/psono/psono-json-types";
|
||||
import { PsonoJsonExport } from "../../../src/importers/psono/psono-json-types";
|
||||
|
||||
export const EmptyTestFolderData: PsonoJsonExport = {
|
||||
folders: [
|
@ -1,4 +1,4 @@
|
||||
import { PsonoJsonExport } from "@bitwarden/common/importers/psono/psono-json-types";
|
||||
import { PsonoJsonExport } from "../../../src/importers/psono/psono-json-types";
|
||||
|
||||
export const EnvVariablesData: PsonoJsonExport = {
|
||||
folders: [],
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user