-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handled identity item and unsupported items during ProtonPass import.
- Loading branch information
1 parent
1bf29f8
commit 840fe45
Showing
4 changed files
with
448 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { FieldType, CipherType } from "@bitwarden/common/vault/enums"; | |
|
||
import { ProtonPassJsonImporter } from "../src/importers"; | ||
|
||
import { identityItemTestData } from "./test-data/protonpass-json/protonpass-identity.json"; | ||
import { testData } from "./test-data/protonpass-json/protonpass.json"; | ||
|
||
describe("Protonpass Json Importer", () => { | ||
|
@@ -126,4 +127,94 @@ describe("Protonpass Json Importer", () => { | |
expect(ciphers[1].favorite).toBe(false); | ||
expect(ciphers[2].favorite).toBe(true); | ||
}); | ||
|
||
it("should skip unsupported items", async () => { | ||
const identityItemTestDataJson = JSON.stringify(identityItemTestData); | ||
const result = await importer.parse(identityItemTestDataJson); | ||
expect(result != null).toBe(true); | ||
|
||
const ciphers = result.ciphers; | ||
expect(ciphers.length).toBe(1); | ||
expect(ciphers[0].type).toEqual(CipherType.Identity); | ||
}); | ||
|
||
it("should parse identity data", async () => { | ||
const identityItemTestDataJson = JSON.stringify(identityItemTestData); | ||
const result = await importer.parse(identityItemTestDataJson); | ||
expect(result != null).toBe(true); | ||
|
||
const cipher = result.ciphers[0]; | ||
|
||
expect(cipher.type).toEqual(CipherType.Identity); | ||
expect(cipher.identity.firstName).toBe("Test"); | ||
expect(cipher.identity.middleName).toBe("1"); | ||
expect(cipher.identity.lastName).toBe("1"); | ||
expect(cipher.identity.email).toBe("[email protected]"); | ||
expect(cipher.identity.phone).toBe("7507951789"); | ||
expect(cipher.identity.company).toBe("Bitwarden"); | ||
expect(cipher.identity.ssn).toBe("98378264782"); | ||
expect(cipher.identity.passportNumber).toBe("7173716378612"); | ||
expect(cipher.identity.licenseNumber).toBe("21234"); | ||
expect(cipher.identity.address1).toBe("Bitwarden"); | ||
expect(cipher.identity.address2).toBe("23 Street"); | ||
expect(cipher.identity.address3).toBe("12th Foor Test County"); | ||
expect(cipher.identity.city).toBe("New York"); | ||
expect(cipher.identity.state).toBe("Test"); | ||
expect(cipher.identity.postalCode).toBe("4038456"); | ||
expect(cipher.identity.country).toBe("US"); | ||
|
||
expect(cipher.fields.length).toEqual(13); | ||
|
||
expect(cipher.fields.at(0).name).toEqual("gender"); | ||
expect(cipher.fields.at(0).value).toEqual("Male"); | ||
expect(cipher.fields.at(0).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(1).name).toEqual("TestPersonal"); | ||
expect(cipher.fields.at(1).value).toEqual("Personal"); | ||
expect(cipher.fields.at(1).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(2).name).toEqual("TestAddress"); | ||
expect(cipher.fields.at(2).value).toEqual("Address"); | ||
expect(cipher.fields.at(2).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(3).name).toEqual("xHandle"); | ||
expect(cipher.fields.at(3).value).toEqual("@twiter"); | ||
expect(cipher.fields.at(3).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(4).name).toEqual("secondPhoneNumber"); | ||
expect(cipher.fields.at(4).value).toEqual("243538978"); | ||
expect(cipher.fields.at(4).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(5).name).toEqual("instagram"); | ||
expect(cipher.fields.at(5).value).toEqual("@insta"); | ||
expect(cipher.fields.at(5).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(6).name).toEqual("TestContact"); | ||
expect(cipher.fields.at(6).value).toEqual("Contact"); | ||
expect(cipher.fields.at(6).type).toEqual(FieldType.Hidden); | ||
|
||
expect(cipher.fields.at(7).name).toEqual("jobTitle"); | ||
expect(cipher.fields.at(7).value).toEqual("Engineer"); | ||
expect(cipher.fields.at(7).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(8).name).toEqual("workPhoneNumber"); | ||
expect(cipher.fields.at(8).value).toEqual("78236476238746"); | ||
expect(cipher.fields.at(8).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(9).name).toEqual("TestWork"); | ||
expect(cipher.fields.at(9).value).toEqual("Work"); | ||
expect(cipher.fields.at(9).type).toEqual(FieldType.Hidden); | ||
|
||
expect(cipher.fields.at(10).name).toEqual("TestSection"); | ||
expect(cipher.fields.at(10).value).toEqual("Section"); | ||
expect(cipher.fields.at(10).type).toEqual(FieldType.Text); | ||
|
||
expect(cipher.fields.at(11).name).toEqual("TestSectionHidden"); | ||
expect(cipher.fields.at(11).value).toEqual("SectionHidden"); | ||
expect(cipher.fields.at(11).type).toEqual(FieldType.Hidden); | ||
|
||
expect(cipher.fields.at(12).name).toEqual("TestExtra"); | ||
expect(cipher.fields.at(12).value).toEqual("Extra"); | ||
expect(cipher.fields.at(12).type).toEqual(FieldType.Text); | ||
}); | ||
}); |
155 changes: 155 additions & 0 deletions
155
libs/importer/spec/test-data/protonpass-json/protonpass-identity.json.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import { ProtonPassJsonFile } from "../../../src/importers/protonpass/types/protonpass-json-type"; | ||
|
||
export const identityItemTestData: ProtonPassJsonFile = { | ||
encrypted: false, | ||
userId: | ||
"97AKUKQLkB-5BTBjoVgm3es34k8p5_UiKdxLnKb_57b4sekoGHKmKYV__6LMonA_00AKVBzWM-CL1Htkqkwl8Q==", | ||
vaults: { | ||
"TpawpLbs1nuUlQUCtgKZgb3zgAvbrGrOaqOylKqVe_RLROEyUvMq8_ZEuGw73PGRUSr89iNtQ2NosuggP54nwA==": { | ||
name: "Personal", | ||
description: "Personal vault", | ||
display: { color: 0, icon: 0 }, | ||
items: [ | ||
{ | ||
itemId: | ||
"gliCOyyJOsoBf5QIijvCF4QsPij3q_MR4nCXZ2sXm7YCJCfHjrRD_p2XG9vLsaytErsQvMhcLISVS7q8-7SCkg==", | ||
shareId: | ||
"TpawpLbs1nuUlQUCtgKZgb3zgAvbrGrOaqOylKqVe_RLROEyUvMq8_ZEuGw73PGRUSr89iNtQ2NosuggP54nwA==", | ||
data: { | ||
metadata: { | ||
name: "Identity", | ||
note: "", | ||
itemUuid: "c2e52768", | ||
}, | ||
extraFields: [ | ||
{ | ||
fieldName: "TestExtra", | ||
type: "text", | ||
data: { | ||
content: "Extra", | ||
}, | ||
}, | ||
], | ||
type: "identity", | ||
content: { | ||
fullName: "Test 1", | ||
email: "[email protected]", | ||
phoneNumber: "7507951789", | ||
firstName: "Test", | ||
middleName: "1", | ||
lastName: "Test", | ||
birthdate: "", | ||
gender: "Male", | ||
extraPersonalDetails: [ | ||
{ | ||
fieldName: "TestPersonal", | ||
type: "text", | ||
data: { | ||
content: "Personal", | ||
}, | ||
}, | ||
], | ||
organization: "Bitwarden", | ||
streetAddress: "23 Street", | ||
zipOrPostalCode: "4038456", | ||
city: "New York", | ||
stateOrProvince: "Test", | ||
countryOrRegion: "US", | ||
floor: "12th Foor", | ||
county: "Test County", | ||
extraAddressDetails: [ | ||
{ | ||
fieldName: "TestAddress", | ||
type: "text", | ||
data: { | ||
content: "Address", | ||
}, | ||
}, | ||
], | ||
socialSecurityNumber: "98378264782", | ||
passportNumber: "7173716378612", | ||
licenseNumber: "21234", | ||
website: "", | ||
xHandle: "@twiter", | ||
secondPhoneNumber: "243538978", | ||
linkedin: "", | ||
reddit: "", | ||
facebook: "", | ||
yahoo: "", | ||
instagram: "@insta", | ||
extraContactDetails: [ | ||
{ | ||
fieldName: "TestContact", | ||
type: "hidden", | ||
data: { | ||
content: "Contact", | ||
}, | ||
}, | ||
], | ||
company: "Bitwarden", | ||
jobTitle: "Engineer", | ||
personalWebsite: "", | ||
workPhoneNumber: "78236476238746", | ||
workEmail: "", | ||
extraWorkDetails: [ | ||
{ | ||
fieldName: "TestWork", | ||
type: "hidden", | ||
data: { | ||
content: "Work", | ||
}, | ||
}, | ||
], | ||
extraSections: [ | ||
{ | ||
sectionName: "TestSection", | ||
sectionFields: [ | ||
{ | ||
fieldName: "TestSection", | ||
type: "text", | ||
data: { | ||
content: "Section", | ||
}, | ||
}, | ||
{ | ||
fieldName: "TestSectionHidden", | ||
type: "hidden", | ||
data: { | ||
content: "SectionHidden", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
state: 1, | ||
aliasEmail: null, | ||
contentFormatVersion: 6, | ||
createTime: 1725707298, | ||
modifyTime: 1725707298, | ||
pinned: false, | ||
}, | ||
{ | ||
itemId: | ||
"WTKLZtKfHIC3Gv7gRXUANifNjj0gN3P_52I4MznAzig9GSb_OgJ0qcZ8taOZyfsFTLOWBslXwI-HSMWXVmnKzQ==", | ||
shareId: | ||
"TpawpLbs1nuUlQUCtgKZgb3zgAvbrGrOaqOylKqVe_RLROEyUvMq8_ZEuGw73PGRUSr89iNtQ2NosuggP54nwA==", | ||
data: { | ||
metadata: { name: "Alias", note: "", itemUuid: "576f14fa" }, | ||
extraFields: [], | ||
type: "alias", | ||
content: {}, | ||
}, | ||
state: 1, | ||
aliasEmail: "[email protected]", | ||
contentFormatVersion: 6, | ||
createTime: 1725708208, | ||
modifyTime: 1725708208, | ||
pinned: false, | ||
}, | ||
], | ||
}, | ||
}, | ||
version: "1.22.3", | ||
}; |
Oops, something went wrong.