mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
[PS-1755] BEEEP: FSecure FSK-Importer improvements (#3877)
* Move FsecureFskImporter into separate folder * Add types for exported fsk file * Add new testdata and rewrite existing tests * Fix #2801 - Use type instead of style property to differentiate between cipher types * Add setting cipher.favorite * Remove unmapped property autofillAndroid * Re-naming files due to new naming convention Renamed added or changed files of this PR Fixed all imports Removed items from the whitelist * Extract method refactor Move logic inside of parse loop into parseEntry Extract handling of Entries of type Login into handleLoginEntry Extract handling of Entries of type CreditCard into handleCreditCardEntry * Simplify folder structure Use vendor name importer folder Rename /importers/fsecureImporters to /importers/fsecure Move fsecure-fsk-types.ts out of the types folder into the fsecure-folder Delete types folder Fix all the imports * Move spec and test-data to fsecure importer * Fix broken import after merge master * Use the new FSecureFskImporter Must have messed up during the last merge: Delete old importer and spec Fix import of FSecureFskImporter in import.service
This commit is contained in:
committed by
GitHub
parent
3a98b415b0
commit
d6acc77ba7
@@ -0,0 +1,52 @@
|
||||
import { CipherType } from "../../enums/cipherType";
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user