diff options
author | Joel Beckmeyer <joel@thebeckmeyers.xyz> | 2018-09-25 13:45:54 -0400 |
---|---|---|
committer | حسين <zidhussein@gmail.com> | 2018-09-25 18:45:54 +0100 |
commit | eea0e68dda1eb7248c6d458f52baeedb318b466a (patch) | |
tree | 73ff2b2f121b8db3097671f0e0639906edc2abea /app/src/androidTest | |
parent | ac889abdd3d71ffb7f064a384c375ec22e7734c4 (diff) |
Display HOTP code if password contains HOTP secret, unify HOTP and TOTP code (#413)
* Display HOTP code if password contains HOTP secret, unify HOTP and TOTP code
* Add ability to show HOTP instead of showing every decrypt
* Fix off by 1 error
* fix return intent logic so that edits and HOTP increments are properly committed
* fix linting errors
* Fix broken logic for case when a password is created
* add ability to choose if password entry will be updated on HOTP code calculation
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); - } -} |