2022-06-14 17:10:53 +02:00
|
|
|
import { FieldType } from "@bitwarden/common/enums/fieldType";
|
|
|
|
import { OnePassword1PifImporter as Importer } from "@bitwarden/common/importers/onepasswordImporters/onepassword1PifImporter";
|
2019-03-23 17:27:50 +01:00
|
|
|
|
2019-03-23 17:31:52 +01:00
|
|
|
const TestData: string =
|
|
|
|
"***aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee***\n" +
|
2019-03-23 17:27:50 +01:00
|
|
|
JSON.stringify({
|
2019-03-25 14:10:33 +01:00
|
|
|
uuid: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
|
|
updatedAt: 1486071244,
|
|
|
|
securityLevel: "SL5",
|
|
|
|
contentsHash: "aaaaaaaa",
|
|
|
|
title: "Imported Entry",
|
|
|
|
location: "https://www.google.com",
|
|
|
|
secureContents: {
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
value: "user@test.net",
|
|
|
|
id: "email-input",
|
|
|
|
name: "email",
|
|
|
|
type: "T",
|
|
|
|
designation: "username",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: "myservicepassword",
|
|
|
|
id: "password-input",
|
|
|
|
name: "password",
|
|
|
|
type: "P",
|
|
|
|
designation: "password",
|
|
|
|
},
|
2021-12-16 13:36:21 +01:00
|
|
|
],
|
2019-03-25 14:10:33 +01:00
|
|
|
sections: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
fields: [
|
2019-03-23 17:27:50 +01:00
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
k: "concealed",
|
|
|
|
n: "AAAAAAAAAAAABBBBBBBBBBBCCCCCCCCC",
|
|
|
|
v: "console-password-123",
|
|
|
|
t: "console password",
|
2019-03-23 17:27:50 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-25 14:10:33 +01:00
|
|
|
title: "Admin Console",
|
|
|
|
name: "admin_console",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-25 14:10:33 +01:00
|
|
|
passwordHistory: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2019-03-23 17:27:50 +01:00
|
|
|
value: "old-password",
|
2019-03-25 14:10:33 +01:00
|
|
|
time: 1447791421,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
URLs: [
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
label: "website",
|
|
|
|
url: "https://www.google.com",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-25 14:10:33 +01:00
|
|
|
txTimestamp: 1508941334,
|
|
|
|
createdAt: 1390426636,
|
|
|
|
typeName: "webforms.WebForm",
|
|
|
|
});
|
2019-03-23 17:27:50 +01:00
|
|
|
|
2019-03-25 14:10:33 +01:00
|
|
|
const WindowsOpVaultTestData = JSON.stringify({
|
2019-03-24 15:50:49 +01:00
|
|
|
category: "001",
|
|
|
|
created: 1544823719,
|
|
|
|
hmac: "NtyBmTTPOb88HV3JUKPx1xl/vcMhac9kvCfe/NtszY0=",
|
2019-03-27 19:46:34 +01:00
|
|
|
k: "**REMOVED LONG LINE FOR LINTER** -Kyle",
|
2019-03-24 15:50:49 +01:00
|
|
|
tx: 1553395669,
|
|
|
|
updated: 1553395669,
|
|
|
|
uuid: "528AB076FB5F4FBF960884B8E01619AC",
|
|
|
|
overview: {
|
|
|
|
title: "Google",
|
|
|
|
URLs: [
|
|
|
|
{
|
|
|
|
u: "google.com",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-24 15:50:49 +01:00
|
|
|
url: "google.com",
|
2021-12-16 13:36:21 +01:00
|
|
|
ps: 26,
|
2019-03-24 15:50:49 +01:00
|
|
|
ainfo: "googluser",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 15:50:49 +01:00
|
|
|
details: {
|
|
|
|
passwordHistory: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass1",
|
2019-03-24 15:50:49 +01:00
|
|
|
time: 1553394449,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass2",
|
2019-03-24 15:50:49 +01:00
|
|
|
time: 1553394457,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass3",
|
|
|
|
time: 1553394458,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass4",
|
|
|
|
time: 1553394459,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass5",
|
|
|
|
time: 1553394460,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-25 14:10:33 +01:00
|
|
|
value: "oldpass6",
|
|
|
|
time: 1553394461,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-24 15:50:49 +01:00
|
|
|
fields: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
|
|
|
type: "T",
|
2019-03-24 15:50:49 +01:00
|
|
|
id: "username",
|
|
|
|
name: "username",
|
|
|
|
value: "googluser",
|
|
|
|
designation: "username",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "P",
|
2019-03-24 15:50:49 +01:00
|
|
|
id: "password",
|
|
|
|
name: "password",
|
|
|
|
value: "12345678901",
|
|
|
|
designation: "password",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-24 15:50:49 +01:00
|
|
|
notesPlain: "This is a note\r\n\r\nline1\r\nline2",
|
|
|
|
sections: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2019-03-24 15:50:49 +01:00
|
|
|
title: "test",
|
|
|
|
name: "1214FD88CD30405D9EED14BEB4D61B60",
|
|
|
|
fields: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 15:50:49 +01:00
|
|
|
n: "6CC3BD77482D4559A4B8BB2D360F821B",
|
2021-12-16 13:36:21 +01:00
|
|
|
v: "fgfg",
|
|
|
|
t: "fgggf",
|
|
|
|
},
|
|
|
|
{
|
2019-03-24 15:50:49 +01:00
|
|
|
k: "concealed",
|
|
|
|
n: "5CFE7BCAA1DF4578BBF7EB508959BFF3",
|
|
|
|
v: "dfgdfgfdg",
|
|
|
|
t: "pwfield",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-12-16 13:36:21 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-03-24 15:50:49 +01:00
|
|
|
const IdentityTestData = JSON.stringify({
|
2019-03-25 14:10:33 +01:00
|
|
|
uuid: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
2019-03-24 15:50:49 +01:00
|
|
|
updatedAt: 1553365894,
|
2019-03-24 03:21:43 +01:00
|
|
|
securityLevel: "SL5",
|
|
|
|
contentsHash: "eeeeeeee",
|
2019-03-24 15:50:49 +01:00
|
|
|
title: "Test Identity",
|
2019-03-24 03:21:43 +01:00
|
|
|
secureContents: {
|
|
|
|
lastname: "Fritzenberger",
|
2019-03-24 15:50:49 +01:00
|
|
|
zip: "223344",
|
2019-03-24 03:21:43 +01:00
|
|
|
birthdate_dd: "11",
|
2019-03-24 15:50:49 +01:00
|
|
|
homephone: "+49 333 222 111",
|
2019-03-24 03:21:43 +01:00
|
|
|
company: "Web Inc.",
|
|
|
|
firstname: "Frank",
|
|
|
|
birthdate_mm: "3",
|
|
|
|
country: "de",
|
2021-12-16 13:36:21 +01:00
|
|
|
sex: "male",
|
2019-03-24 03:21:43 +01:00
|
|
|
sections: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2019-03-24 03:21:43 +01:00
|
|
|
fields: [
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Words",
|
2019-03-24 15:50:49 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "firstname",
|
2019-03-25 14:10:33 +01:00
|
|
|
v: "Frank",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 15:50:49 +01:00
|
|
|
guarded: "yes",
|
|
|
|
},
|
2019-03-25 14:10:33 +01:00
|
|
|
t: "first name",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
2019-03-25 14:10:33 +01:00
|
|
|
autocapitalization: "Words",
|
|
|
|
},
|
|
|
|
n: "initial",
|
|
|
|
v: "MD",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-25 14:10:33 +01:00
|
|
|
guarded: "yes",
|
|
|
|
},
|
|
|
|
t: "initial",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Words",
|
2019-03-25 14:10:33 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "lastname",
|
|
|
|
v: "Fritzenberger",
|
2019-03-25 14:10:33 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-25 14:10:33 +01:00
|
|
|
t: "last name",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "menu",
|
2019-03-25 14:10:33 +01:00
|
|
|
v: "male",
|
2021-12-16 13:36:21 +01:00
|
|
|
n: "sex",
|
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-25 14:10:33 +01:00
|
|
|
t: "sex",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "date",
|
2019-03-25 14:10:33 +01:00
|
|
|
v: 1552305660,
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "birthdate",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "birth date",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
2019-03-25 14:10:33 +01:00
|
|
|
autocapitalization: "Words",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "occupation",
|
|
|
|
v: "Engineer",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "occupation",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Words",
|
2019-03-25 14:10:33 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "company",
|
|
|
|
v: "Web Inc.",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "company",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Words",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "department",
|
2021-12-16 13:36:21 +01:00
|
|
|
v: "IT",
|
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "department",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Words",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "jobtitle",
|
|
|
|
v: "Developer",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "job title",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 15:50:49 +01:00
|
|
|
],
|
2019-03-24 03:21:43 +01:00
|
|
|
title: "Identification",
|
|
|
|
name: "name",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-24 15:50:49 +01:00
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
k: "address",
|
|
|
|
inputTraits: {
|
|
|
|
autocapitalization: "Sentences",
|
|
|
|
},
|
|
|
|
n: "address",
|
|
|
|
v: {
|
2019-03-24 03:21:43 +01:00
|
|
|
street: "Mainstreet 1",
|
|
|
|
city: "Berlin",
|
|
|
|
country: "de",
|
2019-03-24 15:50:49 +01:00
|
|
|
zip: "223344",
|
|
|
|
},
|
|
|
|
a: {
|
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "address",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-24 15:50:49 +01:00
|
|
|
k: "phone",
|
2019-03-24 03:21:43 +01:00
|
|
|
v: "+49 001 222 333 44",
|
2019-03-24 15:50:49 +01:00
|
|
|
n: "defphone",
|
|
|
|
a: {
|
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 15:50:49 +01:00
|
|
|
t: "default phone",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "phone",
|
|
|
|
v: "+49 333 222 111",
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "homephone",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 15:50:49 +01:00
|
|
|
t: "home",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "phone",
|
|
|
|
n: "cellphone",
|
|
|
|
a: {
|
|
|
|
guarded: "yes",
|
|
|
|
},
|
2021-12-16 13:36:21 +01:00
|
|
|
t: "mobile",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "phone",
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "busphone",
|
2021-12-16 13:36:21 +01:00
|
|
|
a: {
|
2019-03-24 03:21:43 +01:00
|
|
|
guarded: "yes",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "business",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 15:50:49 +01:00
|
|
|
],
|
2019-03-24 03:21:43 +01:00
|
|
|
title: "Address",
|
|
|
|
name: "address",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "username",
|
|
|
|
a: {
|
|
|
|
guarded: "yes",
|
|
|
|
},
|
|
|
|
t: "username",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "reminderq",
|
|
|
|
t: "reminder question",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "remindera",
|
|
|
|
t: "reminder answer",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
inputTraits: {
|
|
|
|
keyboard: "EmailAddress",
|
|
|
|
},
|
|
|
|
n: "email",
|
|
|
|
v: "test@web.de",
|
|
|
|
a: {
|
|
|
|
guarded: "yes",
|
|
|
|
},
|
|
|
|
t: "email",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-24 03:21:43 +01:00
|
|
|
k: "string",
|
|
|
|
n: "website",
|
|
|
|
inputTraits: {
|
|
|
|
keyboard: "URL",
|
|
|
|
},
|
|
|
|
t: "website",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "icq",
|
|
|
|
t: "ICQ",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "skype",
|
|
|
|
t: "skype",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "aim",
|
2019-03-24 03:21:43 +01:00
|
|
|
t: "AOL/AIM",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "yahoo",
|
|
|
|
t: "Yahoo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
|
|
|
n: "msn",
|
|
|
|
t: "MSN",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
k: "string",
|
2019-03-24 03:21:43 +01:00
|
|
|
n: "forumsig",
|
|
|
|
t: "forum signature",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
2019-03-24 03:21:43 +01:00
|
|
|
],
|
|
|
|
title: "Internet Details",
|
|
|
|
name: "internet",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
{
|
2019-03-24 03:21:43 +01:00
|
|
|
title: "Related Items",
|
|
|
|
name: "linked items",
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
],
|
2019-03-24 03:21:43 +01:00
|
|
|
initial: "MD",
|
|
|
|
address1: "Mainstreet 1",
|
|
|
|
city: "Berlin",
|
|
|
|
jobtitle: "Developer",
|
|
|
|
occupation: "Engineer",
|
|
|
|
department: "IT",
|
|
|
|
email: "test@web.de",
|
|
|
|
birthdate_yy: "2019",
|
|
|
|
homephone_local: "+49 333 222 111",
|
|
|
|
defphone_local: "+49 001 222 333 44",
|
|
|
|
defphone: "+49 001 222 333 44",
|
|
|
|
},
|
|
|
|
txTimestamp: 1553365894,
|
|
|
|
createdAt: 1553364679,
|
|
|
|
typeName: "identities.Identity",
|
|
|
|
});
|
|
|
|
|
2019-03-23 17:27:50 +01:00
|
|
|
describe("1Password 1Pif Importer", () => {
|
|
|
|
it("should parse data", async () => {
|
|
|
|
const importer = new Importer();
|
2020-12-05 03:05:11 +01:00
|
|
|
const result = await importer.parse(TestData);
|
2019-03-23 17:27:50 +01:00
|
|
|
expect(result != null).toBe(true);
|
|
|
|
|
|
|
|
const cipher = result.ciphers.shift();
|
|
|
|
expect(cipher.login.username).toEqual("user@test.net");
|
|
|
|
expect(cipher.login.password).toEqual("myservicepassword");
|
|
|
|
expect(cipher.login.uris.length).toEqual(1);
|
|
|
|
const uriView = cipher.login.uris.shift();
|
|
|
|
expect(uriView.uri).toEqual("https://www.google.com");
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create concealed field as "hidden" type', async () => {
|
|
|
|
const importer = new Importer();
|
2020-12-05 03:05:11 +01:00
|
|
|
const result = await importer.parse(TestData);
|
2019-03-23 17:27:50 +01:00
|
|
|
expect(result != null).toBe(true);
|
|
|
|
|
|
|
|
const ciphers = result.ciphers;
|
|
|
|
expect(ciphers.length).toEqual(1);
|
|
|
|
|
|
|
|
const cipher = ciphers.shift();
|
|
|
|
const fields = cipher.fields;
|
|
|
|
expect(fields.length).toEqual(1);
|
|
|
|
|
|
|
|
const field = fields.shift();
|
|
|
|
expect(field.name).toEqual("console password");
|
|
|
|
expect(field.value).toEqual("console-password-123");
|
|
|
|
expect(field.type).toEqual(FieldType.Hidden);
|
|
|
|
});
|
2019-03-24 03:21:43 +01:00
|
|
|
|
|
|
|
it("should create identity records", async () => {
|
|
|
|
const importer = new Importer();
|
2020-12-05 03:05:11 +01:00
|
|
|
const result = await importer.parse(IdentityTestData);
|
2019-03-24 03:21:43 +01:00
|
|
|
expect(result != null).toBe(true);
|
|
|
|
const cipher = result.ciphers.shift();
|
|
|
|
expect(cipher.name).toEqual("Test Identity");
|
|
|
|
|
|
|
|
const identity = cipher.identity;
|
|
|
|
expect(identity.firstName).toEqual("Frank");
|
|
|
|
expect(identity.middleName).toEqual("MD");
|
|
|
|
expect(identity.lastName).toEqual("Fritzenberger");
|
|
|
|
expect(identity.company).toEqual("Web Inc.");
|
|
|
|
expect(identity.address1).toEqual("Mainstreet 1");
|
2019-03-24 03:49:22 +01:00
|
|
|
expect(identity.country).toEqual("DE");
|
2019-03-24 03:21:43 +01:00
|
|
|
expect(identity.city).toEqual("Berlin");
|
|
|
|
expect(identity.postalCode).toEqual("223344");
|
|
|
|
expect(identity.phone).toEqual("+49 001 222 333 44");
|
|
|
|
expect(identity.email).toEqual("test@web.de");
|
|
|
|
|
|
|
|
// remaining fields as custom fields
|
|
|
|
expect(cipher.fields.length).toEqual(6);
|
2021-12-16 18:46:33 +01:00
|
|
|
const fields = cipher.fields;
|
|
|
|
expect(fields[0].name).toEqual("sex");
|
|
|
|
expect(fields[0].value).toEqual("male");
|
|
|
|
expect(fields[1].name).toEqual("birth date");
|
|
|
|
expect(fields[1].value).toEqual("Mon, 11 Mar 2019 12:01:00 GMT");
|
|
|
|
expect(fields[2].name).toEqual("occupation");
|
|
|
|
expect(fields[2].value).toEqual("Engineer");
|
|
|
|
expect(fields[3].name).toEqual("department");
|
|
|
|
expect(fields[3].value).toEqual("IT");
|
|
|
|
expect(fields[4].name).toEqual("job title");
|
|
|
|
expect(fields[4].value).toEqual("Developer");
|
|
|
|
expect(fields[5].name).toEqual("home");
|
|
|
|
expect(fields[5].value).toEqual("+49 333 222 111");
|
2019-03-24 03:21:43 +01:00
|
|
|
});
|
2019-03-24 15:50:49 +01:00
|
|
|
|
|
|
|
it("should create password history", async () => {
|
|
|
|
const importer = new Importer();
|
2020-12-05 03:05:11 +01:00
|
|
|
const result = await importer.parse(TestData);
|
2019-03-24 15:50:49 +01:00
|
|
|
const cipher = result.ciphers.shift();
|
|
|
|
|
|
|
|
expect(cipher.passwordHistory.length).toEqual(1);
|
|
|
|
const ph = cipher.passwordHistory.shift();
|
|
|
|
expect(ph.password).toEqual("old-password");
|
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2015-11-17T20:17:01.000Z");
|
|
|
|
});
|
|
|
|
|
2019-03-25 14:10:33 +01:00
|
|
|
it("should create password history from windows opvault 1pif format", async () => {
|
2019-03-24 15:50:49 +01:00
|
|
|
const importer = new Importer();
|
2020-12-05 03:05:11 +01:00
|
|
|
const result = await importer.parse(WindowsOpVaultTestData);
|
2019-03-24 15:50:49 +01:00
|
|
|
const cipher = result.ciphers.shift();
|
|
|
|
|
2019-03-25 14:10:33 +01:00
|
|
|
expect(cipher.passwordHistory.length).toEqual(5);
|
2019-03-24 15:50:49 +01:00
|
|
|
let ph = cipher.passwordHistory.shift();
|
2019-03-25 14:10:33 +01:00
|
|
|
expect(ph.password).toEqual("oldpass6");
|
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2019-03-24T02:27:41.000Z");
|
|
|
|
ph = cipher.passwordHistory.shift();
|
|
|
|
expect(ph.password).toEqual("oldpass5");
|
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2019-03-24T02:27:40.000Z");
|
|
|
|
ph = cipher.passwordHistory.shift();
|
|
|
|
expect(ph.password).toEqual("oldpass4");
|
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2019-03-24T02:27:39.000Z");
|
2019-03-24 15:50:49 +01:00
|
|
|
ph = cipher.passwordHistory.shift();
|
2019-03-25 14:10:33 +01:00
|
|
|
expect(ph.password).toEqual("oldpass3");
|
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2019-03-24T02:27:38.000Z");
|
|
|
|
ph = cipher.passwordHistory.shift();
|
|
|
|
expect(ph.password).toEqual("oldpass2");
|
2019-03-24 15:50:49 +01:00
|
|
|
expect(ph.lastUsedDate.toISOString()).toEqual("2019-03-24T02:27:37.000Z");
|
|
|
|
});
|
2019-03-23 17:27:50 +01:00
|
|
|
});
|