summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2023-10-26 15:57:37 +0200
committercyBerta <cyberta@riseup.net>2023-10-26 15:57:37 +0200
commit5be2ebddf13059dc5cf817c99709b8c467f9b6dd (patch)
tree3bc4f4eb1145b025cea1243e65a2482df067e330 /app
parentf74107e3c47824e1cf4fdbc415d32871eb85f83c (diff)
fixing tests
Diffstat (limited to 'app')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
index a478af63..4af0d072 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
@@ -19,7 +19,9 @@ package se.leap.bitmaskclient.eip;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY;
import static se.leap.bitmaskclient.base.models.Constants.EIP_ACTION_START;
import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY;
@@ -90,6 +92,7 @@ import se.leap.bitmaskclient.providersetup.ProviderAPI;
import se.leap.bitmaskclient.providersetup.ProviderApiConnector;
import se.leap.bitmaskclient.providersetup.ProviderApiManager;
import se.leap.bitmaskclient.providersetup.ProviderApiManagerBase;
+import se.leap.bitmaskclient.providersetup.ProviderSetupObservable;
import se.leap.bitmaskclient.tor.TorStatusObservable;
@@ -98,7 +101,7 @@ import se.leap.bitmaskclient.tor.TorStatusObservable;
*/
@RunWith(PowerMockRunner.class)
-@PrepareForTest({ProviderApiManager.class, TextUtils.class, ConfigHelper.RSAHelper.class, ConfigHelper.class, ProviderApiConnector.class, PreferenceHelper.class, TorStatusObservable.class, android.util.Base64.class})
+@PrepareForTest({ProviderApiManager.class, TextUtils.class, ConfigHelper.RSAHelper.class, ConfigHelper.class, ProviderApiConnector.class, PreferenceHelper.class, TorStatusObservable.class, android.util.Base64.class, ProviderSetupObservable.class})
public class ProviderApiManagerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -189,6 +192,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -211,6 +216,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -233,6 +240,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(getConfiguredProvider());
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -278,6 +287,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29495");
mockProviderApiConnector(NO_ERROR);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -424,6 +435,8 @@ public class ProviderApiManagerTest {
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(ERROR_CASE_MICONFIGURED_PROVIDER);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -452,6 +465,7 @@ public class ProviderApiManagerTest {
mockProviderApiConnector(ERROR_CASE_MICONFIGURED_PROVIDER);
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
when(ConfigHelper.isDefaultBitmask()).thenReturn(false);
+ mockStatic(ProviderSetupObservable.class);
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
@@ -477,6 +491,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -504,6 +520,8 @@ public class ProviderApiManagerTest {
mockConfigHelper("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(ERROR_CASE_FETCH_EIP_SERVICE_CERTIFICATE_INVALID);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -688,6 +706,8 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR_API_V4);
+ mockStatic(ProviderSetupObservable.class);
+
providerApiManager = new ProviderApiManager(mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
Bundle expectedResult = mockBundle();
@@ -710,6 +730,7 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
when(PreferenceHelper.hasSnowflakePrefs()).thenReturn(false);
when(PreferenceHelper.getUseSnowflake()).thenReturn(true); // getUseSnowflake() defaults to true if not set
+ mockStatic(ProviderSetupObservable.class);
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(ERROR_DNS_RESUOLUTION_TOR_FALLBACK);
@@ -772,6 +793,7 @@ public class ProviderApiManagerTest {
mockPreferenceHelper(provider);
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR_API_V4);
+ mockStatic(ProviderSetupObservable.class);
when(PreferenceHelper.getUseBridges()).thenReturn(true);
when(PreferenceHelper.getUseSnowflake()).thenReturn(true);
@@ -798,6 +820,7 @@ public class ProviderApiManagerTest {
mockConfigHelper(" a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
mockProviderApiConnector(NO_ERROR_API_V4);
+ mockStatic(ProviderSetupObservable.class);
when(PreferenceHelper.getUseBridges()).thenReturn(false);
when(PreferenceHelper.getUseSnowflake()).thenReturn(false);
when(PreferenceHelper.hasSnowflakePrefs()).thenReturn(true);