aboutsummaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/dev/msfjarvis/aps/data/password/PasswordEntryTest.kt34
1 files changed, 33 insertions, 1 deletions
diff --git a/app/src/test/java/dev/msfjarvis/aps/data/password/PasswordEntryTest.kt b/app/src/test/java/dev/msfjarvis/aps/data/password/PasswordEntryTest.kt
index a627dd7a..aab7d1d2 100644
--- a/app/src/test/java/dev/msfjarvis/aps/data/password/PasswordEntryTest.kt
+++ b/app/src/test/java/dev/msfjarvis/aps/data/password/PasswordEntryTest.kt
@@ -50,6 +50,38 @@ class PasswordEntryTest {
assertEquals("", makeEntry("").extraContent)
}
+ @Test fun parseExtraContentWithoutAuth() {
+ var entry = makeEntry("username: abc\npassword: abc\ntest: abcdef")
+ assertEquals(1, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("test"))
+ assertEquals("abcdef", entry.extraContentMap["test"])
+
+ entry = makeEntry("username: abc\npassword: abc\ntest: :abcdef:")
+ assertEquals(1, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("test"))
+ assertEquals(":abcdef:", entry.extraContentMap["test"])
+
+ entry = makeEntry("username: abc\npassword: abc\ntest : ::abc:def::")
+ assertEquals(1, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("test"))
+ assertEquals("::abc:def::", entry.extraContentMap["test"])
+
+ entry = makeEntry("username: abc\npassword: abc\ntest: abcdef\ntest2: ghijkl")
+ assertEquals(2, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("test2"))
+ assertEquals("ghijkl", entry.extraContentMap["test2"])
+
+ entry = makeEntry("username: abc\npassword: abc\ntest: abcdef\n: ghijkl\n mnopqr:")
+ assertEquals(2, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("Extra Content"))
+ assertEquals(": ghijkl\n mnopqr:", entry.extraContentMap["Extra Content"])
+
+ entry = makeEntry("username: abc\npassword: abc\n:\n\n")
+ assertEquals(1, entry.extraContentMap.size)
+ assertTrue(entry.extraContentMap.containsKey("Extra Content"))
+ assertEquals(":", entry.extraContentMap["Extra Content"])
+ }
+
@Test fun testGetUsername() {
for (field in PasswordEntry.USERNAME_FIELDS) {
assertEquals("username", makeEntry("\n$field username").username)
@@ -133,7 +165,7 @@ class PasswordEntryTest {
// This implementation is hardcoded for the URI above.
val testFinder = object : TotpFinder {
- override fun findSecret(content: String): String? {
+ override fun findSecret(content: String): String {
return "HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ"
}