package com.peachpasswords.ui.vault import org.junit.Assume.assumeTrue import com.peachpasswords.vault.PeachScript import org.junit.Test import java.io.File import org.junit.Assert.assertTrue /** * Decode-path check against a real, full-size PeachScript backup rather than a * toy fixture. The small round-trip fixtures all passed while a real export * (262k PUA characters) failed in the app, so size itself is the variable * worth covering. * * Skips when the file isn't present — it's a local artifact, never committed * (it's an encrypted vault backup). */ class RealBackupDecodeTest { private val backup = File(System.getProperty("user.home"), "Downloads/peach-backup-2026-07-24.peach") @Test fun real_backup_is_recognised_and_decodes_to_bytes() { assumeTrue("no local backup artifact", backup.exists()) val text = backup.readText() println("chars=${text.length}") assertTrue("looksLikePeachScript rejected a real export", PeachScriptImport.looksLikePeachScript(text)) val normalised = PeachScript.normalise(text) assertTrue("normalise broke the sniff", PeachScript.isPeachScript(normalised)) // Decrypting needs the backup password, which we don't have — but // decode() is the whole pre-crypto path and is where size would bite. val bytes = PeachScript.decode(normalised) println("decoded bytes=${bytes.size}") assertTrue("decoded to nothing", bytes.isNotEmpty()) } @Test fun wrong_password_is_reported_as_wrong_not_corrupted() { assumeTrue("no local backup artifact", backup.exists()) val result = PeachScriptImport.decryptAndParse(backup.readText(), "definitely-not-the-password") println("result=$result") assertTrue( "a real export with a bad password should report WrongPassword, got $result", result is PeachScriptImport.DecryptResult.WrongPassword, ) } }