Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion libs/importer/src/importers/securesafe-csv-importer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";

import { SecureSafeCsvImporter } from "./securesafe-csv-importer";
import { data_upperUrl, data_lowerUrl } from "./spec-data/securesafe-csv/securesafe-example.csv";
import {
data_upperUrl,
data_lowerUrl,
data_website,
} from "./spec-data/securesafe-csv/securesafe-example.csv";

const CipherData = [
{
Expand Down Expand Up @@ -48,6 +52,27 @@ const CipherData = [
type: 1,
}),
},
{
title: "should parse new format with Website column",
csv: data_website,
expected: Object.assign(new CipherView(), {
id: null,
organizationId: null,
folderId: null,
name: "Gmail",
login: Object.assign(new LoginView(), {
username: "test@gmail.com",
password: "test",
uris: [
Object.assign(new LoginUriView(), {
uri: "https://gmail.com",
}),
],
}),
notes: null,
type: 1,
}),
},
];

describe("SecureSafe CSV Importer", () => {
Expand Down
4 changes: 2 additions & 2 deletions libs/importer/src/importers/securesafe-csv-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class SecureSafeCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}

// The url field can be in different case formats.
const urlField = Object.keys(results[0]).find((k) => /url/i.test(k));
// The url field can be in different case formats, and the new SecureSafe export uses "Website".
const urlField = Object.keys(results[0]).find((k) => /url|website/i.test(k));
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export const data_upperUrl = `"Title","Username","Password","URL","Comment"

export const data_lowerUrl = `"Title","Username","Password","url","Comment"
"Gmail","test@gmail.com","test","https://gmail.com"`;

export const data_website = `"Title","Username","Password","Website","Comment"
"Gmail","test@gmail.com","test","https://gmail.com"`;
Loading