1package soy.iko.opencode.data.repo
3import org.junit.Assert.assertEquals
4import org.junit.Assert.assertFalse
5import org.junit.Assert.assertTrue
8class CrashLoggerScrubTest {
11 fun scrubUrls_replacesBareUrl() {
12 assertEquals("see [url] for details", CrashLogger.scrubUrls("see http://host:4096/path for details"))
16 fun scrubUrls_replacesUrlWithCredentials() {
17 // Ktor/OkHttp exception messages embed the full request URL, which may carry
18 // auth or internal paths — none of it may survive into a stored crash report.
19 val scrubbed = CrashLogger.scrubUrls("Bad response: GET https://u:se%20cret@10.0.0.2:4096/session/s%201/message")
20 assertFalse("password leaked: $scrubbed", scrubbed.contains("se%20cret"))
21 assertFalse("host leaked: $scrubbed", scrubbed.contains("10.0.0.2"))
22 assertTrue("redaction marker missing: $scrubbed", scrubbed.contains("[url]"))
26 fun scrubUrls_replacesEveryOccurrenceIncludingCausedBy() {
27 // printStackTrace re-emits the message on the top line and on each "Caused by:"
28 // line; the scrub must catch all of them, not just the first.
30 io.ktor.client.plugins.ClientRequestException: GET https://srv/event
32 Caused by: java.net.SocketTimeoutException: Request timeout https://srv/session
34 val scrubbed = CrashLogger.scrubUrls(report)
35 assertFalse(scrubbed.contains("https://"))
36 // Non-URL content (class names, stack frames) is preserved.
37 assertTrue(scrubbed.contains("ClientRequestException"))
38 assertTrue(scrubbed.contains("Foo.kt:1"))
42 fun scrubUrls_leavesPlainTextUntouched() {
43 val text = "opencode-android crash report\nAndroid: 14 (API 34)\nno urls here"
44 assertEquals(text, CrashLogger.scrubUrls(text))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list