summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java83
-rw-r--r--app/src/test/resources/ptdemo_only_experimental_transports_gateways.json134
2 files changed, 213 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());
+ }
+
}
diff --git a/app/src/test/resources/ptdemo_only_experimental_transports_gateways.json b/app/src/test/resources/ptdemo_only_experimental_transports_gateways.json
new file mode 100644
index 00000000..31c919e7
--- /dev/null
+++ b/app/src/test/resources/ptdemo_only_experimental_transports_gateways.json
@@ -0,0 +1,134 @@
+{
+ "gateways":[
+ {
+ "capabilities":{
+ "adblock":false,
+ "filter_dns":false,
+ "limited":false,
+ "transport":[
+ {
+ "type":"obfs4-1",
+ "protocols":[
+ "tcp"
+ ],
+ "ports":[
+ "23050"
+ ],
+ "options": {
+ "cert": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1",
+ "iatMode": "0"
+ }
+ },
+ {
+ "type":"openvpn",
+ "protocols":[
+ "tcp"
+ ],
+ "ports":[
+ "1195"
+ ]
+ }
+ ],
+ "user_ips":false
+ },
+ "host":"pt.demo.bitmask.net",
+ "ip_address":"37.218.247.60",
+ "location":"Amsterdam"
+ },
+ {
+ "capabilities":{
+ "adblock":false,
+ "filter_dns":false,
+ "limited":false,
+ "transport":[
+ {
+ "type":"openvpn",
+ "protocols":[
+ "tcp"
+ ],
+ "ports":[
+ "1195"
+ ]
+ }
+ ],
+ "user_ips":false
+ },
+ "host":"moscow.bitmask.net",
+ "ip_address":"3.21.247.89",
+ "location":"moscow"
+ },
+ {
+ "capabilities":{
+ "adblock":false,
+ "filter_dns":false,
+ "limited":false,
+ "transport":[
+ {
+ "type":"openvpn",
+ "protocols":[
+ "tcp",
+ "udp"
+ ],
+
+ "ports":[
+ "1195"
+ ]
+ },
+ {
+ "type":"obfs4-1",
+ "protocols":[
+ "tcp"
+ ],
+ "ports":[
+ "23050"
+ ],
+ "options": {
+ "cert": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1",
+ "iatMode": "0"
+ }
+ }
+ ],
+ "user_ips":false
+ },
+ "host":"manila.bitmask.net",
+ "ip_address":"37.12.247.10",
+ "location":"manila"
+ }
+ ],
+ "locations":{
+ "Amsterdam":{
+ "country_code":"NL",
+ "hemisphere":"N",
+ "name":"Amsterdam",
+ "timezone":"-1"
+ },
+ "moscow": {
+ "country_code": "RU",
+ "hemisphere": "N",
+ "name": "Moscow",
+ "timezone": "+3"
+ },
+ "manila": {
+ "country_code": "PH",
+ "hemisphere": "N",
+ "name": "Manila",
+ "timezone": "+8"
+ }
+ },
+ "openvpn_configuration":{
+ "auth":"SHA1",
+ "cipher":"AES-256-CBC",
+ "keepalive":"10 30",
+ "tls-cipher":"DHE-RSA-AES128-SHA",
+ "tun-ipv6":true,
+ "dev" : "tun",
+ "sndbuf" : "0",
+ "rcvbuf" : "0",
+ "nobind" : true,
+ "persist-key" : true,
+ "key-direction" : "1",
+ "verb" : "3"
+ },
+ "serial":2,
+ "version":3
+} \ No newline at end of file