aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-10-08 19:55:28 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-10-08 19:55:28 +0200
commit3bf653775b7fa668d11ea4a2369d90ad0c7f645d (patch)
treec1d7ae2b9588700d4a8758d45181e5dff93ad886 /OpenKeychain/src
parent81a462c2ac66dd0dc16019af2099c7dd96fe9f36 (diff)
downloadopen-keychain-3bf653775b7fa668d11ea4a2369d90ad0c7f645d.tar.gz
open-keychain-3bf653775b7fa668d11ea4a2369d90ad0c7f645d.tar.bz2
open-keychain-3bf653775b7fa668d11ea4a2369d90ad0c7f645d.zip
improve tests, get rid of some redundant checks
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java10
-rw-r--r--OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java11
2 files changed, 7 insertions, 14 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java
index d3c722761..0709d4f62 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java
@@ -502,11 +502,6 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
log.add(LogType.MSG_DC_ASKIP_NO_KEY, indent + 1);
continue;
}
- if (secretKeyRing == null) {
- // continue with the next packet in the while loop
- log.add(LogType.MSG_DC_ASKIP_NO_KEY, indent + 1);
- continue;
- }
// allow only specific keys for decryption?
if (input.getAllowedKeyIds() != null) {
@@ -526,11 +521,6 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
// get subkey which has been used for this encryption packet
secretEncryptionKey = secretKeyRing.getSecretKey(subKeyId);
- if (secretEncryptionKey == null) {
- // should actually never happen, so no need to be more specific.
- log.add(LogType.MSG_DC_ASKIP_NO_KEY, indent + 1);
- continue;
- }
/* secret key exists in database and is allowed! */
asymmetricPacketFound = true;
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 84ebc5296..be233d0b3 100644
--- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java
+++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java
@@ -344,7 +344,7 @@ public class PgpEncryptDecryptTest {
@Test
public void testAsymmetricSignCleartext() {
- String plaintext = "dies ist ein plaintext ☭" + TestingUtils.genPassphrase(true);
+ String plaintext = "dies ist ein\r\nplaintext\n ☭" + TestingUtils.genPassphrase(true);
byte[] ciphertext;
{ // encrypt data with key
@@ -370,7 +370,8 @@ public class PgpEncryptDecryptTest {
ciphertext = out.toByteArray();
}
- Assert.assertTrue("clearsigned text must contain plaintext", new String(ciphertext).contains(plaintext));
+ Assert.assertTrue("clearsigned text must contain plaintext (ignoring newlines)",
+ new String(ciphertext).replace("\r\n", "").contains(plaintext.replace("\r", "").replace("\n", "")));
{ // verification should succeed
@@ -383,8 +384,10 @@ public class PgpEncryptDecryptTest {
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(), data, out);
Assert.assertTrue("verification must succeed", result.success());
- Assert.assertArrayEquals("verification text should equal plaintext (save for a newline)",
- (plaintext + StringUtils.LINE_SEP).getBytes(), out.toByteArray());
+
+ Assert.assertTrue("verification text should equal plaintext (ignoring newlines)",
+ new String(out.toByteArray()).replace(StringUtils.LINE_SEP, "")
+ .equals(plaintext.replace("\r", "").replace("\n", "")));
Assert.assertEquals("decryptionResult should be RESULT_NOT_ENCRYPTED",
OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED, result.getDecryptionResult().getResult());
Assert.assertEquals("signatureResult should be RESULT_VALID_CONFIRMED",