aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/com
diff options
context:
space:
mode:
authorFelix Bechstein <f@ub0r.de>2017-07-22 12:09:34 +0200
committerMohamed Zenadi <zeapo@users.noreply.github.com>2017-07-22 12:09:34 +0200
commit5cba6c62d7b4628dfaf482dd883e333f93d323d4 (patch)
treeb28df0db4ca187df0cabc575bbd89c009f69e127 /app/src/androidTest/java/com
parent6ce31056c987b8fd73513d5b4eebc8d0d763a7a2 (diff)
Parse username from password entry, refs #192 (#318)
This is a first step of letting APS handle usernames from password entries. It shows the username in PgpHandler and allows to copy it to the clipboard.
Diffstat (limited to 'app/src/androidTest/java/com')
-rw-r--r--app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java44
1 files changed, 44 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
new file mode 100644
index 00000000..66636b1b
--- /dev/null
+++ b/app/src/androidTest/java/com/zeapo/pwdstore/PasswordEntryTest.java
@@ -0,0 +1,44 @@
+package com.zeapo.pwdstore;
+
+import junit.framework.TestCase;
+
+public class PasswordEntryTest extends TestCase {
+
+ public void testGetPassword() throws Exception {
+ assertEquals("fooooo", new PasswordEntry("fooooo\nbla\n").getPassword());
+ assertEquals("fooooo", new PasswordEntry("fooooo\nbla").getPassword());
+ assertEquals("fooooo", new PasswordEntry("fooooo\n").getPassword());
+ assertEquals("fooooo", new PasswordEntry("fooooo").getPassword());
+ assertEquals("", new PasswordEntry("\nblubb\n").getPassword());
+ assertEquals("", new PasswordEntry("\nblubb").getPassword());
+ assertEquals("", new PasswordEntry("\n").getPassword());
+ assertEquals("", new PasswordEntry("").getPassword());
+ }
+
+ public void testGetExtraContent() throws Exception {
+ assertEquals("bla\n", new PasswordEntry("fooooo\nbla\n").getExtraContent());
+ assertEquals("bla", new PasswordEntry("fooooo\nbla").getExtraContent());
+ assertEquals("", new PasswordEntry("fooooo\n").getExtraContent());
+ assertEquals("", new PasswordEntry("fooooo").getExtraContent());
+ assertEquals("blubb\n", new PasswordEntry("\nblubb\n").getExtraContent());
+ assertEquals("blubb", new PasswordEntry("\nblubb").getExtraContent());
+ assertEquals("", new PasswordEntry("\n").getExtraContent());
+ assertEquals("", new PasswordEntry("").getExtraContent());
+ }
+
+ public void testGetUsername() throws Exception {
+ assertEquals("username", new PasswordEntry("secret\nextra\nlogin: username\ncontent\n").getUsername());
+ assertEquals("username", new PasswordEntry("\nextra\nusername: username\ncontent\n").getUsername());
+ assertEquals("username", new PasswordEntry("\nUSERNaMe: username\ncontent\n").getUsername());
+ assertEquals("username", new PasswordEntry("\nLOGiN:username").getUsername());
+ assertNull(new PasswordEntry("secret\nextra\ncontent\n").getUsername());
+ }
+
+ public void testHasUsername() throws Exception {
+ assertTrue(new PasswordEntry("secret\nextra\nlogin: username\ncontent\n").hasUsername());
+ assertFalse(new PasswordEntry("secret\nextra\ncontent\n").hasUsername());
+ assertFalse(new PasswordEntry("secret\nlogin failed\n").hasUsername());
+ assertFalse(new PasswordEntry("\n").hasUsername());
+ assertFalse(new PasswordEntry("").hasUsername());
+ }
+} \ No newline at end of file