diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-16 00:05:02 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-16 00:05:02 +0100 |
commit | 89d1b6e4dcd175872fabc2f5ac4c87adb3f3faf5 (patch) | |
tree | e86381303963c8567801e426a5a900491ce2daf7 /OpenKeychain/src/test/java/org | |
parent | b5b197a9c4edde87cc36d61b13058c58520bafb0 (diff) | |
download | open-keychain-89d1b6e4dcd175872fabc2f5ac4c87adb3f3faf5.tar.gz open-keychain-89d1b6e4dcd175872fabc2f5ac4c87adb3f3faf5.tar.bz2 open-keychain-89d1b6e4dcd175872fabc2f5ac4c87adb3f3faf5.zip |
fix unit tests (IllegalStateException)
Diffstat (limited to 'OpenKeychain/src/test/java/org')
-rw-r--r-- | OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java | 19 |
1 files changed, 14 insertions, 5 deletions
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<RawPacket>(), new ArrayList<RawPacket>(), @@ -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<RawPacket>(), new ArrayList<RawPacket>(), 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<RawPacket> packets = KeyringTestingHelper.parseKeyring(ciphertext); |