extract DatabaseReadWriteInteractor

This commit is contained in:
Vincent Breitmoser
2017-02-20 16:28:30 +01:00
parent d577257bd5
commit aef6e6614e
62 changed files with 1658 additions and 1571 deletions

View File

@@ -44,7 +44,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
@@ -135,7 +135,7 @@ public class BackupOperationTest {
@Before
public void setUp() {
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
// don't log verbosely here, we're not here to test imports
ShadowLog.stream = oldShadowStream;
@@ -150,7 +150,7 @@ public class BackupOperationTest {
@Test
public void testExportAllLocalStripped() throws Exception {
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
// make sure there is a local cert (so the later checks that there are none are meaningful)
assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
@@ -249,7 +249,7 @@ public class BackupOperationTest {
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
BackupOperation op = new BackupOperation(spyApplication,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
BackupKeyringParcel parcel = new BackupKeyringParcel(
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
@@ -306,7 +306,7 @@ public class BackupOperationTest {
{ // export encrypted
BackupOperation op = new BackupOperation(spyApplication,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
BackupKeyringParcel parcel = new BackupKeyringParcel(
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
@@ -324,7 +324,7 @@ public class BackupOperationTest {
{
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(outStream.toByteArray());
input.setAllowSymmetricDecryption(true);

View File

@@ -25,7 +25,7 @@ import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowLog;
import org.sufficientlysecure.keychain.KeychainTestRunner;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.service.BenchmarkInputParcel;
import java.io.PrintStream;
@@ -47,7 +47,7 @@ public class BenchmarkOperationTest {
@Test
public void testBenchmark() throws Exception {
BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
op.execute(new BenchmarkInputParcel(), null);
}

View File

@@ -34,8 +34,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
@@ -117,7 +117,7 @@ public class CertifyOperationTest {
@Before
public void setUp() throws Exception {
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
// don't log verbosely here, we're not here to test imports
ShadowLog.stream = oldShadowStream;
@@ -132,7 +132,7 @@ public class CertifyOperationTest {
@Test
public void testSelfCertifyFlag() throws Exception {
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
Assert.assertEquals("secret key must be marked self-certified in database",
// TODO this should be more correctly be VERIFIED_SELF at some point!
@@ -143,10 +143,10 @@ public class CertifyOperationTest {
@Test
public void testCertifyId() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("public key must not be marked verified prior to certification",
Certs.UNVERIFIED, ring.getVerified());
@@ -160,7 +160,7 @@ public class CertifyOperationTest {
Assert.assertTrue("certification must succeed", result.success());
{
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("new key must be verified now",
Certs.VERIFIED_SECRET, ring.getVerified());
@@ -171,10 +171,10 @@ public class CertifyOperationTest {
@Test
public void testCertifyAttribute() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("public key must not be marked verified prior to certification",
Certs.UNVERIFIED, ring.getVerified());
@@ -188,7 +188,7 @@ public class CertifyOperationTest {
Assert.assertTrue("certification must succeed", result.success());
{
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("new key must be verified now",
Certs.VERIFIED_SECRET, ring.getVerified());
@@ -200,7 +200,7 @@ public class CertifyOperationTest {
@Test
public void testCertifySelf() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
@@ -217,7 +217,7 @@ public class CertifyOperationTest {
public void testCertifyNonexistent() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());

View File

@@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.UncachedPublicKey;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
@@ -90,7 +90,7 @@ public class PromoteKeyOperationTest {
@Before
public void setUp() throws Exception {
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
// don't log verbosely here, we're not here to test imports
ShadowLog.stream = oldShadowStream;
@@ -104,14 +104,14 @@ public class PromoteKeyOperationTest {
@Test
public void testPromote() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
Assert.assertTrue("promotion must succeed", result.success());
{
CachedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
@@ -128,7 +128,7 @@ public class PromoteKeyOperationTest {
@Test
public void testPromoteDivert() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
byte[] aid = Hex.decode("D2760001240102000000012345670000");
@@ -137,7 +137,7 @@ public class PromoteKeyOperationTest {
Assert.assertTrue("promotion must succeed", result.success());
{
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
@@ -153,7 +153,7 @@ public class PromoteKeyOperationTest {
@Test
public void testPromoteDivertSpecific() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
byte[] aid = Hex.decode("D2760001240102000000012345670000");
@@ -167,7 +167,7 @@ public class PromoteKeyOperationTest {
Assert.assertTrue("promotion must succeed", result.success());
{
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {

View File

@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.KeychainTestRunner;
import org.sufficientlysecure.keychain.operations.InputDataOperation;
import org.sufficientlysecure.keychain.operations.results.InputDataResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.InputDataParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -126,7 +126,7 @@ public class InputDataOperationTest {
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
InputDataOperation op = new InputDataOperation(spyApplication,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputDataParcel input = new InputDataParcel(fakeInputUri, null);
@@ -306,7 +306,7 @@ public class InputDataOperationTest {
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
InputDataOperation op = new InputDataOperation(spyApplication,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputDataParcel input = new InputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
return op.execute(input, new CryptoInputParcel());

View File

@@ -40,8 +40,8 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
@@ -149,7 +149,7 @@ public class PgpEncryptDecryptTest {
@Before
public void setUp() {
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
// don't log verbosely here, we're not here to test imports
ShadowLog.stream = oldShadowStream;
@@ -172,7 +172,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -197,7 +197,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(
@@ -227,7 +227,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(input,
@@ -249,7 +249,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(input,
@@ -270,7 +270,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(false);
DecryptVerifyResult result = op.execute(input,
@@ -297,7 +297,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -353,7 +353,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -415,7 +415,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -472,7 +472,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -575,7 +575,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -626,11 +626,11 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
@@ -648,11 +648,11 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
@@ -675,7 +675,7 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
}
@@ -685,7 +685,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -730,7 +730,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -824,7 +824,7 @@ public class PgpEncryptDecryptTest {
{ // decryption with passphrase cached should succeed for the other key if first is gone
// delete first key from database
new DatabaseInteractor(RuntimeEnvironment.application).getContentResolver().delete(
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
);
@@ -859,7 +859,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -907,7 +907,7 @@ public class PgpEncryptDecryptTest {
{ // decryption with passphrase cached should succeed for the other key if first is gone
// delete first key from database
new DatabaseInteractor(RuntimeEnvironment.application).getContentResolver().delete(
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
);
@@ -946,7 +946,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -1018,7 +1018,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null);
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -1069,7 +1069,7 @@ public class PgpEncryptDecryptTest {
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
new DatabaseInteractor(RuntimeEnvironment.application), null) {
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
@Override
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
throws NoSecretKeyException {

View File

@@ -43,7 +43,7 @@ import java.util.Iterator;
@RunWith(KeychainTestRunner.class)
public class DatabaseInteractorSaveTest {
DatabaseInteractor mDatabaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor mDatabaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
@BeforeClass
public static void setUpOnce() throws Exception {
@@ -61,17 +61,17 @@ public class DatabaseInteractorSaveTest {
SaveKeyringResult result;
// insert both keys, second should fail
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
Assert.assertTrue("first keyring import should succeed", result.success());
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
Assert.assertFalse("second keyring import should fail", result.success());
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
// and the other way around
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
Assert.assertTrue("first keyring import should succeed", result.success());
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
Assert.assertFalse("second keyring import should fail", result.success());
}
@@ -90,13 +90,13 @@ public class DatabaseInteractorSaveTest {
SaveKeyringResult result;
// insert secret, this should fail because of missing self-cert
result = new DatabaseInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
// insert pubkey, then seckey - both should succeed
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
Assert.assertTrue("public keyring import should succeed", result.success());
result = new DatabaseInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
}

View File

@@ -243,7 +243,7 @@ public class InteropTest {
final Uri verifyUri = verify != null ?
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null;
DatabaseInteractor helper = new DatabaseInteractor(RuntimeEnvironment.application) {
DatabaseReadWriteInteractor helper = new DatabaseReadWriteInteractor(RuntimeEnvironment.application) {
@Override
public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException {

View File

@@ -20,8 +20,8 @@ import org.sufficientlysecure.keychain.operations.results.CertifyResult;
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeychainExternalContract.EmailStatus;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractorSaveTest;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
@@ -45,7 +45,7 @@ public class KeychainExternalProviderTest {
static final long KEY_ID_PUBLIC = 0x9A282CE2AB44A382L;
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
ApiPermissionHelper apiPermissionHelper;
ApiDataAccessObject apiDao;

View File

@@ -21,9 +21,10 @@ import android.content.Context;
import android.net.Uri;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
class DatabaseInteractorStub extends DatabaseInteractor {
class DatabaseInteractorStub extends DatabaseReadWriteInteractor {
public DatabaseInteractorStub(Context context) {
super(context);
}

View File

@@ -25,6 +25,7 @@ import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.util.ProgressScaler;
import java.io.ByteArrayInputStream;
@@ -50,7 +51,7 @@ public class KeyringTestingHelper {
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
DatabaseInteractor databaseInteractor = new DatabaseInteractor(context);
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(context);
byte[] data = TestDataUtil.readAllFully(blobFiles);
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
@@ -349,7 +350,7 @@ public class KeyringTestingHelper {
try {
databaseInteractor.getCanonicalizedPublicKeyRing(masterKeyId);
throw new AssertionError("Was expecting the previous call to fail!");
} catch (DatabaseInteractor.NotFoundException expectedException) {
} catch (DatabaseReadWriteInteractor.NotFoundException expectedException) {
// good
}
}