From 3d5dd65e306ba3ca560b3c221830ee4cdb4363fb Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Mon, 6 Nov 2017 12:41:00 +0100 Subject: Display TOTP code if entry contains OTP secret TOTP is calculated on display and on copy to clipboard from secret embedded in entry (either in password or in extra) and the current time. --- .../java/com/zeapo/pwdstore/PasswordEntryTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java') 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 -- cgit v1.2.3