Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make db init test work (#771)
Leendert de Borstcb61b7355382
diff --git a/mobile-app/ios/VaultStoreTests/VaultStoreTests.swift b/mobile-app/ios/VaultStoreTests/VaultStoreTests.swiftindex e43dfd3fd..e265e95ee 100644--- a/mobile-app/ios/VaultStoreTests/VaultStoreTests.swift+++ b/mobile-app/ios/VaultStoreTests/VaultStoreTests.swift@@ -2,7 +2,7 @@ import XCTestclass VaultStoreTests: XCTestCase {var vaultStore: VaultStore!- let testEncryptionKey = "testEncryptionKey1234567890123456789012" // 32 bytes for AES-256+ let testEncryptionKeyBase64 = "qXcA7cJMA9gN0gfrvlbGL8/iUcay1ihT32N8i33DR/U=" // 32 bytes for AES-256override func setUp() {super.setUp()@@ -17,7 +17,12 @@ class VaultStoreTests: XCTestCase {func testDatabaseInitialization() async throws {// First, store the encryption key- try vaultStore.storeEncryptionKey(base64Key: testEncryptionKey)+ try vaultStore.storeEncryptionKey(base64Key: testEncryptionKeyBase64)++ // Load and store the encrypted database+ let encryptedDb = try loadTestDatabase()+ // TODO: get metadata via vault generation and pass it here so we have all info we need for all tests.+ try vaultStore.storeEncryptedDatabase(encryptedDb, metadata: "")// Then try to initialize the databasetry vaultStore.initializeDatabase()@@ -28,8 +33,13 @@ class VaultStoreTests: XCTestCase {func testGetAllCredentials() async throws {// First, store the encryption key- try vaultStore.storeEncryptionKey(base64Key: testEncryptionKey)+ try vaultStore.storeEncryptionKey(base64Key: testEncryptionKeyBase64)+ // Load and store the encrypted database+ let encryptedDb = try loadTestDatabase()+ // TODO: get metadata via vault generation and pass it here so we have all info we need for all tests.+ try vaultStore.storeEncryptedDatabase(encryptedDb, metadata: "")+// Initialize the databasetry vaultStore.initializeDatabase()@@ -48,12 +58,15 @@ class VaultStoreTests: XCTestCase {}// Helper method to load test database file- private func loadTestDatabase() throws -> Data {- // TODO: Add your test database file to the test bundle- // and load it here- guard let testDbPath = Bundle(for: type(of: self)).path(forResource: "test_db", ofType: "sqlite") else {- throw NSError(domain: "VaultStoreTests", code: 1, userInfo: [NSLocalizedDescriptionKey: "Test database file not found"])+ private func loadTestDatabase() throws -> String {+ // Look in the root of the test bundle Resources+ guard let testDbPath = Bundle(for: type(of: self))+ .path(forResource: "test-encrypted-vault", ofType: "txt")+ else {+ throw NSError(domain: "VaultStoreTests",+ code: 1,+ userInfo: [NSLocalizedDescriptionKey: "Test database file not found"])}- return try Data(contentsOf: URL(fileURLWithPath: testDbPath))+ return try String(contentsOfFile: testDbPath, encoding: .utf8)}}diff --git a/mobile-app/ios/aliasvault.xcodeproj/project.pbxproj b/mobile-app/ios/aliasvault.xcodeproj/project.pbxprojindex ef8a6b62b..1fa2ea581 100644--- a/mobile-app/ios/aliasvault.xcodeproj/project.pbxproj+++ b/mobile-app/ios/aliasvault.xcodeproj/project.pbxproj@@ -3,7 +3,7 @@archiveVersion = 1;classes = {};- objectVersion = 60;+ objectVersion = 70;objects = {/* Begin PBXBuildFile section */@@ -94,7 +94,7 @@/* End PBXFileReference section *//* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */- CE9A5BBB2DBBB60D00CB0A4C /* Exceptions for "Models" folder in "VaultStoreTests" target */ = {+ CE9A5BBB2DBBB60D00CB0A4C /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {isa = PBXFileSystemSynchronizedBuildFileExceptionSet;membershipExceptions = (AuthMethods.swift,@@ -102,7 +102,7 @@);target = CE9A5BAF2DBBB47200CB0A4C /* VaultStoreTests */;};- CEE9098F2DA548C7008D568F /* Exceptions for "Autofill" folder in "Autofill" target */ = {+ CEE9098F2DA548C7008D568F /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {isa = PBXFileSystemSynchronizedBuildFileExceptionSet;membershipExceptions = (Info.plist,@@ -112,41 +112,9 @@/* End PBXFileSystemSynchronizedBuildFileExceptionSet section *//* Begin PBXFileSystemSynchronizedRootGroup section */- CE9A5B592DBAE06400CB0A4C /* Models */ = {- isa = PBXFileSystemSynchronizedRootGroup;- exceptions = (- CE9A5BBB2DBBB60D00CB0A4C /* Exceptions for "Models" folder in "VaultStoreTests" target */,- );- explicitFileTypes = {- };- explicitFolders = (- );- path = Models;- sourceTree = "<group>";- };- CE9A5BB12DBBB47200CB0A4C /* VaultStoreTests */ = {- isa = PBXFileSystemSynchronizedRootGroup;- exceptions = (- );- explicitFileTypes = {- };- explicitFolders = (- );- path = VaultStoreTests;- sourceTree = "<group>";- };- CEE909812DA548C7008D568F /* Autofill */ = {- isa = PBXFileSystemSynchronizedRootGroup;- exceptions = (- CEE9098F2DA548C7008D568F /* Exceptions for "Autofill" folder in "Autofill" target */,- );- explicitFileTypes = {- };- explicitFolders = (- );- path = Autofill;- sourceTree = "<group>";- };+ CE9A5B592DBAE06400CB0A4C /* Models */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (CE9A5BBB2DBBB60D00CB0A4C /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = Models; sourceTree = "<group>"; };+ CE9A5BB12DBBB47200CB0A4C /* VaultStoreTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = VaultStoreTests; sourceTree = "<group>"; };+ CEE909812DA548C7008D568F /* Autofill */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (CEE9098F2DA548C7008D568F /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = Autofill; sourceTree = "<group>"; };/* End PBXFileSystemSynchronizedRootGroup section *//* Begin PBXFrameworksBuildPhase section */@@ -788,10 +756,7 @@LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift\"$(inherited)\"";MTL_ENABLE_DEBUG_INFO = YES;ONLY_ACTIVE_ARCH = YES;- OTHER_LDFLAGS = (- "$(inherited)",- " ",- );+ OTHER_LDFLAGS = "$(inherited) ";REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";SDKROOT = iphoneos;SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";@@ -846,10 +811,7 @@);LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift\"$(inherited)\"";MTL_ENABLE_DEBUG_INFO = NO;- OTHER_LDFLAGS = (- "$(inherited)",- " ",- );+ OTHER_LDFLAGS = "$(inherited) ";REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";SDKROOT = iphoneos;USE_HERMES = true;diff --git a/src/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.csindex d0cfeeafb..6058d7801 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs@@ -134,7 +134,7 @@ public class TestVaultGeneratorTests : BrowserExtensionPlaywrightTest// Ensure the output directory existsDirectory.CreateDirectory(vaultOutputDir);- var tempVaultPath = Path.Combine(vaultOutputDir, "test-vault.encrypted.blob");+ var tempVaultPath = Path.Combine(vaultOutputDir, "test-encrypted-vault.txt");await File.WriteAllTextAsync(tempVaultPath, vault.VaultBlob);// Generate the decryption key using the same method as the login page