// // Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only // #if TESTABLE_BUILD import Foundation public import LibSignalClient open class MessageBackupManagerMock: MessageBackupManager { public func downloadEncryptedBackup( localIdentifiers: LocalIdentifiers, auth: ChatServiceAuth ) async throws -> URL { return URL(string: "file://")! } public func uploadEncryptedBackup( metadata: Upload.EncryptedBackupUploadMetadata, localIdentifiers: LocalIdentifiers, auth: ChatServiceAuth ) async throws -> Upload.Result { return Upload.Result( cdnKey: "cdnKey", cdnNumber: 1, localUploadMetadata: .init( fileUrl: URL(string: "file://")!, digest: Data(), encryptedDataLength: 0, plaintextDataLength: 0), beginTimestamp: 0, finishTimestamp: Date().ows_millisecondsSince1970 ) } public func exportEncryptedBackup( localIdentifiers: LocalIdentifiers, backupKey: BackupKey, backupPurpose: MessageBackupPurpose, progress: OWSProgressSink? ) async throws -> Upload.EncryptedBackupUploadMetadata { let source = await progress?.addSource(withLabel: "", unitCount: 1) source?.incrementCompletedUnitCount(by: 1) return Upload.EncryptedBackupUploadMetadata( fileUrl: URL(string: "file://")!, digest: Data(), encryptedDataLength: 0, plaintextDataLength: 0 ) } public func exportPlaintextBackup( localIdentifiers: LocalIdentifiers, backupPurpose: MessageBackupPurpose, progress: OWSProgressSink? ) async throws -> URL { let source = await progress?.addSource(withLabel: "", unitCount: 1) source?.incrementCompletedUnitCount(by: 1) return URL(string: "file://")! } public func hasRestoredFromBackup(tx: DBReadTransaction) -> Bool { false } public func importEncryptedBackup( fileUrl: URL, localIdentifiers: LocalIdentifiers, backupKey: BackupKey, progress: OWSProgressSink? ) async throws { let source = await progress?.addSource(withLabel: "", unitCount: 1) source?.incrementCompletedUnitCount(by: 1) } public func importPlaintextBackup( fileUrl: URL, localIdentifiers: LocalIdentifiers, progress: OWSProgressSink? ) async throws { let source = await progress?.addSource(withLabel: "", unitCount: 1) source?.incrementCompletedUnitCount(by: 1) } public func validateEncryptedBackup( fileUrl: URL, localIdentifiers: LocalIdentifiers, backupKey: BackupKey, backupPurpose: MessageBackupPurpose ) async throws {} } #endif