mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-21 16:18:28 +01:00
[PM-536] Adding the 1password fix for custom sections and test cases (#7190)
* Adding the 1password fix for custom sections and test cases * sorting the validate function * running prettier to format files * removed id from getField name and refactored dupe field validation
This commit is contained in:
parent
6755c8c6ce
commit
64362fe869
@ -37,6 +37,17 @@ function validateCustomField(fields: FieldView[], fieldName: string, expectedVal
|
||||
expect(customField.value).toEqual(expectedValue);
|
||||
}
|
||||
|
||||
function validateDuplicateCustomField(
|
||||
fields: FieldView[],
|
||||
fieldName: string,
|
||||
expectedValues: string[],
|
||||
) {
|
||||
expect(fields).toBeDefined();
|
||||
const customFieldValues = fields.filter((f) => f.name === fieldName).map((v) => v.value);
|
||||
|
||||
expect(customFieldValues).toEqual(expectedValues);
|
||||
}
|
||||
|
||||
describe("1Password 1Pux Importer", () => {
|
||||
const OnePuxExampleFileJson = JSON.stringify(OnePuxExampleFile);
|
||||
const LoginDataJson = JSON.stringify(LoginData);
|
||||
@ -65,7 +76,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.fields.length).toEqual(3);
|
||||
validateCustomField(cipher.fields, "terms", "false");
|
||||
validateCustomField(cipher.fields, "policies", "true");
|
||||
validateCustomField(cipher.fields, "cyqyggt2otns6tbbqtsl6w2ceu", "username123123");
|
||||
validateCustomField(cipher.fields, "Create an account", "username123123");
|
||||
});
|
||||
|
||||
it("should parse notes", async () => {
|
||||
@ -114,7 +125,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(ciphers.length).toEqual(1);
|
||||
const cipher = ciphers.shift();
|
||||
|
||||
expect(cipher.fields[0].name).toEqual("reg_email");
|
||||
expect(cipher.fields[0].name).toEqual("registered email");
|
||||
expect(cipher.fields[0].value).toEqual("kriddler@nullvalue.test");
|
||||
expect(cipher.fields[0].type).toBe(FieldType.Text);
|
||||
|
||||
@ -170,18 +181,18 @@ describe("1Password 1Pux Importer", () => {
|
||||
|
||||
// remaining fields as custom fields
|
||||
expect(cipher.fields.length).toEqual(12);
|
||||
validateCustomField(cipher.fields, "txbzvwzpck7ejhfres3733rbpm", "card");
|
||||
validateCustomField(cipher.fields, "cashLimit", "$500");
|
||||
validateCustomField(cipher.fields, "creditLimit", "$1312");
|
||||
validateCustomField(cipher.fields, "validFrom", "200101");
|
||||
validateCustomField(cipher.fields, "bank", "Some bank");
|
||||
validateCustomField(cipher.fields, "phoneLocal", "123456");
|
||||
validateCustomField(cipher.fields, "phoneTollFree", "0800123456");
|
||||
validateCustomField(cipher.fields, "phoneIntl", "+49123456");
|
||||
validateCustomField(cipher.fields, "", "card");
|
||||
validateCustomField(cipher.fields, "cash withdrawal limit", "$500");
|
||||
validateCustomField(cipher.fields, "credit limit", "$1312");
|
||||
validateCustomField(cipher.fields, "valid from", "200101");
|
||||
validateCustomField(cipher.fields, "issuing bank", "Some bank");
|
||||
validateCustomField(cipher.fields, "phone (local)", "123456");
|
||||
validateCustomField(cipher.fields, "phone (toll free)", "0800123456");
|
||||
validateCustomField(cipher.fields, "phone (intl)", "+49123456");
|
||||
validateCustomField(cipher.fields, "website", "somebank.com");
|
||||
validateCustomField(cipher.fields, "pin", "1234");
|
||||
validateCustomField(cipher.fields, "interest", "1%");
|
||||
validateCustomField(cipher.fields, "issuenumber", "123456");
|
||||
validateCustomField(cipher.fields, "PIN", "1234");
|
||||
validateCustomField(cipher.fields, "interest rate", "1%");
|
||||
validateCustomField(cipher.fields, "issue number", "123456");
|
||||
});
|
||||
|
||||
it("should create identity records", async () => {
|
||||
@ -208,22 +219,22 @@ describe("1Password 1Pux Importer", () => {
|
||||
// remaining fields as custom fields
|
||||
expect(cipher.fields.length).toEqual(17);
|
||||
validateCustomField(cipher.fields, "sex", "male");
|
||||
validateCustomField(cipher.fields, "birthdate", "Thu, 01 Jan 1981 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "birth date", "Thu, 01 Jan 1981 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "occupation", "Steel Worker");
|
||||
validateCustomField(cipher.fields, "department", "QA");
|
||||
validateCustomField(cipher.fields, "jobtitle", "Quality Assurance Manager");
|
||||
validateCustomField(cipher.fields, "homephone", "4575555555");
|
||||
validateCustomField(cipher.fields, "cellphone", "4585555555");
|
||||
validateCustomField(cipher.fields, "busphone", "4595555555");
|
||||
validateCustomField(cipher.fields, "reminderq", "Who's a super cool guy?");
|
||||
validateCustomField(cipher.fields, "remindera", "Me, buddy.");
|
||||
validateCustomField(cipher.fields, "job title", "Quality Assurance Manager");
|
||||
validateCustomField(cipher.fields, "home", "4575555555");
|
||||
validateCustomField(cipher.fields, "cell", "4585555555");
|
||||
validateCustomField(cipher.fields, "business", "4595555555");
|
||||
validateCustomField(cipher.fields, "reminder question", "Who's a super cool guy?");
|
||||
validateCustomField(cipher.fields, "reminder answer", "Me, buddy.");
|
||||
validateCustomField(cipher.fields, "website", "cv.gengels.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "icq", "12345678");
|
||||
validateCustomField(cipher.fields, "ICQ", "12345678");
|
||||
validateCustomField(cipher.fields, "skype", "skypeisbad1619");
|
||||
validateCustomField(cipher.fields, "aim", "aollol@lololol.aol.com");
|
||||
validateCustomField(cipher.fields, "yahoo", "sk8rboi13@yah00.com");
|
||||
validateCustomField(cipher.fields, "msn", "msnothankyou@msn&m&m.com");
|
||||
validateCustomField(cipher.fields, "forumsig", "super cool guy");
|
||||
validateCustomField(cipher.fields, "AOL/AIM", "aollol@lololol.aol.com");
|
||||
validateCustomField(cipher.fields, "Yahoo", "sk8rboi13@yah00.com");
|
||||
validateCustomField(cipher.fields, "MSN", "msnothankyou@msn&m&m.com");
|
||||
validateCustomField(cipher.fields, "forum signature", "super cool guy");
|
||||
});
|
||||
|
||||
it("emails fields on identity types should be added to the identity email field", async () => {
|
||||
@ -257,7 +268,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
const identity = cipher.identity;
|
||||
expect(identity.email).toEqual("gengels@nullvalue.test");
|
||||
|
||||
expect(cipher.fields[0].name).toEqual("2nd_email");
|
||||
expect(cipher.fields[0].name).toEqual("2nd email");
|
||||
expect(cipher.fields[0].value).toEqual("kriddler@nullvalue.test");
|
||||
expect(cipher.fields[0].type).toBe(FieldType.Text);
|
||||
|
||||
@ -291,23 +302,23 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.notes).toEqual("My Software License");
|
||||
|
||||
expect(cipher.fields.length).toEqual(13);
|
||||
validateCustomField(cipher.fields, "product_version", "5.10.1000");
|
||||
validateCustomField(cipher.fields, "reg_code", "265453-13457355-847327");
|
||||
validateCustomField(cipher.fields, "reg_name", "Kay Riddler");
|
||||
validateCustomField(cipher.fields, "reg_email", "kriddler@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "version", "5.10.1000");
|
||||
validateCustomField(cipher.fields, "license key", "265453-13457355-847327");
|
||||
validateCustomField(cipher.fields, "licensed to", "Kay Riddler");
|
||||
validateCustomField(cipher.fields, "registered email", "kriddler@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "company", "Riddles and Jigsaw Puzzles GmbH");
|
||||
validateCustomField(
|
||||
cipher.fields,
|
||||
"download_link",
|
||||
"download page",
|
||||
"https://limuxcompany.nullvalue.test/5.10.1000/isos",
|
||||
);
|
||||
validateCustomField(cipher.fields, "publisher_name", "Limux Software and Hardware");
|
||||
validateCustomField(cipher.fields, "publisher_website", "https://limuxcompany.nullvalue.test/");
|
||||
validateCustomField(cipher.fields, "retail_price", "$999");
|
||||
validateCustomField(cipher.fields, "support_email", "support@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "order_date", "Thu, 01 Apr 2021 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "order_number", "594839");
|
||||
validateCustomField(cipher.fields, "order_total", "$1086.59");
|
||||
validateCustomField(cipher.fields, "publisher", "Limux Software and Hardware");
|
||||
validateCustomField(cipher.fields, "website", "https://limuxcompany.nullvalue.test/");
|
||||
validateCustomField(cipher.fields, "retail price", "$999");
|
||||
validateCustomField(cipher.fields, "support email", "support@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "purchase date", "Thu, 01 Apr 2021 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "order number", "594839");
|
||||
validateCustomField(cipher.fields, "order total", "$1086.59");
|
||||
});
|
||||
|
||||
it("should parse category 101 - BankAccount", async () => {
|
||||
@ -323,15 +334,15 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.card.cardholderName).toEqual("Cool Guy");
|
||||
|
||||
expect(cipher.fields.length).toEqual(9);
|
||||
validateCustomField(cipher.fields, "bankName", "Super Credit Union");
|
||||
validateCustomField(cipher.fields, "accountType", "checking");
|
||||
validateCustomField(cipher.fields, "routingNo", "111000999");
|
||||
validateCustomField(cipher.fields, "accountNo", "192837465918273645");
|
||||
validateCustomField(cipher.fields, "swift", "123456");
|
||||
validateCustomField(cipher.fields, "iban", "DE12 123456");
|
||||
validateCustomField(cipher.fields, "telephonePin", "5555");
|
||||
validateCustomField(cipher.fields, "branchPhone", "9399399933");
|
||||
validateCustomField(cipher.fields, "branchAddress", "1 Fifth Avenue");
|
||||
validateCustomField(cipher.fields, "bank name", "Super Credit Union");
|
||||
validateCustomField(cipher.fields, "type", "checking");
|
||||
validateCustomField(cipher.fields, "routing number", "111000999");
|
||||
validateCustomField(cipher.fields, "account number", "192837465918273645");
|
||||
validateCustomField(cipher.fields, "SWIFT", "123456");
|
||||
validateCustomField(cipher.fields, "IBAN", "DE12 123456");
|
||||
validateCustomField(cipher.fields, "PIN", "5555");
|
||||
validateCustomField(cipher.fields, "phone", "9399399933");
|
||||
validateCustomField(cipher.fields, "address", "1 Fifth Avenue");
|
||||
});
|
||||
|
||||
it("should parse category 102 - Database", async () => {
|
||||
@ -350,13 +361,13 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(login.password).toEqual("^+kTjhLaN7wVPAhGU)*J");
|
||||
|
||||
expect(cipher.fields.length).toEqual(7);
|
||||
validateCustomField(cipher.fields, "database_type", "postgresql");
|
||||
validateCustomField(cipher.fields, "hostname", "my.secret.db.server");
|
||||
validateCustomField(cipher.fields, "type", "postgresql");
|
||||
validateCustomField(cipher.fields, "server", "my.secret.db.server");
|
||||
validateCustomField(cipher.fields, "port", "1337");
|
||||
validateCustomField(cipher.fields, "database", "user_database");
|
||||
validateCustomField(cipher.fields, "sid", "ASDIUFU-283234");
|
||||
validateCustomField(cipher.fields, "SID", "ASDIUFU-283234");
|
||||
validateCustomField(cipher.fields, "alias", "cdbu");
|
||||
validateCustomField(cipher.fields, "options", "ssh");
|
||||
validateCustomField(cipher.fields, "connection options", "ssh");
|
||||
});
|
||||
|
||||
it("should parse category 103 - Drivers license", async () => {
|
||||
@ -379,12 +390,12 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(identity.licenseNumber).toEqual("12345678901");
|
||||
|
||||
expect(cipher.fields.length).toEqual(6);
|
||||
validateCustomField(cipher.fields, "birthdate", "Sun, 01 Jan 1978 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "date of birth", "Sun, 01 Jan 1978 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "sex", "male");
|
||||
validateCustomField(cipher.fields, "height", "5'11\"");
|
||||
validateCustomField(cipher.fields, "class", "C");
|
||||
validateCustomField(cipher.fields, "conditions", "B");
|
||||
validateCustomField(cipher.fields, "expiry_date", "203012");
|
||||
validateCustomField(cipher.fields, "license class", "C");
|
||||
validateCustomField(cipher.fields, "conditions / restrictions", "B");
|
||||
validateCustomField(cipher.fields, "expiry date", "203012");
|
||||
});
|
||||
|
||||
it("should parse category 104 - Outdoor License", async () => {
|
||||
@ -407,10 +418,10 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(identity.country).toEqual("United States of America");
|
||||
|
||||
expect(cipher.fields.length).toEqual(4);
|
||||
validateCustomField(cipher.fields, "valid_from", "Thu, 01 Apr 2021 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "valid from", "Thu, 01 Apr 2021 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "expires", "Fri, 01 Apr 2044 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "game", "Bananas,blueberries,corn");
|
||||
validateCustomField(cipher.fields, "quota", "100/each");
|
||||
validateCustomField(cipher.fields, "approved wildlife", "Bananas,blueberries,corn");
|
||||
validateCustomField(cipher.fields, "maximum quota", "100/each");
|
||||
});
|
||||
|
||||
it("should parse category 105 - Membership", async () => {
|
||||
@ -432,10 +443,10 @@ describe("1Password 1Pux Importer", () => {
|
||||
|
||||
expect(cipher.fields.length).toEqual(5);
|
||||
validateCustomField(cipher.fields, "website", "https://npl.nullvalue.gov.test");
|
||||
validateCustomField(cipher.fields, "member_since", "199901");
|
||||
validateCustomField(cipher.fields, "expiry_date", "203412");
|
||||
validateCustomField(cipher.fields, "membership_no", "64783862");
|
||||
validateCustomField(cipher.fields, "pin", "19191");
|
||||
validateCustomField(cipher.fields, "member since", "199901");
|
||||
validateCustomField(cipher.fields, "expiry date", "203412");
|
||||
validateCustomField(cipher.fields, "member ID", "64783862");
|
||||
validateCustomField(cipher.fields, "PIN", "19191");
|
||||
});
|
||||
|
||||
it("should parse category 106 - Passport", async () => {
|
||||
@ -458,11 +469,11 @@ describe("1Password 1Pux Importer", () => {
|
||||
validateCustomField(cipher.fields, "type", "US Passport");
|
||||
validateCustomField(cipher.fields, "sex", "female");
|
||||
validateCustomField(cipher.fields, "nationality", "International");
|
||||
validateCustomField(cipher.fields, "issuing_authority", "Department of State");
|
||||
validateCustomField(cipher.fields, "birthdate", "Fri, 01 Apr 1983 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "birthplace", "A cave somewhere in Maine");
|
||||
validateCustomField(cipher.fields, "issue_date", "Wed, 01 Jan 2020 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "expiry_date", "Sat, 01 Jan 2050 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "issuing authority", "Department of State");
|
||||
validateCustomField(cipher.fields, "date of birth", "Fri, 01 Apr 1983 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "place of birth", "A cave somewhere in Maine");
|
||||
validateCustomField(cipher.fields, "issued on", "Wed, 01 Jan 2020 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "expiry date", "Sat, 01 Jan 2050 12:01:00 GMT");
|
||||
});
|
||||
|
||||
it("should parse category 107 - RewardsProgram", async () => {
|
||||
@ -482,12 +493,12 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(identity.company).toEqual("Super Cool Store Co.");
|
||||
|
||||
expect(cipher.fields.length).toEqual(7);
|
||||
validateCustomField(cipher.fields, "membership_no", "member-29813569");
|
||||
validateCustomField(cipher.fields, "pin", "99913");
|
||||
validateCustomField(cipher.fields, "additional_no", "additional member id");
|
||||
validateCustomField(cipher.fields, "member_since", "202101");
|
||||
validateCustomField(cipher.fields, "customer_service_phone", "123456");
|
||||
validateCustomField(cipher.fields, "reservations_phone", "123456");
|
||||
validateCustomField(cipher.fields, "member ID", "member-29813569");
|
||||
validateCustomField(cipher.fields, "PIN", "99913");
|
||||
validateCustomField(cipher.fields, "member ID (additional)", "additional member id");
|
||||
validateCustomField(cipher.fields, "member since", "202101");
|
||||
validateCustomField(cipher.fields, "customer service phone", "123456");
|
||||
validateCustomField(cipher.fields, "phone for reservations", "123456");
|
||||
validateCustomField(cipher.fields, "website", "supercoolstore.com");
|
||||
});
|
||||
|
||||
@ -513,20 +524,19 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(result != null).toBe(true);
|
||||
const cipher = result.ciphers.shift();
|
||||
|
||||
expect(cipher.type).toEqual(CipherType.Login);
|
||||
expect(cipher.type).toEqual(CipherType.SecureNote);
|
||||
expect(cipher.name).toEqual("Wireless Router");
|
||||
expect(cipher.notes).toEqual("My Wifi Router Config");
|
||||
|
||||
expect(cipher.login.password).toEqual("BqatGTVQ9TCN72tLbjrsHqkb");
|
||||
|
||||
expect(cipher.fields.length).toEqual(7);
|
||||
validateCustomField(cipher.fields, "name", "pixel 2Xl");
|
||||
validateCustomField(cipher.fields, "server", "127.0.0.1");
|
||||
validateCustomField(cipher.fields, "airport_id", "some airportId");
|
||||
validateCustomField(cipher.fields, "network_name", "some network name");
|
||||
validateCustomField(cipher.fields, "wireless_security", "WPA");
|
||||
validateCustomField(cipher.fields, "wireless_password", "wifipassword");
|
||||
validateCustomField(cipher.fields, "disk_password", "diskpassword");
|
||||
expect(cipher.fields.length).toEqual(8);
|
||||
validateCustomField(cipher.fields, "base station name", "pixel 2Xl");
|
||||
validateCustomField(cipher.fields, "base station password", "BqatGTVQ9TCN72tLbjrsHqkb");
|
||||
validateCustomField(cipher.fields, "server / ip address", "127.0.0.1");
|
||||
validateCustomField(cipher.fields, "airport id", "some airportId");
|
||||
validateCustomField(cipher.fields, "network name", "some network name");
|
||||
validateCustomField(cipher.fields, "wireless security", "WPA");
|
||||
validateCustomField(cipher.fields, "wireless network password", "wifipassword");
|
||||
validateCustomField(cipher.fields, "attached storage password", "diskpassword");
|
||||
});
|
||||
|
||||
it("should parse category 110 - Server", async () => {
|
||||
@ -547,19 +557,15 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.fields.length).toEqual(7);
|
||||
validateCustomField(
|
||||
cipher.fields,
|
||||
"admin_console_url",
|
||||
"admin console URL",
|
||||
"https://coolserver.nullvalue.test/admin",
|
||||
);
|
||||
validateCustomField(cipher.fields, "admin_console_username", "frankly-idontknowwhatimdoing");
|
||||
validateCustomField(cipher.fields, "admin_console_password", "^%RY&^YUiju8iUYHJI(U");
|
||||
validateCustomField(cipher.fields, "admin console username", "frankly-idontknowwhatimdoing");
|
||||
validateCustomField(cipher.fields, "console password", "^%RY&^YUiju8iUYHJI(U");
|
||||
validateCustomField(cipher.fields, "name", "Private Hosting Provider Inc.");
|
||||
validateCustomField(cipher.fields, "website", "https://phpi.nullvalue.test");
|
||||
validateCustomField(
|
||||
cipher.fields,
|
||||
"support_contact_url",
|
||||
"https://phpi.nullvalue.test/support",
|
||||
);
|
||||
validateCustomField(cipher.fields, "support_contact_phone", "8882569382");
|
||||
validateCustomField(cipher.fields, "support URL", "https://phpi.nullvalue.test/support");
|
||||
validateCustomField(cipher.fields, "support phone", "8882569382");
|
||||
});
|
||||
|
||||
it("should parse category 111 - EmailAccount", async () => {
|
||||
@ -574,23 +580,25 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.notes).toEqual("My Email Config");
|
||||
|
||||
expect(cipher.fields.length).toEqual(17);
|
||||
validateCustomField(cipher.fields, "pop_type", "either");
|
||||
validateCustomField(cipher.fields, "pop_username", "someuser@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "pop_server", "mailserver.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "pop_port", "587");
|
||||
validateCustomField(cipher.fields, "pop_password", "u1jsf<UI*&YU&^T");
|
||||
validateCustomField(cipher.fields, "pop_security", "TLS");
|
||||
validateCustomField(cipher.fields, "pop_authentication", "kerberos_v5");
|
||||
validateCustomField(cipher.fields, "smtp_server", "mailserver.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "smtp_port", "589");
|
||||
validateCustomField(cipher.fields, "smtp_username", "someuser@nullvalue.test");
|
||||
validateCustomField(cipher.fields, "smtp_password", "(*1674%^UIUJ*UI(IUI8u98uyy");
|
||||
validateCustomField(cipher.fields, "smtp_security", "TLS");
|
||||
validateCustomField(cipher.fields, "smtp_authentication", "password");
|
||||
validateDuplicateCustomField(cipher.fields, "port number", ["587", "589"]);
|
||||
validateDuplicateCustomField(cipher.fields, "auth method", ["kerberos_v5", "password"]);
|
||||
validateDuplicateCustomField(cipher.fields, "username", [
|
||||
"someuser@nullvalue.test",
|
||||
"someuser@nullvalue.test",
|
||||
]);
|
||||
validateDuplicateCustomField(cipher.fields, "password", [
|
||||
"u1jsf<UI*&YU&^T",
|
||||
"(*1674%^UIUJ*UI(IUI8u98uyy",
|
||||
]);
|
||||
validateDuplicateCustomField(cipher.fields, "security", ["TLS", "TLS"]);
|
||||
|
||||
validateCustomField(cipher.fields, "type", "either");
|
||||
validateCustomField(cipher.fields, "server", "mailserver.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "SMTP server", "mailserver.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "provider", "Telum");
|
||||
validateCustomField(cipher.fields, "provider_website", "https://telum.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "phone_local", "2346666666");
|
||||
validateCustomField(cipher.fields, "phone_tollfree", "18005557777");
|
||||
validateCustomField(cipher.fields, "provider's website", "https://telum.nullvalue.test");
|
||||
validateCustomField(cipher.fields, "phone (local)", "2346666666");
|
||||
validateCustomField(cipher.fields, "phone (toll free)", "18005557777");
|
||||
});
|
||||
|
||||
it("should parse category 112 - API Credentials", async () => {
|
||||
@ -611,7 +619,7 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.fields.length).toEqual(4);
|
||||
validateCustomField(cipher.fields, "type", "jwt");
|
||||
validateCustomField(cipher.fields, "filename", "filename.jwt");
|
||||
validateCustomField(cipher.fields, "validFrom", "Mon, 04 Apr 2011 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "valid from", "Mon, 04 Apr 2011 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "expires", "Tue, 01 Apr 2031 12:01:00 GMT");
|
||||
});
|
||||
|
||||
@ -642,12 +650,12 @@ describe("1Password 1Pux Importer", () => {
|
||||
expect(cipher.fields.length).toEqual(8);
|
||||
validateCustomField(cipher.fields, "date", "Sat, 01 Jan 2022 12:01:00 GMT");
|
||||
validateCustomField(cipher.fields, "location", "some hospital/clinic");
|
||||
validateCustomField(cipher.fields, "healthcareprofessional", "Some Doctor");
|
||||
validateCustomField(cipher.fields, "healthcare professional", "Some Doctor");
|
||||
validateCustomField(cipher.fields, "patient", "Me");
|
||||
validateCustomField(cipher.fields, "reason", "unwell");
|
||||
validateCustomField(cipher.fields, "reason for visit", "unwell");
|
||||
validateCustomField(cipher.fields, "medication", "Insuline");
|
||||
validateCustomField(cipher.fields, "dosage", "1");
|
||||
validateCustomField(cipher.fields, "notes", "multiple times a day");
|
||||
validateCustomField(cipher.fields, "medication notes", "multiple times a day");
|
||||
});
|
||||
|
||||
it("should create folders", async () => {
|
||||
|
@ -199,11 +199,16 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
|
||||
return;
|
||||
}
|
||||
|
||||
this.parseSectionFields(category, section.fields, cipher);
|
||||
this.parseSectionFields(category, section.fields, cipher, section.title);
|
||||
});
|
||||
}
|
||||
|
||||
private parseSectionFields(category: CategoryEnum, fields: FieldsEntity[], cipher: CipherView) {
|
||||
private parseSectionFields(
|
||||
category: CategoryEnum,
|
||||
fields: FieldsEntity[],
|
||||
cipher: CipherView,
|
||||
sectionTitle: string,
|
||||
) {
|
||||
fields.forEach((field: FieldsEntity) => {
|
||||
const valueKey = Object.keys(field.value)[0];
|
||||
const anyField = field as any;
|
||||
@ -216,7 +221,7 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
|
||||
return;
|
||||
}
|
||||
|
||||
const fieldName = this.getFieldName(field.id, field.title);
|
||||
const fieldName = this.getFieldName(field.title, sectionTitle);
|
||||
const fieldValue = this.extractValue(field.value, valueKey);
|
||||
|
||||
if (cipher.type === CipherType.Login) {
|
||||
@ -338,16 +343,18 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
|
||||
});
|
||||
}
|
||||
|
||||
private getFieldName(id: string, title: string): string {
|
||||
if (this.isNullOrWhitespace(title)) {
|
||||
return id;
|
||||
}
|
||||
|
||||
// Naive approach of checking if the fields id is usable
|
||||
if (id.length > 25 && RegExp(/[0-9]{2}[A-Z]{2}/, "i").test(id)) {
|
||||
// Use the title if available. If not use the sectionTitle if available.
|
||||
// Default to an empty string in all other cases.
|
||||
private getFieldName(title: string, sectionTitle?: string): string {
|
||||
if (!this.isNullOrWhitespace(title)) {
|
||||
return title;
|
||||
}
|
||||
return id;
|
||||
|
||||
if (!this.isNullOrWhitespace(sectionTitle)) {
|
||||
return sectionTitle;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private extractValue(value: Value, valueKey: string): string {
|
||||
@ -363,7 +370,7 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
|
||||
}
|
||||
|
||||
private fillLogin(field: FieldsEntity, fieldValue: string, cipher: CipherView): boolean {
|
||||
const fieldName = this.getFieldName(field.id, field.title);
|
||||
const fieldName = this.getFieldName(field.title);
|
||||
|
||||
if (this.isNullOrWhitespace(cipher.login.username) && fieldName === "username") {
|
||||
cipher.login.username = fieldValue;
|
||||
@ -388,7 +395,7 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
|
||||
}
|
||||
|
||||
private fillApiCredentials(field: FieldsEntity, fieldValue: string, cipher: CipherView): boolean {
|
||||
const fieldName = this.getFieldName(field.id, field.title);
|
||||
const fieldName = this.getFieldName(field.title);
|
||||
|
||||
if (this.isNullOrWhitespace(cipher.login.password) && fieldName === "credential") {
|
||||
cipher.login.password = fieldValue;
|
||||
|
Loading…
Reference in New Issue
Block a user