aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/test
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2016-04-29 21:40:00 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2016-04-29 21:40:00 +0200
commit0ef59e36add59add1b34a316dd13a2049165043e (patch)
tree3d345388e4a5c162407aea5c4f13c112bdbf9854 /OpenKeychain/src/test
parent0e67b49e1a930f1e59ef6ee3a37d0f31b2e65605 (diff)
parent6881754062dcd0b83431cfe36398d20e30922096 (diff)
downloadopen-keychain-0ef59e36add59add1b34a316dd13a2049165043e.tar.gz
open-keychain-0ef59e36add59add1b34a316dd13a2049165043e.tar.bz2
open-keychain-0ef59e36add59add1b34a316dd13a2049165043e.zip
Merge pull request #1816 from fiaxh/no_name_choose_email
Correctly handle keys only having an email address
Diffstat (limited to 'OpenKeychain/src/test')
-rw-r--r--OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/SplitUserIdTest.java (renamed from OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/KeyRingTest.java)37
1 files changed, 34 insertions, 3 deletions
diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/KeyRingTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/SplitUserIdTest.java
index 64316b2a6..97feeea7b 100644
--- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/KeyRingTest.java
+++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/SplitUserIdTest.java
@@ -28,7 +28,7 @@ import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
-public class KeyRingTest {
+public class SplitUserIdTest {
@Test
public void splitCompleteUserIdShouldReturnAll3Components() throws Exception {
@@ -49,9 +49,40 @@ public class KeyRingTest {
@Test
public void splitUserIdWithAllButEmailShouldReturnNameAndComment() throws Exception {
KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann (this is a comment)");
- Assert.assertEquals(info.name, "Max Mustermann");
- Assert.assertEquals(info.comment, "this is a comment");
+ Assert.assertEquals("Max Mustermann", info.name);
+ Assert.assertEquals("this is a comment", info.comment);
+ Assert.assertNull(info.email);
+ }
+
+ @Test
+ public void splitUserIdWithCommentAndEmailShouldReturnCommentAndEmail() throws Exception {
+ KeyRing.UserId info = KeyRing.splitUserId(" (this is a comment) <max@example.com>");
+ Assert.assertNull(info.name);
+ Assert.assertEquals("this is a comment", info.comment);
+ Assert.assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithEmailShouldReturnEmail() throws Exception {
+ KeyRing.UserId info = KeyRing.splitUserId("max@example.com");
+ Assert.assertNull(info.name);
+ Assert.assertNull(info.comment);
+ Assert.assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithNameShouldReturnName() throws Exception {
+ KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann");
+ Assert.assertEquals("Max Mustermann", info.name);
+ Assert.assertNull(info.comment);
Assert.assertNull(info.email);
}
+ @Test
+ public void splitUserIdWithCommentShouldReturnComment() throws Exception {
+ KeyRing.UserId info = KeyRing.splitUserId(" (this is a comment)");
+ Assert.assertNull(info.name);
+ Assert.assertEquals("this is a comment", info.comment);
+ Assert.assertNull(info.email);
+ }
} \ No newline at end of file