1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 11:43:46 +00: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:
Daniel James Smith
2023-03-23 11:43:27 +01:00
committed by GitHub
parent 7cfabf053c
commit a5a12a6723
202 changed files with 706 additions and 479 deletions

View File

@@ -0,0 +1,52 @@
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
import { FSecureFskImporter as Importer } from "./fsecure-fsk-importer";
import { CreditCardTestEntry, LoginTestEntry } from "./fsk-test-data";
describe("FSecure FSK Importer", () => {
it("should import data of type login", async () => {
const importer = new Importer();
const LoginTestEntryStringified = JSON.stringify(LoginTestEntry);
const result = await importer.parse(LoginTestEntryStringified);
expect(result != null).toBe(true);
const cipher = result.ciphers.shift();
expect(cipher.name).toEqual("example.com");
expect(cipher.favorite).toBe(true);
expect(cipher.notes).toEqual("some note for example.com");
expect(cipher.type).toBe(CipherType.Login);
expect(cipher.login.username).toEqual("jdoe");
expect(cipher.login.password).toEqual("somePassword");
expect(cipher.login.uris.length).toEqual(1);
const uriView = cipher.login.uris.shift();
expect(uriView.uri).toEqual("https://www.example.com");
});
it("should import data of type creditCard", async () => {
const importer = new Importer();
const CreditCardTestEntryStringified = JSON.stringify(CreditCardTestEntry);
const result = await importer.parse(CreditCardTestEntryStringified);
expect(result != null).toBe(true);
const cipher = result.ciphers.shift();
expect(cipher.name).toEqual("My credit card");
expect(cipher.favorite).toBe(false);
expect(cipher.notes).toEqual("some notes to my card");
expect(cipher.type).toBe(CipherType.Card);
expect(cipher.card.cardholderName).toEqual("John Doe");
expect(cipher.card.number).toEqual("4242424242424242");
expect(cipher.card.code).toEqual("123");
expect(cipher.fields.length).toBe(2);
expect(cipher.fields[0].name).toEqual("Expiration");
expect(cipher.fields[0].value).toEqual("22.10.2026");
expect(cipher.fields[1].name).toEqual("PIN");
expect(cipher.fields[1].value).toEqual("1234");
});
});