Yokan / rebuild
Course 1 8624561

CrashReportStoreTest.kt

composeApp/src/commonTest/kotlin/eu/friedcutlet/yokan/services/logging/CrashReportStoreTest.kt

test / fixture34 lines
1package eu.friedcutlet.yokan.services.logging23import eu.friedcutlet.yokan.services.files.MemoryFiles4import kotlin.test.Test5import kotlin.test.assertEquals6import kotlin.test.assertFalse7import kotlin.test.assertNotNull8import kotlin.test.assertNull9import kotlin.test.assertTrue1011class CrashReportStoreTest {12    @Test13    fun persistsAndRedactsLatestReport() {14        val files = MemoryFiles()15        CrashReportStore.record(files, IllegalStateException("Authorization: Bearer secret-token"))1617        val report = CrashReportStore.read(files).orEmpty()18        assertTrue(report.contains("[REDACTED]"))19        assertFalse(report.contains("secret-token"))20    }2122    @Test23    fun malformedAndOversizedInputRemainsSafeAndBounded() {24        val files = MemoryFiles()25        CrashReportStore.record(files, Throwable("token=secret\u0000" + "x".repeat(100_000)))2627        assertTrue(CrashReportStore.read(files)!!.encodeToByteArray().size <= 32 * 1024)28        files.writeBytes("/cache/crash/latest.txt", byteArrayOf(0xC3.toByte()))29        assertNotNull(CrashReportStore.read(files))30        CrashReportStore.delete(files)31        assertNull(CrashReportStore.read(files))32        assertEquals("", CrashReportStore.redact(""))33    }34}35

Search chapters, reference and source filenames.