mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
Calling processFolder method when adding ciphers on PsonoJsonImporter (#7984)
This commit is contained in:
parent
fda656afaa
commit
f9539ef68b
@ -230,10 +230,8 @@ describe("PSONO JSON Importer", () => {
|
||||
const result = await importer.parse(FoldersTestDataJson);
|
||||
expect(result != null).toBe(true);
|
||||
|
||||
const folders = result.folders;
|
||||
// // Check that ciphers have a folder assigned to them
|
||||
expect(result.ciphers.filter((c) => c.folderId === folders[0].id).length).toBeGreaterThan(0);
|
||||
expect(result.ciphers.filter((c) => c.folderId === folders[1].id).length).toBeGreaterThan(0);
|
||||
expect(result.ciphers.length).toEqual(result.folderRelationships.length);
|
||||
});
|
||||
|
||||
it("should create collections if part of an organization", async () => {
|
||||
|
@ -23,6 +23,24 @@ export const FoldersTestData: PsonoJsonExport = {
|
||||
callback_user: "callbackUser",
|
||||
callback_pass: "callbackPassword",
|
||||
},
|
||||
{
|
||||
type: "website_password",
|
||||
name: "TestEntry1.2",
|
||||
autosubmit: true,
|
||||
urlfilter: "filter",
|
||||
website_password_title: "TestEntry1.2",
|
||||
website_password_url: "bitwarden.com",
|
||||
website_password_username: "testUser",
|
||||
website_password_password: "testPassword",
|
||||
website_password_notes: "some notes",
|
||||
website_password_auto_submit: true,
|
||||
website_password_url_filter: "filter",
|
||||
create_date: "2022-12-13T19:24:09.810266Z",
|
||||
write_date: "2022-12-13T19:24:09.810292Z",
|
||||
callback_url: "callback",
|
||||
callback_user: "callbackUser",
|
||||
callback_pass: "callbackPassword",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -61,20 +61,22 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
|
||||
this.parseFolders(result, folder.folders, folder.name);
|
||||
}
|
||||
|
||||
this.processFolder(result, folder.name, folderHasItems);
|
||||
|
||||
this.handleItemParsing(result, folder.items);
|
||||
if (!folderHasItems) {
|
||||
this.processFolder(result, folder.name, folderHasItems);
|
||||
} else {
|
||||
this.handleItemParsing(result, folder.items, folder.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private handleItemParsing(result: ImportResult, items?: PsonoItemTypes[]) {
|
||||
private handleItemParsing(result: ImportResult, items?: PsonoItemTypes[], folderName?: string) {
|
||||
if (items == null || items.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach((record) => {
|
||||
const cipher = this.parsePsonoItem(record);
|
||||
|
||||
this.processFolder(result, folderName, true);
|
||||
this.cleanupCipher(cipher);
|
||||
result.ciphers.push(cipher);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user