diff options
Diffstat (limited to 'tests/src/test/java/org/whispersystems/libaxolotl/groups')
-rw-r--r-- | tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java index b41adb58..dd5a306f 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java @@ -2,6 +2,7 @@ package org.whispersystems.libaxolotl.groups; import junit.framework.TestCase; +import org.whispersystems.libaxolotl.AxolotlAddress; import org.whispersystems.libaxolotl.DuplicateMessageException; import org.whispersystems.libaxolotl.InvalidMessageException; import org.whispersystems.libaxolotl.LegacyMessageException; @@ -14,6 +15,9 @@ import java.util.ArrayList; public class GroupCipherTest extends TestCase { + private static final AxolotlAddress SENDER_ADDRESS = new AxolotlAddress("+14150001111", 1); + private static final SenderKeyName GROUP_SENDER = new SenderKeyName("nihilist history reading group", SENDER_ADDRESS); + public void testBasicEncryptDecrypt() throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException { @@ -23,13 +27,12 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("cool group", 1111, 0)); - GroupCipher bobGroupCipher = new GroupCipher(bobStore, new SenderKeyName("cool group", 1111, 0)); + GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER); + GroupCipher bobGroupCipher = new GroupCipher(bobStore, GROUP_SENDER); - SenderKeyDistributionMessage aliceDistributionMessage = - aliceSessionBuilder.create(new SenderKeyName("cool group", 1111, 0)); + SenderKeyDistributionMessage aliceDistributionMessage = aliceSessionBuilder.create(GROUP_SENDER); - bobSessionBuilder.process(new SenderKeyName("cool group", 1111, 0), aliceDistributionMessage); + bobSessionBuilder.process(GROUP_SENDER, aliceDistributionMessage); byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes()); byte[] plaintextFromAlice = bobGroupCipher.decrypt(ciphertextFromAlice); @@ -46,7 +49,7 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - SenderKeyName aliceName = new SenderKeyName("cool group", 1111, 0); + SenderKeyName aliceName = GROUP_SENDER; GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName); GroupCipher bobGroupCipher = new GroupCipher(bobStore, aliceName); @@ -86,7 +89,7 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - SenderKeyName aliceName = new SenderKeyName("cool group", 1111, 0); + SenderKeyName aliceName = GROUP_SENDER; GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName); GroupCipher bobGroupCipher = new GroupCipher(bobStore, aliceName); @@ -113,7 +116,7 @@ public class GroupCipherTest extends TestCase { public void testEncryptNoSession() { InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore(); - GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("coolio groupio", 1111, 0)); + GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("coolio groupio", new AxolotlAddress("+10002223333", 1))); try { aliceGroupCipher.encrypt("up the punks".getBytes()); throw new AssertionError("Should have failed!"); |