rename ProviderHelper -> DatabaseInteractor
This commit is contained in:
@@ -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.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
@@ -135,13 +135,13 @@ public class BackupOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
providerHelper.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
providerHelper.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
@@ -150,7 +150,7 @@ public class BackupOperationTest {
|
||||
@Test
|
||||
public void testExportAllLocalStripped() throws Exception {
|
||||
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(outStream.toByteArray());
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
|
||||
@@ -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.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
op.execute(new BenchmarkInputParcel(), null);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
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,13 +117,13 @@ public class CertifyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
providerHelper.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
providerHelper.savePublicKeyRing(mStaticRing2.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing2.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
@@ -132,7 +132,7 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testSelfCertifyFlag() throws Exception {
|
||||
|
||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||
|
||||
@@ -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.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
@@ -90,12 +90,12 @@ public class PromoteKeyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
providerHelper.savePublicKeyRing(mStaticRing.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
databaseInteractor.savePublicKeyRing(mStaticRing.extractPublicKeyRing(), new ProgressScaler(), null);
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
@@ -104,14 +104,14 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromote() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application)
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||
|
||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||
|
||||
@@ -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.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputDataParcel input = new InputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
|
||||
return op.execute(input, new CryptoInputParcel());
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogTyp
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
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,13 +149,13 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
|
||||
providerHelper.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
providerHelper.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing1, new ProgressScaler());
|
||||
databaseInteractor.saveSecretKeyRing(mStaticRing2, new ProgressScaler());
|
||||
|
||||
// ok NOW log verbosely!
|
||||
ShadowLog.stream = System.out;
|
||||
@@ -172,7 +172,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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));
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
providerHelper.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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));
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
providerHelper.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
|
||||
|
||||
@@ -675,8 +675,8 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
providerHelper.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
}
|
||||
|
||||
{ // encrypt to this keyring, make sure it's not encrypted to the revoked subkey
|
||||
@@ -685,7 +685,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null);
|
||||
new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application), null) {
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null) {
|
||||
@Override
|
||||
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
||||
throws NoSecretKeyException {
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class ProviderHelperKeyringTest {
|
||||
public class DatabaseInteractorKeyringTest {
|
||||
|
||||
@Test
|
||||
public void testSavePublicKeyring() throws Exception {
|
||||
@@ -41,9 +41,9 @@ import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class ProviderHelperSaveTest {
|
||||
public class DatabaseInteractorSaveTest {
|
||||
|
||||
ProviderHelper mProviderHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor mDatabaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpOnce() throws Exception {
|
||||
@@ -61,17 +61,17 @@ public class ProviderHelperSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert both keys, second should fail
|
||||
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertFalse("second keyring import should fail", result.success());
|
||||
|
||||
}
|
||||
@@ -90,13 +90,13 @@ public class ProviderHelperSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert secret, this should fail because of missing self-cert
|
||||
result = new ProviderHelper(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = new DatabaseInteractor(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 ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||
result = new ProviderHelper(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||
|
||||
}
|
||||
@@ -108,10 +108,10 @@ public class ProviderHelperSaveTest {
|
||||
Assert.assertEquals("key flags should be zero",
|
||||
0, (long) pub.canonicalize(new OperationLog(), 0).getPublicKey().getKeyUsage());
|
||||
|
||||
mProviderHelper.savePublicKeyRing(pub);
|
||||
mDatabaseInteractor.savePublicKeyRing(pub);
|
||||
|
||||
CachedPublicKeyRing cachedRing = mProviderHelper.getCachedPublicKeyRing(keyId);
|
||||
CanonicalizedPublicKeyRing pubRing = mProviderHelper.getCanonicalizedPublicKeyRing(keyId);
|
||||
CachedPublicKeyRing cachedRing = mDatabaseInteractor.getCachedPublicKeyRing(keyId);
|
||||
CanonicalizedPublicKeyRing pubRing = mDatabaseInteractor.getCanonicalizedPublicKeyRing(keyId);
|
||||
|
||||
Assert.assertEquals("master key should be encryption key", keyId, pubRing.getEncryptId());
|
||||
Assert.assertEquals("master key should be encryption key (cached)", keyId, cachedRing.getEncryptId());
|
||||
@@ -131,13 +131,13 @@ public class ProviderHelperSaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mProviderHelper.saveSecretKeyRing(sec, new ProgressScaler());
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(sec, new ProgressScaler());
|
||||
Assert.assertTrue("import of secret keyring should succeed", result.success());
|
||||
|
||||
// make sure both the CanonicalizedSecretKeyRing as well as the CachedPublicKeyRing correctly
|
||||
// indicate the secret key type
|
||||
CachedPublicKeyRing cachedRing = mProviderHelper.getCachedPublicKeyRing(keyId);
|
||||
CanonicalizedSecretKeyRing secRing = mProviderHelper.getCanonicalizedSecretKeyRing(keyId);
|
||||
CachedPublicKeyRing cachedRing = mDatabaseInteractor.getCachedPublicKeyRing(keyId);
|
||||
CanonicalizedSecretKeyRing secRing = mDatabaseInteractor.getCanonicalizedSecretKeyRing(keyId);
|
||||
|
||||
Iterator<CanonicalizedSecretKey> it = secRing.secretKeyIterator().iterator();
|
||||
|
||||
@@ -195,10 +195,10 @@ public class ProviderHelperSaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mProviderHelper.savePublicKeyRing(key, new ProgressScaler(), null);
|
||||
result = mDatabaseInteractor.savePublicKeyRing(key, new ProgressScaler(), null);
|
||||
Assert.assertTrue("import of keyring should succeed", result.success());
|
||||
|
||||
CanonicalizedPublicKeyRing ring = mProviderHelper.getCanonicalizedPublicKeyRing(keyId);
|
||||
CanonicalizedPublicKeyRing ring = mDatabaseInteractor.getCanonicalizedPublicKeyRing(keyId);
|
||||
boolean found = false;
|
||||
byte[] badUserId = Hex.decode("436c61757320467261656e6b656c203c436c6175732e4672e46e6b656c4068616c696661782e727774682d61616368656e2e64653e");
|
||||
for (byte[] rawUserId : new IterableIterator<byte[]>(
|
||||
@@ -222,29 +222,29 @@ public class ProviderHelperSaveTest {
|
||||
|
||||
SaveKeyringResult result;
|
||||
|
||||
result = mProviderHelper.saveSecretKeyRing(key, new ProgressScaler());
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(key, new ProgressScaler());
|
||||
Assert.assertTrue("import of keyring should succeed", result.success());
|
||||
|
||||
long signId;
|
||||
{
|
||||
CanonicalizedSecretKeyRing ring = mProviderHelper.getCanonicalizedSecretKeyRing(masterKeyId);
|
||||
CanonicalizedSecretKeyRing ring = mDatabaseInteractor.getCanonicalizedSecretKeyRing(masterKeyId);
|
||||
Assert.assertTrue("master key should have sign flag", ring.getPublicKey().canSign());
|
||||
Assert.assertTrue("master key should have encrypt flag", ring.getPublicKey().canEncrypt());
|
||||
|
||||
signId = mProviderHelper.getCachedPublicKeyRing(masterKeyId).getSecretSignId();
|
||||
signId = mDatabaseInteractor.getCachedPublicKeyRing(masterKeyId).getSecretSignId();
|
||||
Assert.assertNotEquals("encrypt id should not be 0", 0, signId);
|
||||
Assert.assertNotEquals("encrypt key should be different from master key", masterKeyId, signId);
|
||||
}
|
||||
|
||||
{
|
||||
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
|
||||
CachedPublicKeyRing ring = mDatabaseInteractor.getCachedPublicKeyRing(masterKeyId);
|
||||
Assert.assertEquals("signing key should be same id cached as uncached", signId, ring.getSecretSignId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UncachedKeyRing readRingFromResource(String name) throws Exception {
|
||||
return UncachedKeyRing.fromStream(ProviderHelperSaveTest.class.getResourceAsStream(name)).next();
|
||||
return UncachedKeyRing.fromStream(DatabaseInteractorSaveTest.class.getResourceAsStream(name)).next();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class InteropTest {
|
||||
final Uri verifyUri = verify != null ?
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null;
|
||||
|
||||
ProviderHelper helper = new ProviderHelper(RuntimeEnvironment.application) {
|
||||
DatabaseInteractor helper = new DatabaseInteractor(RuntimeEnvironment.application) {
|
||||
|
||||
@Override
|
||||
public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException {
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainExternalContract.EmailStatus;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelperSaveTest;
|
||||
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;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -45,7 +45,7 @@ public class KeychainExternalProviderTest {
|
||||
static final long KEY_ID_PUBLIC = 0x9A282CE2AB44A382L;
|
||||
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
ApiPermissionHelper apiPermissionHelper;
|
||||
ApiDataAccessObject apiDao;
|
||||
@@ -187,7 +187,7 @@ public class KeychainExternalProviderTest {
|
||||
CertifyActionsParcel certifyActionsParcel = new CertifyActionsParcel(secretMasterKeyId);
|
||||
certifyActionsParcel.add(new CertifyAction(publicMasterKeyId, Collections.singletonList(userId), null));
|
||||
CertifyOperation op = new CertifyOperation(
|
||||
RuntimeEnvironment.application, providerHelper, new ProgressScaler(), null);
|
||||
RuntimeEnvironment.application, databaseInteractor, new ProgressScaler(), null);
|
||||
CertifyResult certifyResult = op.execute(certifyActionsParcel, new CryptoInputParcel());
|
||||
|
||||
assertTrue(certifyResult.success());
|
||||
@@ -195,17 +195,17 @@ public class KeychainExternalProviderTest {
|
||||
|
||||
private void insertPublicKeyringFrom(String filename) throws Exception {
|
||||
UncachedKeyRing ring = readRingFromResource(filename);
|
||||
SaveKeyringResult saveKeyringResult = providerHelper.savePublicKeyRing(ring);
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.savePublicKeyRing(ring);
|
||||
assertTrue(saveKeyringResult.success());
|
||||
}
|
||||
|
||||
private void insertSecretKeyringFrom(String filename) throws Exception {
|
||||
UncachedKeyRing ring = readRingFromResource(filename);
|
||||
SaveKeyringResult saveKeyringResult = providerHelper.saveSecretKeyRing(ring, new ProgressScaler());
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.saveSecretKeyRing(ring, new ProgressScaler());
|
||||
assertTrue(saveKeyringResult.success());
|
||||
}
|
||||
|
||||
UncachedKeyRing readRingFromResource(String name) throws Exception {
|
||||
return UncachedKeyRing.fromStream(ProviderHelperSaveTest.class.getResourceAsStream(name)).next();
|
||||
return UncachedKeyRing.fromStream(DatabaseInteractorSaveTest.class.getResourceAsStream(name)).next();
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
|
||||
class ProviderHelperStub extends ProviderHelper {
|
||||
public ProviderHelperStub(Context context) {
|
||||
class DatabaseInteractorStub extends DatabaseInteractor {
|
||||
public DatabaseInteractorStub(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ 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.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
@@ -50,24 +50,24 @@ public class KeyringTestingHelper {
|
||||
|
||||
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(context);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(context);
|
||||
|
||||
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
||||
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
||||
long masterKeyId = ring.getMasterKeyId();
|
||||
|
||||
// Should throw an exception; key is not yet saved
|
||||
retrieveKeyAndExpectNotFound(providerHelper, masterKeyId);
|
||||
retrieveKeyAndExpectNotFound(databaseInteractor, masterKeyId);
|
||||
|
||||
SaveKeyringResult saveKeyringResult = providerHelper.savePublicKeyRing(ring, new ProgressScaler(), null);
|
||||
SaveKeyringResult saveKeyringResult = databaseInteractor.savePublicKeyRing(ring, new ProgressScaler(), null);
|
||||
|
||||
boolean saveSuccess = saveKeyringResult.success();
|
||||
|
||||
// Now re-retrieve the saved key. Should not throw an exception.
|
||||
providerHelper.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
databaseInteractor.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
|
||||
// A different ID should still fail
|
||||
retrieveKeyAndExpectNotFound(providerHelper, masterKeyId - 1);
|
||||
retrieveKeyAndExpectNotFound(databaseInteractor, masterKeyId - 1);
|
||||
|
||||
return saveSuccess;
|
||||
}
|
||||
@@ -345,11 +345,11 @@ public class KeyringTestingHelper {
|
||||
return getNth(ring.getPublicKeys(), position).getKeyId();
|
||||
}
|
||||
|
||||
private void retrieveKeyAndExpectNotFound(ProviderHelper providerHelper, long masterKeyId) {
|
||||
private void retrieveKeyAndExpectNotFound(DatabaseInteractor databaseInteractor, long masterKeyId) {
|
||||
try {
|
||||
providerHelper.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
databaseInteractor.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
throw new AssertionError("Was expecting the previous call to fail!");
|
||||
} catch (ProviderHelper.NotFoundException expectedException) {
|
||||
} catch (DatabaseInteractor.NotFoundException expectedException) {
|
||||
// good
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user