aboutsummaryrefslogtreecommitdiff
path: root/format/common/src/test
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-03-26 01:41:31 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-03-26 01:41:31 +0530
commit17d4b803f74e393bd4626ababd2b0a2f0cdef16f (patch)
tree734ca3574a4a51c21f17d4538a288cc9a5cef4a5 /format/common/src/test
parent825c8af377cfa8d5e41959cded74299512c019e5 (diff)
fix(format/common): validate TOTP secret ahead of time
Fixes #2949
Diffstat (limited to 'format/common/src/test')
-rw-r--r--format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt8
1 files changed, 8 insertions, 0 deletions
diff --git a/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt
index 865a13c1..95fb3e62 100644
--- a/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt
+++ b/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt
@@ -13,6 +13,7 @@ import app.passwordstore.util.totp.UriTotpFinder
import java.util.Locale
import kotlin.test.Test
import kotlin.test.assertEquals
+import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
@@ -181,6 +182,13 @@ class PasswordEntryTest {
}
}
+ // https://github.com/android-password-store/Android-Password-Store/issues/2949
+ @Test
+ fun disablesTotpForInvalidUri() = runTest {
+ val entry = makeEntry("password\notpauth://totp/otp-secret?secret=")
+ assertFalse(entry.hasTotp())
+ }
+
@Test
fun onlyLooksForUriInFirstLine() {
val entry = makeEntry("id:\n$TOTP_URI")