add simple unit test for more than decryption one key candidate
This commit is contained in:
parent
5e416d6ae5
commit
66f713c847
|
@ -90,6 +90,14 @@ public class RequiredInputParcel implements Parcelable {
|
|||
return mSubKeyIds == null ? null : mSubKeyIds[0];
|
||||
}
|
||||
|
||||
public long[] getMasterKeyIds() {
|
||||
return mMasterKeyIds;
|
||||
}
|
||||
|
||||
public long[] getSubKeyIds() {
|
||||
return mSubKeyIds;
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createRetryUploadOperation() {
|
||||
return new RequiredInputParcel(RequiredInputType.UPLOAD_FAIL_RETRY,
|
||||
null, null, null, 0L, 0L);
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
|||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequiredInputType;
|
||||
import org.sufficientlysecure.keychain.support.KeyringTestingHelper;
|
||||
import org.sufficientlysecure.keychain.support.KeyringTestingHelper.RawPacket;
|
||||
|
@ -1064,6 +1065,25 @@ public class PgpEncryptDecryptTest {
|
|||
Assert.assertEquals(1024, encryptionKeySecurityProblem.bitStrength);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecryptForTwoKeys() throws Exception {
|
||||
InputStream in = getResourceAsStream("/test-ciphertexts/two_keys.asc");
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = operationWithFakePassphraseCache(null, null, null);
|
||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder().build();
|
||||
DecryptVerifyResult result = op.execute(input, CryptoInputParcel.createCryptoInputParcel(), data, out);
|
||||
|
||||
RequiredInputParcel requiredInputParcel = result.getRequiredInputParcel();
|
||||
Assert.assertNotNull(requiredInputParcel);
|
||||
Assert.assertEquals(3, requiredInputParcel.getMasterKeyIds().length);
|
||||
Assert.assertEquals(mStaticRing1.getMasterKeyId(), requiredInputParcel.getMasterKeyIds()[0]);
|
||||
Assert.assertEquals(mStaticRing1.getMasterKeyId(), requiredInputParcel.getMasterKeyIds()[1]);
|
||||
Assert.assertEquals(mStaticRing2.getMasterKeyId(), requiredInputParcel.getMasterKeyIds()[2]);
|
||||
}
|
||||
|
||||
private PgpDecryptVerifyOperation operationWithFakePassphraseCache(
|
||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||
|
||||
|
|
BIN
OpenKeychain/src/test/resources/test-ciphertexts/two_keys.asc
Normal file
BIN
OpenKeychain/src/test/resources/test-ciphertexts/two_keys.asc
Normal file
Binary file not shown.
Loading…
Reference in a new issue