diff options
| author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-11 03:27:28 +0200 | 
|---|---|---|
| committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-11 03:27:28 +0200 | 
| commit | 036a8865814b00f576b261c82e37a36475391451 (patch) | |
| tree | 9ffdec8fb24e08e8ddb3efda6f9b4925562bf402 | |
| parent | f6e39b0a9702beda90b6c6e7f32ca986a8a1f3fb (diff) | |
| download | open-keychain-036a8865814b00f576b261c82e37a36475391451.tar.gz open-keychain-036a8865814b00f576b261c82e37a36475391451.tar.bz2 open-keychain-036a8865814b00f576b261c82e37a36475391451.zip  | |
test: test subkey revocation
| -rw-r--r-- | OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java | 35 | 
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();  | 
