From 04d6fd62c88dcde4e6eff09dc24f471cc979257e Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 1 Jun 2015 12:02:05 +0200 Subject: check for cached session keys in some tests --- .../keychain/pgp/PgpEncryptDecryptTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenKeychain-Test/src') diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java index c7ed9fb30..5a0e27831 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java @@ -168,6 +168,10 @@ public class PgpEncryptDecryptTest { out.toByteArray(), plaintext.getBytes()); Assert.assertNull("signature should be an error", result.getSignatureResult()); + CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel(); + Assert.assertEquals("cached session keys must be empty", + 0, cryptoInput.getCryptoData().size()); + OpenPgpMetadata metadata = result.getDecryptMetadata(); Assert.assertEquals("filesize must be correct", out.toByteArray().length, metadata.getOriginalSize()); @@ -269,6 +273,10 @@ public class PgpEncryptDecryptTest { out.toByteArray(), plaintext.getBytes()); Assert.assertNull("signature be empty", result.getSignatureResult()); + CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel(); + Assert.assertEquals("must have one cached session key", + 1, cryptoInput.getCryptoData().size()); + OpenPgpMetadata metadata = result.getDecryptMetadata(); Assert.assertEquals("filesize must be correct", out.toByteArray().length, metadata.getOriginalSize()); @@ -286,6 +294,10 @@ public class PgpEncryptDecryptTest { PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(); DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(), data, out); + CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel(); + Assert.assertEquals("must have one cached session key", + 1, cryptoInput.getCryptoData().size()); + Assert.assertTrue("decryption with cached passphrase must succeed", result.success()); Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext", out.toByteArray(), plaintext.getBytes()); -- cgit v1.2.3