aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain-Test
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-07-11 03:27:28 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-07-11 03:27:28 +0200
commit036a8865814b00f576b261c82e37a36475391451 (patch)
tree9ffdec8fb24e08e8ddb3efda6f9b4925562bf402 /OpenKeychain-Test
parentf6e39b0a9702beda90b6c6e7f32ca986a8a1f3fb (diff)
downloadopen-keychain-036a8865814b00f576b261c82e37a36475391451.tar.gz
open-keychain-036a8865814b00f576b261c82e37a36475391451.tar.bz2
open-keychain-036a8865814b00f576b261c82e37a36475391451.zip
test: test subkey revocation
Diffstat (limited to 'OpenKeychain-Test')
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
index f55e638f2..dc58fe5a7 100644
--- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
+++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
@@ -172,6 +172,41 @@ public class PgpKeyOperationTest {
}
@Test
+ public void testSubkeyRevoke() throws Exception {
+
+ SaveKeyringParcel parcel = new SaveKeyringParcel();
+ parcel.mMasterKeyId = ring.getMasterKeyId();
+ parcel.mFingerprint = ring.getFingerprint();
+ {
+ Iterator<UncachedPublicKey> it = ring.getPublicKeys();
+ it.next();
+ parcel.revokeSubKeys.add(it.next().getKeyId());
+ }
+
+ UncachedKeyRing modified = applyModificationWithChecks(parcel, ring);
+
+ ArrayList<RawPacket> onlyA = new ArrayList<RawPacket>();
+ ArrayList<RawPacket> onlyB = new ArrayList<RawPacket>();
+
+ Assert.assertTrue("keyring must differ from original", KeyringTestingHelper.diffKeyrings(
+ ring.getEncoded(), modified.getEncoded(), onlyA, onlyB));
+
+ Assert.assertEquals("no extra packets in original", 0, onlyA.size());
+ Assert.assertEquals("exactly one extra packet in modified", 1, onlyB.size());
+
+ Iterator<RawPacket> it = onlyB.iterator();
+ Packet p;
+
+ p = new BCPGInputStream(new ByteArrayInputStream(it.next().buf)).readPacket();
+ Assert.assertTrue("first new packet must be secret subkey", p instanceof SignaturePacket);
+ Assert.assertEquals("signature type must be subkey binding certificate",
+ PGPSignature.SUBKEY_REVOCATION, ((SignaturePacket) p).getSignatureType());
+ Assert.assertEquals("signature must have been created by master key",
+ ring.getMasterKeyId(), ((SignaturePacket) p).getKeyID());
+
+ }
+
+ @Test
public void testUserIdAdd() throws Exception {
SaveKeyringParcel parcel = new SaveKeyringParcel();