From 89d1b6e4dcd175872fabc2f5ac4c87adb3f3faf5 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 16 Nov 2015 00:05:02 +0100 Subject: fix unit tests (IllegalStateException) --- .../keychain/pgp/PgpEncryptDecryptTest.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/test') diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java index d3c3f1df5..47c7a20ea 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java @@ -556,7 +556,7 @@ public class PgpEncryptDecryptTest { } @Test - public void testAsymmetricMultiSubkeyEncrypt() throws Exception { + public void testMultiSubkeyEncryptSkipStripOrBadFlag() throws Exception { String plaintext = "dies ist ein plaintext ☭" + TestingUtils.genPassphrase(true); @@ -610,7 +610,8 @@ public class PgpEncryptDecryptTest { { // strip first encrypted subkey, decryption should skip it - SaveKeyringParcel parcel = new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint()); + SaveKeyringParcel parcel = + new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint()); parcel.mChangeSubKeys.add(new SubkeyChange(encKeyId1, true, false)); UncachedKeyRing modified = PgpKeyOperationTest.applyModificationWithChecks(parcel, mStaticRing1, new ArrayList(), new ArrayList(), @@ -631,8 +632,9 @@ public class PgpEncryptDecryptTest { { // change flags of second encrypted subkey, decryption should skip it - SaveKeyringParcel parcel = new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint()); - parcel.mChangeSubKeys.add(new SubkeyChange(encKeyId1, PGPKeyFlags.CAN_CERTIFY, null)); + SaveKeyringParcel parcel = + new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint()); + parcel.mChangeSubKeys.add(new SubkeyChange(encKeyId1, KeyFlags.CERTIFY_OTHER, null)); UncachedKeyRing modified = PgpKeyOperationTest.applyModificationWithChecks(parcel, mStaticRing1, new ArrayList(), new ArrayList(), new CryptoInputParcel(new Date(), mKeyPhrase1)); @@ -650,6 +652,13 @@ public class PgpEncryptDecryptTest { result.getLog().containsType(LogType.MSG_DC_ASKIP_BAD_FLAGS)); } + } + + @Test + public void testMultiSubkeyEncryptSkipRevoked() throws Exception { + + String plaintext = "dies ist ein plaintext ☭" + TestingUtils.genPassphrase(true); + { // revoke first encryption subkey of keyring in database SaveKeyringParcel parcel = new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint()); parcel.mRevokeSubKeys.add(KeyringTestingHelper.getSubkeyId(mStaticRing1, 2)); @@ -679,7 +688,7 @@ public class PgpEncryptDecryptTest { data, out); Assert.assertTrue("encryption must succeed", result.success()); - ciphertext = out.toByteArray(); + byte[] ciphertext = out.toByteArray(); Iterator packets = KeyringTestingHelper.parseKeyring(ciphertext); -- cgit v1.2.3