mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-27 04:04:43 +01:00
Get shared backup tests working.
This commit is contained in:
committed by
Nicholas Tinsley
parent
36640edfee
commit
7b0badef19
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -587,7 +587,7 @@ class ImportExportTest {
|
||||
)
|
||||
)
|
||||
import(importData)
|
||||
val exported = BackupRepository.export()
|
||||
val exported = BackupRepository.debugExport()
|
||||
val expected = exportFrames(
|
||||
*standardFrames,
|
||||
alexa
|
||||
@@ -1012,7 +1012,7 @@ class ImportExportTest {
|
||||
expirationNotStarted
|
||||
)
|
||||
import(importData)
|
||||
val exported = BackupRepository.export()
|
||||
val exported = BackupRepository.debugExport()
|
||||
val expected = exportFrames(
|
||||
*standardFrames,
|
||||
alice,
|
||||
@@ -1649,7 +1649,7 @@ class ImportExportTest {
|
||||
|
||||
import(originalBackupData)
|
||||
|
||||
val generatedBackupData = BackupRepository.export()
|
||||
val generatedBackupData = BackupRepository.debugExport()
|
||||
compare(originalBackupData, generatedBackupData)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.github.difflib.DiffUtils
|
||||
import com.github.difflib.UnifiedDiffUtils
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
@@ -26,7 +25,6 @@ import java.io.ByteArrayInputStream
|
||||
import java.util.UUID
|
||||
import kotlin.random.Random
|
||||
|
||||
@Ignore("Not passing yet")
|
||||
@RunWith(Parameterized::class)
|
||||
class ImportExportTestSuite(private val path: String) {
|
||||
companion object {
|
||||
@@ -41,8 +39,10 @@ class ImportExportTestSuite(private val path: String) {
|
||||
@JvmStatic
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
fun data(): Collection<Array<String>> {
|
||||
val testFiles = InstrumentationRegistry.getInstrumentation().context.resources.assets.list(TESTS_FOLDER)
|
||||
return testFiles?.map { arrayOf(it) }!!.toList()
|
||||
val testFiles = InstrumentationRegistry.getInstrumentation().context.resources.assets.list(TESTS_FOLDER)!!
|
||||
return testFiles
|
||||
.map { arrayOf(it) }
|
||||
.toList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,11 @@ class ImportExportTestSuite(private val path: String) {
|
||||
assertTrue(importResult is ImportResult.Success)
|
||||
val success = importResult as ImportResult.Success
|
||||
|
||||
val generatedBackupData = BackupRepository.export(plaintext = true, currentTime = success.backupTime)
|
||||
compare(binProtoBytes, generatedBackupData)
|
||||
val generatedBackupData = BackupRepository.debugExport(plaintext = true, currentTime = success.backupTime)
|
||||
|
||||
// TODO [backup] Currently fails, need to look into it
|
||||
// assertPassesValidator(generatedBackupData)
|
||||
assertEquivalent(binProtoBytes, generatedBackupData)
|
||||
}
|
||||
|
||||
private fun import(importData: ByteArray): ImportResult {
|
||||
@@ -78,7 +81,15 @@ class ImportExportTestSuite(private val path: String) {
|
||||
)
|
||||
}
|
||||
|
||||
private fun compare(import: ByteArray, export: ByteArray) {
|
||||
private fun assertPassesValidator(generatedBackupData: ByteArray) {
|
||||
BackupRepository.validate(
|
||||
length = generatedBackupData.size.toLong(),
|
||||
inputStreamFactory = { ByteArrayInputStream(generatedBackupData) },
|
||||
selfData = BackupRepository.SelfData(SELF_ACI, SELF_PNI, SELF_E164, SELF_PROFILE_KEY)
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertEquivalent(import: ByteArray, export: ByteArray) {
|
||||
val importComparable = ComparableBackup.readUnencrypted(MessageBackup.Purpose.REMOTE_BACKUP, import.inputStream(), import.size.toLong())
|
||||
val exportComparable = ComparableBackup.readUnencrypted(MessageBackup.Purpose.REMOTE_BACKUP, export.inputStream(), import.size.toLong())
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ object MessageTableTestUtils {
|
||||
isProfileChange:${type == MessageTypes.PROFILE_CHANGE_TYPE}
|
||||
isGroupV1MigrationEvent:${type == MessageTypes.GV1_MIGRATION_TYPE}
|
||||
isChangeNumber:${type == MessageTypes.CHANGE_NUMBER_TYPE}
|
||||
isBoostRequest:${type == MessageTypes.BOOST_REQUEST_TYPE}
|
||||
isDonationChannelDonationRequest:${type == MessageTypes.RELEASE_CHANNEL_DONATION_REQUEST_TYPE}
|
||||
isThreadMerge:${type == MessageTypes.THREAD_MERGE_TYPE}
|
||||
isSmsExport:${type == MessageTypes.SMS_EXPORT_TYPE}
|
||||
isGroupV2LeaveOnly:${type and MessageTypes.GROUP_V2_LEAVE_BITS == MessageTypes.GROUP_V2_LEAVE_BITS}
|
||||
|
||||
Reference in New Issue
Block a user