Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update test logic to not use otherwise unused methods (#2413)

Leendert de Borst91626760132a
diff --git a/core/client/src/database/__tests__/SharedManifestRendering.test.ts b/core/client/src/database/__tests__/SharedManifestRendering.test.ts
index 33e132d6f..8c2bb0b76 100644
--- a/core/client/src/database/__tests__/SharedManifestRendering.test.ts
+++ b/core/client/src/database/__tests__/SharedManifestRendering.test.ts
@@ -94,6 +94,6 @@ describe('a shared manifest rendered as a folder', () => {
await client.items.create(draftItem('Mine', PERSONAL, null));
expect(client.items.getAll().map(item => item.Name).sort()).toEqual(['Mine', 'Netflix']);
- expect(client.items.getAllInManifest(PERSONAL).map(item => item.Name)).toEqual(['Mine']);
+ expect(client.importExport.getExportData().items.map(item => item.Name)).toEqual(['Mine']);
});
});
diff --git a/core/client/src/database/queries/ItemQueries.ts b/core/client/src/database/queries/ItemQueries.ts
index 13210b9ea..c8cb1d166 100644
--- a/core/client/src/database/queries/ItemQueries.ts
+++ b/core/client/src/database/queries/ItemQueries.ts
@@ -41,14 +41,6 @@ export class ItemQueries {
WHERE i.IsDeleted = 0 AND i.DeletedAt IS NULL AND i.ArchivedAt IS NULL
ORDER BY i.CreatedAt DESC`;
- /**
- * Get the active items of one manifest.
- */
- public static readonly GET_ALL_ACTIVE_IN_MANIFEST = `
- ${ItemQueries.BASE_SELECT}
- WHERE i.IsDeleted = 0 AND i.DeletedAt IS NULL AND i.ArchivedAt IS NULL AND i.ManifestId = ?
- ORDER BY i.CreatedAt DESC`;
-
/**
* Get the active items of one folder, matched on the folder's whole key.
*/
diff --git a/core/client/src/database/repositories/ItemRepository.ts b/core/client/src/database/repositories/ItemRepository.ts
index 169e02984..2dbccd2ad 100644
--- a/core/client/src/database/repositories/ItemRepository.ts
+++ b/core/client/src/database/repositories/ItemRepository.ts
@@ -97,16 +97,6 @@ export class ItemRepository extends BaseRepository {
return yield* this.hydrateItems(itemRows);
}
- /**
- * Fetch the active items of one manifest with their dynamic fields and tags.
- * @param manifestId - The manifest to read
- * @returns Array of Item objects
- */
- public *getAllInManifest(manifestId: string): DbOp<Item[]> {
- const itemRows = yield* this.selectItemRows(ItemQueries.GET_ALL_ACTIVE_IN_MANIFEST, [manifestId]);
- return yield* this.hydrateItems(itemRows);
- }
-
/**
* Fetch the active items of one folder with their dynamic fields and tags.
* @param folder - The folder to read
diff --git a/core/client/src/transfer/export/__tests__/AliasVaultCsvExportService.test.ts b/core/client/src/transfer/export/__tests__/AliasVaultCsvExportService.test.ts
index 9ed2b6ab7..af50ae6fa 100644
--- a/core/client/src/transfer/export/__tests__/AliasVaultCsvExportService.test.ts
+++ b/core/client/src/transfer/export/__tests__/AliasVaultCsvExportService.test.ts
@@ -1,9 +1,8 @@
import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { byName, itemByName, utc } from '../../import/__tests__/testHelpers';
+import { byName, convertToItems, itemByName, utc } from '../../import/__tests__/testHelpers';
import { AliasVaultCsvImportService } from '../../import/importers/aliasvault/AliasVaultCsvImportService';
-import { convertToItems } from '../../import/writers/ItemConverter';
import { AliasVaultCsvExportService } from '../AliasVaultCsvExportService';
import { addFieldValue, addTotpCode, createTestItem, csvText } from './testHelpers';
diff --git a/core/client/src/transfer/export/__tests__/AvuxExportService.test.ts b/core/client/src/transfer/export/__tests__/AvuxExportService.test.ts
index 069abcf81..1f0f966c3 100644
--- a/core/client/src/transfer/export/__tests__/AvuxExportService.test.ts
+++ b/core/client/src/transfer/export/__tests__/AvuxExportService.test.ts
@@ -1,9 +1,8 @@
import { FieldKey, FieldTypes, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { byName, itemByName } from '../../import/__tests__/testHelpers';
+import { byName, convertToItems, itemByName } from '../../import/__tests__/testHelpers';
import { AvuxImportService } from '../../import/importers/aliasvault/AvuxImportService';
-import { convertToItems } from '../../import/writers/ItemConverter';
import { ZipArchive } from '../../shared/ZipArchive';
import { AvuxExportService } from '../AvuxExportService';
diff --git a/core/client/src/transfer/import/__tests__/testHelpers.ts b/core/client/src/transfer/import/__tests__/testHelpers.ts
index dae88864a..760857c45 100644
--- a/core/client/src/transfer/import/__tests__/testHelpers.ts
+++ b/core/client/src/transfer/import/__tests__/testHelpers.ts
@@ -1,6 +1,8 @@
import { readFileSync } from 'node:fs';
import path from 'node:path';
+import { convertToItem } from '../writers/ItemConverter';
+
import type { ItemEntity } from '../../shared/VaultEntities';
import type { ImportedCredential } from '../models/ImportedCredential';
@@ -56,6 +58,16 @@ export function itemByName(items: ItemEntity[], name: string): ItemEntity {
return item;
}
+/**
+ * Convert imported credentials to vault items, the way the import writer does one by one.
+ * @param credentials - The imported credentials
+ * @param folderPathToId - Folder paths to folder ids, or null
+ * @returns The items
+ */
+export function convertToItems(credentials: ImportedCredential[], folderPathToId: Map<string, string> | null = null): ItemEntity[] {
+ return credentials.map(credential => convertToItem(credential, folderPathToId));
+}
+
/**
* A UTC date.
* @param year - Year
diff --git a/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenCsvImporter.test.ts b/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenCsvImporter.test.ts
index f1ec638a0..edfb92416 100644
--- a/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenCsvImporter.test.ts
+++ b/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenCsvImporter.test.ts
@@ -2,9 +2,8 @@ import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it, vi } from 'vitest';
import { parseFolderPath } from '../../../../shared/FolderPaths';
-import { readFixtureText, byName, itemByName } from '../../../__tests__/testHelpers';
+import { byName, convertToItems, itemByName, readFixtureText } from '../../../__tests__/testHelpers';
import { collectHierarchicalFolderPaths } from '../../../writers/ImportDuplicateDetection';
-import { convertToItems } from '../../../writers/ItemConverter';
import { importBitwardenCsv } from '../BitwardenCsvImporter';
import type { ImportedCredential } from '../../../models/ImportedCredential';
diff --git a/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenZipImporter.test.ts b/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenZipImporter.test.ts
index 74e8e235a..60c3ea5c3 100644
--- a/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenZipImporter.test.ts
+++ b/core/client/src/transfer/import/importers/bitwarden/__tests__/BitwardenZipImporter.test.ts
@@ -2,9 +2,8 @@ import { FieldTypes, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
import { createZipArchive, textToZipBytes } from '../../../../shared/ZipArchive';
-import { readFixtureBytes, byName, itemByName } from '../../../__tests__/testHelpers';
+import { byName, convertToItems, itemByName, readFixtureBytes } from '../../../__tests__/testHelpers';
import { ImportException, ImportStage } from '../../../models/ImportException';
-import { convertToItems } from '../../../writers/ItemConverter';
import { importBitwardenZip } from '../BitwardenZipImporter';
describe('BitwardenZipImporter', () => {
diff --git a/core/client/src/transfer/import/importers/enpass/__tests__/EnpassCsvImporter.test.ts b/core/client/src/transfer/import/importers/enpass/__tests__/EnpassCsvImporter.test.ts
index 86d1698ef..9df5dbeb1 100644
--- a/core/client/src/transfer/import/importers/enpass/__tests__/EnpassCsvImporter.test.ts
+++ b/core/client/src/transfer/import/importers/enpass/__tests__/EnpassCsvImporter.test.ts
@@ -1,8 +1,7 @@
import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureText, byName, utc } from '../../../__tests__/testHelpers';
-import { convertToItems } from '../../../writers/ItemConverter';
+import { byName, convertToItems, readFixtureText, utc } from '../../../__tests__/testHelpers';
import { importEnpassCsv } from '../EnpassCsvImporter';
describe('EnpassCsvImporter', () => {
diff --git a/core/client/src/transfer/import/importers/lastpass/__tests__/LastPassCsvImporter.test.ts b/core/client/src/transfer/import/importers/lastpass/__tests__/LastPassCsvImporter.test.ts
index 8c3578118..53a4965fd 100644
--- a/core/client/src/transfer/import/importers/lastpass/__tests__/LastPassCsvImporter.test.ts
+++ b/core/client/src/transfer/import/importers/lastpass/__tests__/LastPassCsvImporter.test.ts
@@ -1,8 +1,7 @@
import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureText, byName, itemByName } from '../../../__tests__/testHelpers';
-import { convertToItems } from '../../../writers/ItemConverter';
+import { byName, convertToItems, itemByName, readFixtureText } from '../../../__tests__/testHelpers';
import { importLastPassCsv } from '../LastPassCsvImporter';
describe('LastPassCsvImporter', () => {
diff --git a/core/client/src/transfer/import/importers/nordpass/__tests__/NordPassCsvImporter.test.ts b/core/client/src/transfer/import/importers/nordpass/__tests__/NordPassCsvImporter.test.ts
index f8561b1d7..50bc8019a 100644
--- a/core/client/src/transfer/import/importers/nordpass/__tests__/NordPassCsvImporter.test.ts
+++ b/core/client/src/transfer/import/importers/nordpass/__tests__/NordPassCsvImporter.test.ts
@@ -1,9 +1,8 @@
import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureText, byName } from '../../../__tests__/testHelpers';
+import { byName, convertToItems, readFixtureText } from '../../../__tests__/testHelpers';
import { collectHierarchicalFolderPaths } from '../../../writers/ImportDuplicateDetection';
-import { convertToItems } from '../../../writers/ItemConverter';
import { importNordPassCsv } from '../NordPassCsvImporter';
describe('NordPassCsvImporter', () => {
diff --git a/core/client/src/transfer/import/importers/onepassword/__tests__/OnePassword1puxImporter.test.ts b/core/client/src/transfer/import/importers/onepassword/__tests__/OnePassword1puxImporter.test.ts
index a30a9946e..d51844269 100644
--- a/core/client/src/transfer/import/importers/onepassword/__tests__/OnePassword1puxImporter.test.ts
+++ b/core/client/src/transfer/import/importers/onepassword/__tests__/OnePassword1puxImporter.test.ts
@@ -1,8 +1,7 @@
import { ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureBytes, byName, itemByName } from '../../../__tests__/testHelpers';
-import { convertToItems } from '../../../writers/ItemConverter';
+import { byName, convertToItems, itemByName, readFixtureBytes } from '../../../__tests__/testHelpers';
import { importOnePassword1pux } from '../OnePassword1puxImporter';
describe('OnePassword1puxImporter', () => {
diff --git a/core/client/src/transfer/import/importers/protonpass/__tests__/ProtonPassZipImporter.test.ts b/core/client/src/transfer/import/importers/protonpass/__tests__/ProtonPassZipImporter.test.ts
index 9a58073b1..63a4c2911 100644
--- a/core/client/src/transfer/import/importers/protonpass/__tests__/ProtonPassZipImporter.test.ts
+++ b/core/client/src/transfer/import/importers/protonpass/__tests__/ProtonPassZipImporter.test.ts
@@ -1,8 +1,7 @@
import { ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureBytes, byName, itemByName } from '../../../__tests__/testHelpers';
-import { convertToItems } from '../../../writers/ItemConverter';
+import { byName, convertToItems, itemByName, readFixtureBytes } from '../../../__tests__/testHelpers';
import { importProtonPassZip } from '../ProtonPassZipImporter';
describe('ProtonPassZipImporter', () => {
diff --git a/core/client/src/transfer/import/importers/roboform/__tests__/RoboformCsvImporter.test.ts b/core/client/src/transfer/import/importers/roboform/__tests__/RoboformCsvImporter.test.ts
index 88d38e20b..49e253113 100644
--- a/core/client/src/transfer/import/importers/roboform/__tests__/RoboformCsvImporter.test.ts
+++ b/core/client/src/transfer/import/importers/roboform/__tests__/RoboformCsvImporter.test.ts
@@ -1,9 +1,8 @@
import { FieldKey, ItemTypes } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { readFixtureText, byName, itemByName } from '../../../__tests__/testHelpers';
+import { byName, convertToItems, itemByName, readFixtureText } from '../../../__tests__/testHelpers';
import { collectHierarchicalFolderPaths } from '../../../writers/ImportDuplicateDetection';
-import { convertToItems } from '../../../writers/ItemConverter';
import { importRoboformCsv } from '../RoboformCsvImporter';
describe('RoboformCsvImporter', () => {
diff --git a/core/client/src/transfer/import/writers/ItemConverter.ts b/core/client/src/transfer/import/writers/ItemConverter.ts
index f6f19b895..666808c79 100644
--- a/core/client/src/transfer/import/writers/ItemConverter.ts
+++ b/core/client/src/transfer/import/writers/ItemConverter.ts
@@ -9,16 +9,6 @@ import { sanitizeTotpSecretKey } from './TotpHelper';
import type { FieldDefinitionEntity, ItemEntity, TotpCodeEntity } from '../../shared/VaultEntities';
import type { ImportedCredential } from '../models/ImportedCredential';
-/**
- * Convert imported credentials to vault items.
- * @param credentials - The imported credentials
- * @param folderPathToId - Folder paths to folder ids, or null
- * @returns The items
- */
-export function convertToItems(credentials: ImportedCredential[], folderPathToId?: Map<string, string> | null): ItemEntity[] {
- return credentials.map(credential => convertToItem(credential, folderPathToId ?? null));
-}
-
/**
* Convert one imported credential to a vault item with all its child fields.
* @param credential - The imported credential
diff --git a/core/client/src/transfer/import/writers/__tests__/ItemConverter.test.ts b/core/client/src/transfer/import/writers/__tests__/ItemConverter.test.ts
index a2811daa6..79d5059c5 100644
--- a/core/client/src/transfer/import/writers/__tests__/ItemConverter.test.ts
+++ b/core/client/src/transfer/import/writers/__tests__/ItemConverter.test.ts
@@ -1,12 +1,11 @@
import { TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD } from '@aliasvault/models/vault';
import { describe, expect, it } from 'vitest';
-import { itemByName } from '../../__tests__/testHelpers';
-import { convertToItems } from '../ItemConverter';
+import { convertToItems, itemByName } from '../../__tests__/testHelpers';
import type { ImportedCredential } from '../../models/ImportedCredential';
-describe('convertToItems', () => {
+describe('convertToItem', () => {
it('keeps the TOTP parameters of an imported otpauth URI', () => {
const credentials: ImportedCredential[] = [
{ ServiceName: 'Sha512Service', TwoFactorSecret: 'otpauth://totp/Sha512Service:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Sha512Service&algorithm=SHA512&digits=8&period=60' },