summaryrefslogtreecommitdiff
path: root/app/src/test/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-07-15 22:08:57 +0200
committercyBerta <cyberta@riseup.net>2022-07-19 00:06:12 +0200
commit472a3fdb9c9036f5666e65b5dfd9bd91a51563f8 (patch)
tree42d36b0adf658f41add285e48204ecd5b1ee5206 /app/src/test/java
parent93c7fd8c592a85341e8dff594ba1ec535aa103c2 (diff)
add UI to enable experimental kcp transport if the client uses obfsvpn instead of shapeshifter and the provider supports the kcp variant
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java83
1 files changed, 79 insertions, 4 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java b/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java
index aaf3f255..8bff690b 100644
--- a/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java
@@ -1,21 +1,36 @@
package se.leap.bitmaskclient.base.models;
+import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashSet;
import java.util.Set;
-import se.leap.bitmaskclient.base.models.Provider;
+import se.leap.bitmaskclient.base.utils.ConfigHelper;
import se.leap.bitmaskclient.testutils.TestSetupHelper;
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Created by cyberta on 12.02.18.
*/
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ConfigHelper.ObfsVpnHelper.class})
public class ProviderTest {
+ @Before
+ public void setup() {
+ mockStatic(ConfigHelper.ObfsVpnHelper.class);
+ when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(false);
+ }
+
@Test
public void testEquals_sameFields_returnsTrue() throws Exception {
Provider p1 = TestSetupHelper.getConfiguredProvider();
@@ -84,4 +99,64 @@ public class ProviderTest {
assertFalse(p1.supportsPluggableTransports());
}
+ @Test
+ public void testIsExperimentalPluggableTransportsSupported_Obfs4_returnsFalse() throws Exception {
+ Provider p1 = TestSetupHelper.getProvider(
+ "https://pt.demo.bitmask.net",
+ null,
+ null,
+ null,
+ null,
+ null,
+ "ptdemo.bitmask.eip-service.json",
+ null);
+ assertFalse(p1.supportsExperimentalPluggableTransports());
+ }
+
+ @Test
+ public void testIsExperimentalPluggableTransportsSupported_Obfs4Kcp_returnsTrue() throws Exception {
+ Provider p1 = TestSetupHelper.getProvider(
+ "https://pt.demo.bitmask.net",
+ null,
+ null,
+ null,
+ null,
+ null,
+ "ptdemo_kcp_gateways.json",
+ null);
+ assertTrue(p1.supportsExperimentalPluggableTransports());
+ }
+
+ @Test
+ public void testSupportsPluggableTransports_Obfs4Kcp_noObsvpn_returnsFalse() throws Exception {
+ when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(false);
+
+ Provider p1 = TestSetupHelper.getProvider(
+ "https://pt.demo.bitmask.net",
+ null,
+ null,
+ null,
+ null,
+ null,
+ "ptdemo_only_experimental_transports_gateways.json",
+ null);
+ assertFalse(p1.supportsPluggableTransports());
+ }
+
+ @Test
+ public void testSupportsPluggableTransports_Obfs4Kcp_obsvpn_returnsTrue() throws Exception {
+ when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(true);
+
+ Provider p1 = TestSetupHelper.getProvider(
+ "https://pt.demo.bitmask.net",
+ null,
+ null,
+ null,
+ null,
+ null,
+ "ptdemo_only_experimental_transports_gateways.json",
+ null);
+ assertTrue(p1.supportsPluggableTransports());
+ }
+
}