diff options
Diffstat (limited to 'app/src/androidTest')
3 files changed, 33 insertions, 12 deletions
diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/OtpTest.java b/app/src/androidTest/java/com/zeapo/pwdstore/OtpTest.java new file mode 100644 index 00000000..e48f1ab6 --- /dev/null +++ b/app/src/androidTest/java/com/zeapo/pwdstore/OtpTest.java @@ -0,0 +1,12 @@ +package com.zeapo.pwdstore; + +import com.zeapo.pwdstore.utils.Otp; + +import junit.framework.TestCase; + +public class OtpTest extends TestCase { + public void testOtp() { + String code = Otp.calculateCode("JBSWY3DPEHPK3PXP", 0L); + assertEquals("282760", code); + } +} diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java b/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java index e8ddc04c..3df296fe 100644 --- a/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java +++ b/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java @@ -59,4 +59,25 @@ public class PasswordEntryTest extends TestCase { assertTrue(entry.hasTotp()); assertEquals("JBSWY3DPEHPK3PXP", entry.getTotpSecret()); } + + public void testNoHotpUriPresent() { + PasswordEntry entry = new PasswordEntry("secret\nextra\nlogin: username\ncontent"); + assertFalse(entry.hasHotp()); + assertNull(entry.getHotpSecret()); + assertNull(entry.getHotpCounter()); + } + + public void testHotpUriInPassword() { + PasswordEntry entry = new PasswordEntry("otpauth://hotp/test?secret=JBSWY3DPEHPK3PXP&counter=25"); + assertTrue(entry.hasHotp()); + assertEquals("JBSWY3DPEHPK3PXP", entry.getHotpSecret()); + assertEquals(new Long(25 ), entry.getHotpCounter()); + } + + public void testHotpUriInContent() { + PasswordEntry entry = new PasswordEntry("secret\nusername: test\notpauth://hotp/test?secret=JBSWY3DPEHPK3PXP&counter=25"); + assertTrue(entry.hasHotp()); + assertEquals("JBSWY3DPEHPK3PXP", entry.getHotpSecret()); + assertEquals(new Long(25), entry.getHotpCounter()); + } }
\ 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 deleted file mode 100644 index 500644d1..00000000 --- a/app/src/androidTest/java/com/zeapo/pwdstore/TotpTest.java +++ /dev/null @@ -1,12 +0,0 @@ -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); - } -} |