mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[PM-3100] Fixes imports of "reduced" psono data (#5859)
* Fixes imports of "reduced" psono data * Fix typo in file name --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
parent
708eb21a49
commit
f2df456516
@ -11,6 +11,7 @@ import { EnvVariablesData } from "./test-data/psono-json/environment-variables";
|
||||
import { FoldersTestData } from "./test-data/psono-json/folders";
|
||||
import { GPGData } from "./test-data/psono-json/gpg";
|
||||
import { NotesData } from "./test-data/psono-json/notes";
|
||||
import { ReducedWebsiteLoginsData } from "./test-data/psono-json/reduced-website-logins";
|
||||
import { TOTPData } from "./test-data/psono-json/totp";
|
||||
import { WebsiteLoginsData } from "./test-data/psono-json/website-logins";
|
||||
|
||||
@ -23,6 +24,7 @@ function validateCustomField(
|
||||
expect(fields).not.toBeUndefined();
|
||||
const customField = fields.find((f) => f.name === fieldName);
|
||||
expect(customField).not.toBeNull();
|
||||
expect(customField).not.toBeUndefined();
|
||||
|
||||
expect(customField.value).toEqual(expectedValue);
|
||||
expect(customField.type).toEqual(fieldType);
|
||||
@ -38,6 +40,7 @@ describe("PSONO JSON Importer", () => {
|
||||
const FoldersTestDataJson = JSON.stringify(FoldersTestData);
|
||||
const GPGDataJson = JSON.stringify(GPGData);
|
||||
const EnvVariablesDataJson = JSON.stringify(EnvVariablesData);
|
||||
const ReducedWebsiteLoginsDataJson = JSON.stringify(ReducedWebsiteLoginsData);
|
||||
|
||||
it("should parse Website/Password data", async () => {
|
||||
const importer = new PsonoJsonImporter();
|
||||
@ -64,6 +67,23 @@ describe("PSONO JSON Importer", () => {
|
||||
validateCustomField(cipher.fields, "callback_user", "callbackUser");
|
||||
validateCustomField(cipher.fields, "callback_pass", "callbackPassword");
|
||||
});
|
||||
it("should parse Website/Password data with missing fields", async () => {
|
||||
const importer = new PsonoJsonImporter();
|
||||
const result = await importer.parse(ReducedWebsiteLoginsDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
const cipher = result.ciphers.shift();
|
||||
|
||||
expect(cipher.type).toEqual(CipherType.Login);
|
||||
expect(cipher.name).toEqual("export_website_1");
|
||||
expect(cipher.login.username).toEqual("username123");
|
||||
expect(cipher.login.password).toEqual("password123");
|
||||
expect(cipher.login.uris).toEqual(null);
|
||||
|
||||
expect(cipher.fields.length).toBe(2);
|
||||
validateCustomField(cipher.fields, "create_date", "2022-09-10T23:05:02.351417Z");
|
||||
validateCustomField(cipher.fields, "write_date", "2022-09-10T23:05:02.351583Z");
|
||||
});
|
||||
|
||||
it("should parse Application Password data", async () => {
|
||||
const importer = new PsonoJsonImporter();
|
||||
|
@ -0,0 +1,21 @@
|
||||
import { PsonoJsonExport } from "../../../src/importers/psono/psono-json-types";
|
||||
|
||||
export const ReducedWebsiteLoginsData: PsonoJsonExport = {
|
||||
folders: [],
|
||||
items: [
|
||||
{
|
||||
type: "website_password",
|
||||
name: "export_website_name",
|
||||
website_password_password: "password123",
|
||||
website_password_username: "username123",
|
||||
website_password_notes: "",
|
||||
website_password_url: "",
|
||||
website_password_title: "export_website_1",
|
||||
create_date: "2022-09-10T23:05:02.351417Z",
|
||||
write_date: "2022-09-10T23:05:02.351583Z",
|
||||
callback_url: "",
|
||||
callback_user: "",
|
||||
callback_pass: "",
|
||||
},
|
||||
],
|
||||
};
|
@ -131,7 +131,7 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
|
||||
this.processKvp(
|
||||
cipher,
|
||||
"website_password_auto_submit",
|
||||
entry.website_password_auto_submit.toString(),
|
||||
entry.website_password_auto_submit?.toString(),
|
||||
FieldType.Boolean
|
||||
);
|
||||
|
||||
|
@ -38,15 +38,15 @@ export type PsonoEntryTypes =
|
||||
|
||||
export interface WebsitePasswordEntry extends RecordBase {
|
||||
type: "website_password";
|
||||
autosubmit: boolean;
|
||||
urlfilter: string;
|
||||
autosubmit?: boolean;
|
||||
urlfilter?: string;
|
||||
website_password_title: string;
|
||||
website_password_url: string;
|
||||
website_password_username: string;
|
||||
website_password_password: string;
|
||||
website_password_notes: string;
|
||||
website_password_auto_submit: boolean;
|
||||
website_password_url_filter: string;
|
||||
website_password_auto_submit?: boolean;
|
||||
website_password_url_filter?: string;
|
||||
}
|
||||
|
||||
export interface PsonoEntry {
|
||||
|
Loading…
Reference in New Issue
Block a user