diff options
Diffstat (limited to 'app/src/androidTest/java')
-rw-r--r-- | app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java | 18 | ||||
-rw-r--r-- | app/src/androidTest/java/com/zeapo/pwdstore/TotpTest.java | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java b/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java index 66636b1b..e8ddc04c 100644 --- a/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java +++ b/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java @@ -41,4 +41,22 @@ public class PasswordEntryTest extends TestCase { assertFalse(new PasswordEntry("\n").hasUsername()); assertFalse(new PasswordEntry("").hasUsername()); } + + public void testNoTotpUriPresent() { + PasswordEntry entry = new PasswordEntry("secret\nextra\nlogin: username\ncontent"); + assertFalse(entry.hasTotp()); + assertNull(entry.getTotpSecret()); + } + + public void testTotpUriInPassword() { + PasswordEntry entry = new PasswordEntry("otpauth://totp/test?secret=JBSWY3DPEHPK3PXP"); + assertTrue(entry.hasTotp()); + assertEquals("JBSWY3DPEHPK3PXP", entry.getTotpSecret()); + } + + public void testTotpUriInContent() { + PasswordEntry entry = new PasswordEntry("secret\nusername: test\notpauth://totp/test?secret=JBSWY3DPEHPK3PXP"); + assertTrue(entry.hasTotp()); + assertEquals("JBSWY3DPEHPK3PXP", entry.getTotpSecret()); + } }
\ No newline at end of file diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/TotpTest.java b/app/src/androidTest/java/com/zeapo/pwdstore/TotpTest.java new file mode 100644 index 00000000..500644d1 --- /dev/null +++ b/app/src/androidTest/java/com/zeapo/pwdstore/TotpTest.java @@ -0,0 +1,12 @@ +package com.zeapo.pwdstore; + +import com.zeapo.pwdstore.utils.Totp; + +import junit.framework.TestCase; + +public class TotpTest extends TestCase { + public void testTotp() { + String code = Totp.calculateCode("JBSWY3DPEHPK3PXP", 0L); + assertEquals("282760", code); + } +} |