aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/test/java/tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/test/java/tests')
-rw-r--r--OpenKeychain/src/test/java/tests/UncachedKeyringTest.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java b/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java
index b14bc2301..1f5bb82bd 100644
--- a/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java
+++ b/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java
@@ -6,30 +6,39 @@ import org.junit.runner.RunWith;
import org.robolectric.*;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.testsupport.*;
-import org.sufficientlysecure.keychain.testsupport.KeyringBuilder;
-import org.sufficientlysecure.keychain.testsupport.TestDataUtil;
+import java.util.*;
import java.io.*;
-import java.util.Collections;
@RunWith(RobolectricTestRunner.class)
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
public class UncachedKeyringTest {
@Test
- public void testVerifySuccess() throws Exception {
- UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2();
- UncachedKeyRing inputKeyRing = KeyringBuilder.ring1();
+ public void testCanonicalizeNoChanges() throws Exception {
+ UncachedKeyRing expectedKeyRing = KeyringBuilder.correctRing();
+ UncachedKeyRing inputKeyRing = KeyringBuilder.correctRing();
// Uncomment to dump the encoded key for manual inspection
-// inputKeyRing.getPublicKey().getPublicKey().encode(new FileOutputStream(new File("/tmp/key-encoded")));
+// TestDataUtil.appendToOutput(new ByteArrayInputStream(inputKeyRing.getEncoded()), new FileOutputStream(new File("/tmp/key-encoded")));
new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing);
}
+
+ @Test
+ public void testCanonicalizeExtraIncorrectSignature() throws Exception {
+ UncachedKeyRing expectedKeyRing = KeyringBuilder.correctRing();
+ UncachedKeyRing inputKeyRing = KeyringBuilder.ringWithExtraIncorrectSignature();
+ new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing);
+ }
+
+ /**
+ * Check the original GnuPG-generated public key is OK
+ */
@Test
- public void testVerifyFromGpg() throws Exception {
- byte[] data = TestDataUtil.readAllFully(Collections.singleton( "/public-key-canonicalize.blob"));
+ public void testCanonicalizeOriginalGpg() throws Exception {
+ byte[] data = TestDataUtil.readAllFully(Collections.singleton("/public-key-canonicalize.blob"));
UncachedKeyRing inputKeyRing = UncachedKeyRing.decodeFromData(data);
- new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, KeyringBuilder.ring2());
+ new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, KeyringBuilder.correctRing());
}
@@ -38,8 +47,8 @@ public class UncachedKeyringTest {
*/
@Test
public void testConcat() throws Exception {
- byte[] actual = TestDataUtil.concatAll(new byte[]{1}, new byte[]{2,-2}, new byte[]{5},new byte[]{3});
- byte[] expected = new byte[]{1,2,-2,5,3};
+ byte[] actual = TestDataUtil.concatAll(new byte[]{1}, new byte[]{2, -2}, new byte[]{5}, new byte[]{3});
+ byte[] expected = new byte[]{1, 2, -2, 5, 3};
Assert.assertEquals(java.util.Arrays.toString(expected), java.util.Arrays.toString(actual));
}