From 40f45521c3d3d52fc9be601569ba032a94ec330e Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 29 Jan 2024 13:15:50 +0100 Subject: [PATCH] Update robolectric to 4.11.1 --- OpenKeychain/build.gradle | 2 +- .../keychain/KeychainTestRunner.java | 1 - .../keychain/WorkaroundBuildConfig.java | 16 ---- .../AuthenticationOperationTest.java | 24 +++--- .../operations/BackupOperationTest.java | 22 ++--- .../operations/BenchmarkOperationTest.java | 4 +- .../operations/CertifyOperationTest.java | 24 +++--- .../operations/PromoteKeyOperationTest.java | 18 ++-- .../keychain/pgp/InputDataOperationTest.java | 8 +- .../keychain/pgp/PgpEncryptDecryptTest.java | 84 +++++++++---------- .../keychain/provider/Cv25519Test.java | 2 +- .../keychain/provider/EddsaTest.java | 2 +- .../keychain/provider/InteropTest.java | 4 +- .../provider/KeyRepositoryKeyringTest.java | 8 +- .../provider/KeyRepositorySaveTest.java | 16 ++-- .../keychain/provider/KeyRepositoryTest.java | 4 +- .../remote/KeychainExternalProviderTest.java | 10 +-- .../SecurityTokenConnectionTest.java | 2 +- .../keychain/ssh/SshPublicKeyTest.java | 4 +- .../util/ParcelableFileCacheTest.java | 2 +- 20 files changed, 120 insertions(+), 137 deletions(-) delete mode 100644 OpenKeychain/src/test/java/org/sufficientlysecure/keychain/WorkaroundBuildConfig.java diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index de45abcd7..2dc7f64b5 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -68,7 +68,7 @@ dependencies { // http://robolectric.org/getting-started/ // http://www.vogella.com/tutorials/Robolectric/article.html testImplementation 'junit:junit:4.13' - testImplementation ('org.robolectric:robolectric:3.8') { + testImplementation ('org.robolectric:robolectric:4.11.1') { exclude group: 'org.bouncycastle', module: 'bcprov-jdk18on' } testImplementation 'org.mockito:mockito-core:2.18.0' diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/KeychainTestRunner.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/KeychainTestRunner.java index aad764af5..e13cf608c 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/KeychainTestRunner.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/KeychainTestRunner.java @@ -17,7 +17,6 @@ public class KeychainTestRunner extends RobolectricTestRunner { protected Config buildGlobalConfig() { return new Config.Builder() .setSdk(27) - .setConstants(WorkaroundBuildConfig.class) .setShadows(new Class[] { ShadowWorkManager.class }) .build(); } diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/WorkaroundBuildConfig.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/WorkaroundBuildConfig.java deleted file mode 100644 index 5f1a20fe9..000000000 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/WorkaroundBuildConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sufficientlysecure.keychain; - -import org.sufficientlysecure.keychain.BuildConfig; - -/** - * Temporary workaround for https://github.com/robolectric/robolectric/issues/1747 - */ -public final class WorkaroundBuildConfig { - public static final boolean DEBUG = BuildConfig.DEBUG; - // Workaround: Use real packageName not applicationId - public static final String APPLICATION_ID = "org.sufficientlysecure.keychain"; - public static final String BUILD_TYPE = BuildConfig.BUILD_TYPE; - public static final String FLAVOR = BuildConfig.FLAVOR; - public static final int VERSION_CODE = BuildConfig.VERSION_CODE; - public static final String VERSION_NAME = BuildConfig.VERSION_NAME; -} diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/AuthenticationOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/AuthenticationOperationTest.java index 38d326986..acb20b825 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/AuthenticationOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/AuthenticationOperationTest.java @@ -133,7 +133,7 @@ public class AuthenticationOperationTest { @Before public void setUp() { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -153,13 +153,13 @@ public class AuthenticationOperationTest { byte[] challenge = "dies ist ein challenge ☭".getBytes(); byte[] signature; - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingRsa.getMasterKeyId(); Long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); { // sign challenge - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); @@ -199,13 +199,13 @@ public class AuthenticationOperationTest { byte[] challenge = "dies ist ein challenge ☭".getBytes(); byte[] signature; - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingEcDsa.getMasterKeyId(); Long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); { // sign challenge - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); @@ -245,13 +245,13 @@ public class AuthenticationOperationTest { byte[] challenge = "dies ist ein challenge ☭".getBytes(); byte[] signature; - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingEdDsa.getMasterKeyId(); Long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); { // sign challenge - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); @@ -294,13 +294,13 @@ public class AuthenticationOperationTest { byte[] challenge = "dies ist ein challenge ☭".getBytes(); byte[] signature; - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingDsa.getMasterKeyId(); Long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); { // sign challenge - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); @@ -339,13 +339,13 @@ public class AuthenticationOperationTest { byte[] challenge = "dies ist ein challenge ☭".getBytes(); - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingEcDsa.getMasterKeyId(); Long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); { // sign challenge - should succeed with selected key allowed - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); @@ -368,7 +368,7 @@ public class AuthenticationOperationTest { Assert.assertTrue("authentication must succeed with selected key allowed", result.success()); } { // sign challenge - should fail with selected key disallowed - AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.application, + AuthenticationOperation op = new AuthenticationOperation(RuntimeEnvironment.getApplication(), keyRepository); AuthenticationData.Builder authData = AuthenticationData.builder(); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BackupOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BackupOperationTest.java index 596e1d989..20fd404a0 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BackupOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BackupOperationTest.java @@ -135,7 +135,7 @@ public class BackupOperationTest { @Before public void setUp() { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -149,8 +149,8 @@ public class BackupOperationTest { @Test public void testExportAllLocalStripped() throws Exception { - BackupOperation op = new BackupOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + BackupOperation op = new BackupOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), 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)); @@ -230,8 +230,8 @@ public class BackupOperationTest { @Test public void testExportWithExtraHeaders() throws Exception { - BackupOperation op = new BackupOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + BackupOperation op = new BackupOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); ByteArrayOutputStream out = new ByteArrayOutputStream(); boolean result = op.exportKeysToStream( @@ -252,11 +252,11 @@ public class BackupOperationTest { ByteArrayOutputStream outStream1 = new ByteArrayOutputStream(); when(mockResolver.openOutputStream(fakeOutputUri)).thenReturn(outStream1); - Application spyApplication = spy(RuntimeEnvironment.application); + Application spyApplication = spy(RuntimeEnvironment.getApplication()); when(spyApplication.getContentResolver()).thenReturn(mockResolver); BackupOperation op = new BackupOperation(spyApplication, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); BackupKeyringParcel parcel = BackupKeyringParcel.create( new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri); @@ -305,7 +305,7 @@ public class BackupOperationTest { outStream = new ByteArrayOutputStream(); when(mockResolver.openOutputStream(fakeOutputUri)).thenReturn(outStream); - spyApplication = spy(RuntimeEnvironment.application); + spyApplication = spy(RuntimeEnvironment.getApplication()); when(spyApplication.getContentResolver()).thenReturn(mockResolver); } @@ -313,7 +313,7 @@ public class BackupOperationTest { { // export encrypted BackupOperation op = new BackupOperation(spyApplication, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); BackupKeyringParcel parcel = BackupKeyringParcel.create( new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri); @@ -330,8 +330,8 @@ public class BackupOperationTest { } { - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setAllowSymmetricDecryption(true) diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BenchmarkOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BenchmarkOperationTest.java index 4ec73b25a..fd835bed7 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BenchmarkOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/BenchmarkOperationTest.java @@ -46,8 +46,8 @@ public class BenchmarkOperationTest { @Test public void testBenchmark() throws Exception { - BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); op.execute(BenchmarkInputParcel.newInstance(), null); } diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java index 16a0b755d..78038f7aa 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java @@ -118,7 +118,7 @@ public class CertifyOperationTest { @Before public void setUp() throws Exception { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -133,7 +133,7 @@ public class CertifyOperationTest { @Test public void testSelfCertifyFlag() throws Exception { - CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application) + CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .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,11 +143,11 @@ public class CertifyOperationTest { @Test public void testCertifyId() throws Exception { - CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null, null); + CertifyOperation op = new CertifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null, null); { - CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application) + CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId()); Assert.assertNull("public key must not be marked verified prior to certification", ring.getVerified()); @@ -161,7 +161,7 @@ public class CertifyOperationTest { Assert.assertTrue("certification must succeed", result.success()); { - CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application) + CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId()); Assert.assertEquals("new key must be verified now", VerificationStatus.VERIFIED_SECRET, ring.getVerified()); @@ -171,8 +171,8 @@ public class CertifyOperationTest { @Test public void testCertifyAttribute() throws Exception { - KeyWritableRepository keyWritableRepository = KeyWritableRepository.create(RuntimeEnvironment.application); - CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application, keyWritableRepository, null, null); + KeyWritableRepository keyWritableRepository = KeyWritableRepository.create(RuntimeEnvironment.getApplication()); + CertifyOperation op = new CertifyOperation(RuntimeEnvironment.getApplication(), keyWritableRepository, null, null); { CanonicalizedPublicKeyRing ring = keyWritableRepository.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId()); @@ -198,8 +198,8 @@ public class CertifyOperationTest { @Test public void testCertifySelf() throws Exception { - CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null, null); + CertifyOperation op = new CertifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null, null); CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId()); actions.addAction(CertifyAction.createForUserIds(mStaticRing1.getMasterKeyId(), @@ -215,8 +215,8 @@ public class CertifyOperationTest { @Test public void testCertifyNonexistent() throws Exception { - CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null, null); + CertifyOperation op = new CertifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null, null); { CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId()); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java index 8e1f97b66..e4dfc4375 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java @@ -92,7 +92,7 @@ public class PromoteKeyOperationTest { @Before public void setUp() throws Exception { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -105,8 +105,8 @@ public class PromoteKeyOperationTest { @Test public void testPromote() throws Exception { - KeyWritableRepository keyRepository = KeyWritableRepository.create(RuntimeEnvironment.application); - PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application, + KeyWritableRepository keyRepository = KeyWritableRepository.create(RuntimeEnvironment.getApplication()); + PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.getApplication(), keyRepository, null, null); PromoteKeyResult result = op.execute( @@ -130,8 +130,8 @@ public class PromoteKeyOperationTest { @Test public void testPromoteDivert() throws Exception { - PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null, null); + PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null, null); byte[] aid = Hex.decode("D2760001240102000000012345670000"); @@ -141,7 +141,7 @@ public class PromoteKeyOperationTest { Assert.assertTrue("promotion must succeed", result.success()); { - CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application) + CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId()); for (CanonicalizedSecretKey key : ring.secretKeyIterator()) { @@ -156,8 +156,8 @@ public class PromoteKeyOperationTest { @Test public void testPromoteDivertSpecific() throws Exception { - PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null, null); + PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null, null); byte[] aid = Hex.decode("D2760001240102000000012345670000"); @@ -171,7 +171,7 @@ public class PromoteKeyOperationTest { Assert.assertTrue("promotion must succeed", result.success()); { - CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application) + CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId()); for (CanonicalizedSecretKey key : ring.secretKeyIterator()) { diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/InputDataOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/InputDataOperationTest.java index 2ad3aa659..14c9fc86d 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/InputDataOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/InputDataOperationTest.java @@ -126,11 +126,11 @@ public class InputDataOperationTest { .thenReturn(fakeOutputUri1, fakeOutputUri2); // application which returns mockresolver - Application spyApplication = spy(RuntimeEnvironment.application); + Application spyApplication = spy(RuntimeEnvironment.getApplication()); when(spyApplication.getContentResolver()).thenReturn(mockResolver); InputDataOperation op = new InputDataOperation(spyApplication, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputDataParcel input = InputDataParcel.createInputDataParcel(fakeInputUri, null); @@ -306,11 +306,11 @@ public class InputDataOperationTest { .thenReturn(fakeOutputUri1); // application which returns mockresolver - Application spyApplication = spy(RuntimeEnvironment.application); + Application spyApplication = spy(RuntimeEnvironment.getApplication()); when(spyApplication.getContentResolver()).thenReturn(mockResolver); InputDataOperation op = new InputDataOperation(spyApplication, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputDataParcel input = InputDataParcel.createInputDataParcel(FAKE_CONTENT_INPUT_URI_1, null); return op.execute(input, CryptoInputParcel.createCryptoInputParcel()); 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 b802165d1..a50e4f777 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java @@ -148,7 +148,7 @@ public class PgpEncryptDecryptTest { @Before public void setUp() { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -171,8 +171,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -195,8 +195,8 @@ public class PgpEncryptDecryptTest { ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); InputData data = new InputData(in, in.available()); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setAllowSymmetricDecryption(true) .build(); @@ -226,8 +226,8 @@ public class PgpEncryptDecryptTest { ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); InputData data = new InputData(in, in.available()); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setAllowSymmetricDecryption(true) .build(); @@ -249,8 +249,8 @@ public class PgpEncryptDecryptTest { ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); InputData data = new InputData(in, in.available()); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setAllowSymmetricDecryption(true) .build(); @@ -271,8 +271,8 @@ public class PgpEncryptDecryptTest { ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); InputData data = new InputData(in, in.available()); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder().build(); DecryptVerifyResult result = op.execute(input, CryptoInputParcel.createCryptoInputParcel(), data, out); @@ -297,8 +297,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -352,8 +352,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -413,8 +413,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -470,8 +470,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -572,8 +572,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -624,11 +624,11 @@ public class PgpEncryptDecryptTest { CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1)); KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); databaseInteractor.saveSecretKeyRing(modified); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setInputBytes(ciphertext) .build(); @@ -649,11 +649,11 @@ public class PgpEncryptDecryptTest { CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1)); KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); databaseInteractor.saveSecretKeyRing(modified); - PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder() .setInputBytes(ciphertext) .build(); @@ -680,7 +680,7 @@ public class PgpEncryptDecryptTest { CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1)); KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); databaseInteractor.saveSecretKeyRing(modified); } @@ -689,8 +689,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -733,8 +733,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -829,7 +829,7 @@ public class PgpEncryptDecryptTest { { // decryption with passphrase cached should succeed for the other key if first is gone // delete first key from database - KeyWritableRepository.create(RuntimeEnvironment.application).deleteKeyRing(mStaticRing1.getMasterKeyId()); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()).deleteKeyRing(mStaticRing1.getMasterKeyId()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); @@ -861,8 +861,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -908,7 +908,7 @@ public class PgpEncryptDecryptTest { { // decryption with passphrase cached should succeed for the other key if first is gone // delete first key from database - KeyWritableRepository.create(RuntimeEnvironment.application).deleteKeyRing(mStaticRing1.getMasterKeyId()); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()).deleteKeyRing(mStaticRing1.getMasterKeyId()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(ciphertext); @@ -944,8 +944,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(plaindata); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); @@ -1081,8 +1081,8 @@ public class PgpEncryptDecryptTest { private PgpDecryptVerifyOperation operationWithFakePassphraseCache( final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) { - return new PgpDecryptVerifyOperation(RuntimeEnvironment.application, - KeyWritableRepository.create(RuntimeEnvironment.application), null) { + return new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.create(RuntimeEnvironment.getApplication()), null) { @Override public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId) throws NoSecretKeyException { @@ -1112,8 +1112,8 @@ public class PgpEncryptDecryptTest { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream("dies ist ein plaintext ☭".getBytes()); - PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application, - KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null); + PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.getApplication(), + KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.getApplication()), null); InputData data = new InputData(in, in.available()); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/Cv25519Test.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/Cv25519Test.java index 0a85722cc..2c718001d 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/Cv25519Test.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/Cv25519Test.java @@ -66,7 +66,7 @@ public class Cv25519Test { @Before public void setUp() throws Exception { - context = RuntimeEnvironment.application; + context = RuntimeEnvironment.getApplication(); keyRepository = KeyWritableRepository.create(context); } diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/EddsaTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/EddsaTest.java index 72a1ca482..94ca45bf6 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/EddsaTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/EddsaTest.java @@ -76,7 +76,7 @@ public class EddsaTest { @Before public void setUp() throws Exception { - context = RuntimeEnvironment.application; + context = RuntimeEnvironment.getApplication(); keyRepository = KeyWritableRepository.create(context); } diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java index 5bbbd4833..ee9904a88 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java @@ -228,14 +228,14 @@ public class InteropTest { private PgpDecryptVerifyOperation makeOperation(final String msg, final Passphrase passphrase, UncachedKeyRing decrypt, UncachedKeyRing verify) { - KeyWritableRepository keyRepository = KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository keyRepository = KeyWritableRepository.create(RuntimeEnvironment.getApplication()); Assert.assertTrue(keyRepository.saveSecretKeyRing(decrypt).success()); if (verify != null) { Assert.assertTrue(keyRepository.savePublicKeyRing(verify).success()); } - return new PgpDecryptVerifyOperation(RuntimeEnvironment.application, keyRepository, null) { + return new PgpDecryptVerifyOperation(RuntimeEnvironment.getApplication(), keyRepository, null) { @Override public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId) { Assert.assertEquals(msg + ": passphrase should be for the secret key", diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryKeyringTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryKeyringTest.java index 9e6cc03c4..1614183f7 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryKeyringTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryKeyringTest.java @@ -34,14 +34,14 @@ public class KeyRepositoryKeyringTest { @Test public void testSavePublicKeyring() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(Collections.singleton( + Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.getApplication()).addKeyring(Collections.singleton( "/public-key-for-sample.blob" ))); } // @Test public void testSavePublicKeyringRsa() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList( + Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.getApplication()).addKeyring(prependResourcePath(Arrays.asList( "000001-006.public_key", "000002-013.user_id", "000003-002.sig", @@ -62,7 +62,7 @@ public class KeyRepositoryKeyringTest { // @Test public void testSavePublicKeyringDsa() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList( + Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.getApplication()).addKeyring(prependResourcePath(Arrays.asList( "000016-006.public_key", "000017-002.sig", "000018-012.ring_trust", @@ -79,7 +79,7 @@ public class KeyRepositoryKeyringTest { // @Test public void testSavePublicKeyringDsa2() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList( + Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.getApplication()).addKeyring(prependResourcePath(Arrays.asList( "000027-006.public_key", "000028-002.sig", "000029-012.ring_trust", diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java index 8e18d4357..ff87027d0 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java @@ -47,7 +47,7 @@ import java.util.Iterator; public class KeyRepositorySaveTest { KeyWritableRepository mDatabaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); @BeforeClass public static void setUpOnce() { @@ -65,9 +65,9 @@ public class KeyRepositorySaveTest { SaveKeyringResult result; // insert both keys, second should fail - result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(first); + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()).savePublicKeyRing(first); Assert.assertTrue("first keyring import should succeed", result.success()); - result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(second); + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()).savePublicKeyRing(second); Assert.assertFalse("second keyring import should fail", result.success()); } @@ -81,9 +81,9 @@ public class KeyRepositorySaveTest { SaveKeyringResult result; - result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(second); + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()).savePublicKeyRing(second); Assert.assertTrue("first keyring import should succeed", result.success()); - result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(first); + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()).savePublicKeyRing(first); Assert.assertFalse("second keyring import should fail", result.success()); } @@ -102,14 +102,14 @@ public class KeyRepositorySaveTest { SaveKeyringResult result; // insert secret, this should fail because of missing self-cert - result = KeyWritableRepository.create(RuntimeEnvironment.application) + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .saveSecretKeyRing(seckey); Assert.assertFalse("secret keyring import before pubring import should fail", result.success()); // insert pubkey, then seckey - both should succeed - result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(pubkey); + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()).savePublicKeyRing(pubkey); Assert.assertTrue("public keyring import should succeed", result.success()); - result = KeyWritableRepository.create(RuntimeEnvironment.application) + result = KeyWritableRepository.create(RuntimeEnvironment.getApplication()) .saveSecretKeyRing(seckey); Assert.assertTrue("secret keyring import after pubring import should succeed", result.success()); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryTest.java index f7e3e7f62..586e77b0e 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositoryTest.java @@ -45,7 +45,7 @@ public class KeyRepositoryTest { testKeyring = KeyringTestingHelper.readRingFromResource("/test-keys/authenticate_multisub_with_revoked.asc"); KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); databaseInteractor.saveSecretKeyRing(testKeyring); } @@ -55,7 +55,7 @@ public class KeyRepositoryTest { long expectedEncryptSubKeyId = KeyFormattingUtils.convertKeyIdHexToKeyId("0xDA7207E385A44339"); long expectedSignSubKeyId = KeyFormattingUtils.convertKeyIdHexToKeyId("0xB8ECA89E054028D5"); - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = testKeyring.getMasterKeyId(); long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java index 9a21e4fbc..8a406dbf5 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java @@ -68,7 +68,7 @@ public class KeychainExternalProviderTest { public void setUp() throws Exception { ShadowLog.stream = System.out; - ShadowPackageManager packageManager = shadowOf(RuntimeEnvironment.application.getPackageManager()); + ShadowPackageManager packageManager = shadowOf(RuntimeEnvironment.getApplication().getPackageManager()); packageManager.setPackagesForUid(PACKAGE_UID, PACKAGE_NAME); PackageInfo packageInfo = new PackageInfo(); packageInfo.signatures = new Signature[] { new Signature(PACKAGE_SIGNATURE) }; @@ -81,9 +81,9 @@ public class KeychainExternalProviderTest { info.authority = KeychainExternalContract.CONTENT_AUTHORITY_EXTERNAL; Robolectric.buildContentProvider(KeychainExternalProvider.class).create(info); - apiAppDao = ApiAppDao.getInstance(RuntimeEnvironment.application); - apiPermissionHelper = new ApiPermissionHelper(RuntimeEnvironment.application, apiAppDao); - autocryptPeerDao = AutocryptPeerDao.getInstance(RuntimeEnvironment.application); + apiAppDao = ApiAppDao.getInstance(RuntimeEnvironment.getApplication()); + apiPermissionHelper = new ApiPermissionHelper(RuntimeEnvironment.getApplication(), apiAppDao); + autocryptPeerDao = AutocryptPeerDao.getInstance(RuntimeEnvironment.getApplication()); apiAppDao.insertApiApp(PACKAGE_NAME, PACKAGE_SIGNATURE); } @@ -329,7 +329,7 @@ public class KeychainExternalProviderTest { certifyActionsParcel.addAction( CertifyAction.createForUserIds(publicMasterKeyId, Collections.singletonList(userId))); CertifyOperation op = new CertifyOperation( - RuntimeEnvironment.application, databaseInteractor, new ProgressScaler(), null); + RuntimeEnvironment.getApplication(), databaseInteractor, new ProgressScaler(), null); CertifyResult certifyResult = op.execute(certifyActionsParcel.build(), CryptoInputParcel.createCryptoInputParcel()); assertTrue(certifyResult.success()); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenConnectionTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenConnectionTest.java index a711b8134..cd5664daf 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenConnectionTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenConnectionTest.java @@ -70,7 +70,7 @@ public class SecurityTokenConnectionTest { "c59cd0f2a59cd0af059cd0c959000"); // get application related data - securityTokenConnection.connectToDevice(RuntimeEnvironment.application); + securityTokenConnection.connectToDevice(RuntimeEnvironment.getApplication()); verify(transport).connect(); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/ssh/SshPublicKeyTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/ssh/SshPublicKeyTest.java index 2e79a6a80..07261c02d 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/ssh/SshPublicKeyTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/ssh/SshPublicKeyTest.java @@ -60,7 +60,7 @@ public class SshPublicKeyTest { @Before public void setUp() { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); // don't log verbosely here, we're not here to test imports ShadowLog.stream = oldShadowStream; @@ -73,7 +73,7 @@ public class SshPublicKeyTest { @Test public void testECDSA() throws Exception { - KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.application); + KeyRepository keyRepository = KeyRepository.create(RuntimeEnvironment.getApplication()); long masterKeyId = mStaticRingEcDsa.getMasterKeyId(); long authSubKeyId = keyRepository.getEffectiveAuthenticationKeyId(masterKeyId); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/util/ParcelableFileCacheTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/util/ParcelableFileCacheTest.java index 3bda809d4..86b8acc87 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/util/ParcelableFileCacheTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/util/ParcelableFileCacheTest.java @@ -41,7 +41,7 @@ public class ParcelableFileCacheTest { @Test public void testInputOutput() throws Exception { - ParcelableFileCache cache = new ParcelableFileCache(RuntimeEnvironment.application, "test.pcl"); + ParcelableFileCache cache = new ParcelableFileCache(RuntimeEnvironment.getApplication(), "test.pcl"); ArrayList list = new ArrayList();