simplify progress for key import operations
This commit is contained in:
@@ -18,6 +18,14 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.Iterator;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
@@ -53,17 +61,8 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import org.sufficientlysecure.keychain.util.TestingUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -141,8 +140,8 @@ public class BackupOperationTest {
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1);
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
|
||||
@@ -17,6 +17,13 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bouncycastle.bcpg.sig.KeyFlags;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.junit.Assert;
|
||||
@@ -43,15 +50,8 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import org.sufficientlysecure.keychain.util.TestingUtils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class CertifyOperationTest {
|
||||
|
||||
@@ -123,8 +123,8 @@ public class CertifyOperationTest {
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing2.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1);
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing2.extractPublicKeyRing(), null);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bouncycastle.bcpg.sig.KeyFlags;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
@@ -45,13 +49,8 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
import org.sufficientlysecure.keychain.support.KeyringTestingHelper;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import org.sufficientlysecure.keychain.util.TestingUtils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.security.Security;
|
||||
import java.util.Iterator;
|
||||
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class PromoteKeyOperationTest {
|
||||
|
||||
@@ -96,7 +95,7 @@ public class PromoteKeyOperationTest {
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing.extractPublicKeyRing(), null);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
|
||||
@@ -64,7 +64,6 @@ import org.sufficientlysecure.keychain.support.KeyringTestingHelper;
|
||||
import org.sufficientlysecure.keychain.support.KeyringTestingHelper.RawPacket;
|
||||
import org.sufficientlysecure.keychain.util.InputData;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import org.sufficientlysecure.keychain.util.TestingUtils;
|
||||
|
||||
import static org.hamcrest.core.AnyOf.anyOf;
|
||||
@@ -156,9 +155,9 @@ public class PgpEncryptDecryptTest {
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRingInsecure, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1);
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2);
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRingInsecure);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
@@ -631,7 +630,7 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
KeyWritableRepository databaseInteractor =
|
||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(modified);
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
@@ -654,7 +653,7 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
KeyWritableRepository databaseInteractor =
|
||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(modified);
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
@@ -682,7 +681,7 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
KeyWritableRepository databaseInteractor =
|
||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(modified);
|
||||
}
|
||||
|
||||
{ // encrypt to this keyring, make sure it's not encrypted to the revoked subkey
|
||||
|
||||
@@ -92,14 +92,14 @@ public class KeyRepositorySaveTest {
|
||||
|
||||
// insert secret, this should fail because of missing self-cert
|
||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
.saveSecretKeyRing(seckey);
|
||||
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
||||
|
||||
// insert pubkey, then seckey - both should succeed
|
||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
.saveSecretKeyRing(seckey);
|
||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class KeyRepositorySaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(sec, new ProgressScaler());
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(sec);
|
||||
Assert.assertTrue("import of secret keyring should succeed", result.success());
|
||||
|
||||
// make sure both the CanonicalizedSecretKeyRing as well as the CachedPublicKeyRing correctly
|
||||
@@ -198,7 +198,7 @@ public class KeyRepositorySaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mDatabaseInteractor.savePublicKeyRing(key, new ProgressScaler(), null);
|
||||
result = mDatabaseInteractor.savePublicKeyRing(key, null);
|
||||
Assert.assertTrue("import of keyring should succeed", result.success());
|
||||
|
||||
CanonicalizedPublicKeyRing ring = mDatabaseInteractor.getCanonicalizedPublicKeyRing(keyId);
|
||||
@@ -225,7 +225,7 @@ public class KeyRepositorySaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(key, new ProgressScaler());
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(key);
|
||||
Assert.assertTrue("import of keyring should succeed", result.success());
|
||||
|
||||
long signId;
|
||||
|
||||
@@ -211,7 +211,7 @@ public class KeychainExternalProviderTest {
|
||||
|
||||
private void insertSecretKeyringFrom(String filename) throws Exception {
|
||||
UncachedKeyRing ring = readRingFromResource(filename);
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.saveSecretKeyRing(ring, new ProgressScaler());
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.saveSecretKeyRing(ring);
|
||||
assertTrue(saveKeyringResult.success());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.support;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -40,6 +31,15 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
|
||||
|
||||
/** Helper methods for keyring tests. */
|
||||
public class KeyringTestingHelper {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class KeyringTestingHelper {
|
||||
// Should throw an exception; key is not yet saved
|
||||
retrieveKeyAndExpectNotFound(databaseInteractor, masterKeyId);
|
||||
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.savePublicKeyRing(ring, new ProgressScaler(), null);
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.savePublicKeyRing(ring, null);
|
||||
|
||||
boolean saveSuccess = saveKeyringResult.success();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user