feat: harden offline sync and add diagnostics
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package pl.firmatpp.kierowca.diagnostics
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class DiagnosticSnapshotProviderTest {
|
||||
@Test
|
||||
fun secureIdentifierSummaryDoesNotExposeWholeToken() {
|
||||
val token = "secret-session-token-123456"
|
||||
|
||||
val summary = secureIdentifierSummary(token)
|
||||
|
||||
assertFalse(summary.contains(token))
|
||||
assertTrue(summary.contains("długość ${token.length}"))
|
||||
assertTrue(summary.contains("końcówka …3456"))
|
||||
assertTrue(summary.contains("SHA-256"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun copiedReportExplainsThatCredentialsAreRedacted() {
|
||||
val snapshot = DiagnosticSnapshot(
|
||||
generatedAtEpochMillis = 1_700_000_000_000,
|
||||
sections = listOf(
|
||||
DiagnosticSection(
|
||||
title = "Sesja",
|
||||
entries = listOf(DiagnosticEntry("Token", secureIdentifierSummary("top-secret"))),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
val report = snapshot.asPlainText()
|
||||
|
||||
assertTrue(report.contains("[Sesja]"))
|
||||
assertTrue(report.contains("Token: obecny"))
|
||||
assertTrue(report.contains("nie zawiera danych pozwalających przejąć sesję"))
|
||||
assertFalse(report.contains("top-secret"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user