summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2024-06-17 02:52:06 +0200
committercyBerta <cyberta@riseup.net>2024-06-17 02:52:06 +0200
commitcd2e002c9e0f10079d8c1ec7af1d4be54a9de9e0 (patch)
treea9d514efbc47f2f47d8ac700996e4ef11d2f614c /app/src/test
parent3b3500e82fef981769cc6fff1dddc58cbe66ed48 (diff)
update obfsvpn to version 1.0.0, this is a breaking API change. Obfsvpn requires openvpn in UDP as inner transport protocol from now on
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/de/blinkt/openvpn/VpnProfileTest.java18
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java9
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java10
3 files changed, 11 insertions, 26 deletions
diff --git a/app/src/test/java/de/blinkt/openvpn/VpnProfileTest.java b/app/src/test/java/de/blinkt/openvpn/VpnProfileTest.java
index ad42ffde..eebee891 100644
--- a/app/src/test/java/de/blinkt/openvpn/VpnProfileTest.java
+++ b/app/src/test/java/de/blinkt/openvpn/VpnProfileTest.java
@@ -25,7 +25,7 @@ import de.blinkt.openvpn.core.connection.Obfs4Connection;
import de.blinkt.openvpn.core.connection.OpenvpnConnection;
import se.leap.bitmaskclient.base.models.Transport;
import se.leap.bitmaskclient.base.utils.BuildConfigHelper;
-import se.leap.bitmaskclient.pluggableTransports.Obfs4Options;
+import se.leap.bitmaskclient.pluggableTransports.models.Obfs4Options;
@RunWith(PowerMockRunner.class)
@PrepareForTest({UUID.class, BuildConfigHelper.class})
@@ -77,8 +77,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(false);
-
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4);
Transport transport = new Transport(OBFS4.toString(), new String[]{"tcp"}, new String[]{"1234"}, "CERT");
@@ -96,7 +94,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4_obfsvpn() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4);
Transport.Options options = new Transport.Options("CERT", "1");
Transport transport = new Transport(OBFS4.toString(), new String[]{"tcp"}, new String[]{"1234"}, options);
@@ -114,7 +111,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4_obfsvpn_kcp() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4);
Transport.Options options = new Transport.Options("CERT", "1");
@@ -133,7 +129,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4hop_kcp() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4_HOP);
@@ -154,7 +149,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4hop_portHopping() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4_HOP);
@@ -175,7 +169,6 @@ public class VpnProfileTest {
@Test
public void toJson_obfs4hop() throws JSONException {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OBFS4_HOP);
Transport.Options options = new Transport.Options("1", new Transport.Endpoint[]{new Transport.Endpoint("1.1.1.1", "CERT1"), new Transport.Endpoint("2.2.2.2", "CERT2")}, 200, 100, true);
@@ -195,7 +188,6 @@ public class VpnProfileTest {
@Test
public void fromJson_obfs4() {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(false);
VpnProfile mockVpnProfile = VpnProfile.fromJson(OBFS4CONNECTION_PROFILE);
assertNotNull(mockVpnProfile);
@@ -210,14 +202,13 @@ public class VpnProfileTest {
}
assertEquals("CERT", obfs4Connection.getObfs4Options().transport.getOptions().getCert());
assertEquals("0", obfs4Connection.getObfs4Options().transport.getOptions().getIatMode());
- assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().gatewayIP);
+ assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().bridgeIP);
assertEquals("1234", obfs4Connection.getObfs4Options().transport.getPorts()[0]);
assertEquals(1, obfs4Connection.getObfs4Options().transport.getPorts().length);
}
@Test
public void fromJson_obfs4_obfsvpn() {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = VpnProfile.fromJson(OBFS4CONNECTION_PROFILE_OBFSVPN);
assertNotNull(mockVpnProfile);
@@ -229,14 +220,13 @@ public class VpnProfileTest {
assertEquals("tcp", obfs4Connection.getObfs4Options().transport.getProtocols()[0]);
assertEquals("CERT", obfs4Connection.getObfs4Options().transport.getOptions().getCert());
assertEquals("1", obfs4Connection.getObfs4Options().transport.getOptions().getIatMode());
- assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().gatewayIP);
+ assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().bridgeIP);
assertEquals("1234", obfs4Connection.getObfs4Options().transport.getPorts()[0]);
assertEquals(1, obfs4Connection.getObfs4Options().transport.getPorts().length);
}
@Test
public void fromJson_obfs4_obfsvpn_kcp() {
- when(BuildConfigHelper.useObfsVpn()).thenReturn(true);
VpnProfile mockVpnProfile = VpnProfile.fromJson(OBFS4CONNECTION_PROFILE_OBFSVPN_KCP);
assertNotNull(mockVpnProfile);
@@ -248,7 +238,7 @@ public class VpnProfileTest {
assertEquals("kcp", obfs4Connection.getObfs4Options().transport.getProtocols()[0]);
assertEquals("CERT", obfs4Connection.getObfs4Options().transport.getOptions().getCert());
assertEquals("1", obfs4Connection.getObfs4Options().transport.getOptions().getIatMode());
- assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().gatewayIP);
+ assertEquals("192.168.0.1", obfs4Connection.getObfs4Options().bridgeIP);
assertEquals("1234", obfs4Connection.getObfs4Options().transport.getPorts()[0]);
}
} \ No newline at end of file
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java
index 4b9e5d65..b17a51cf 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java
@@ -24,7 +24,6 @@ import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ConfigParser;
import de.blinkt.openvpn.core.connection.Connection;
import de.blinkt.openvpn.core.connection.Obfs4Connection;
-import de.blinkt.openvpn.core.connection.Obfs4HopConnection;
import se.leap.bitmaskclient.base.models.ProviderObservable;
import se.leap.bitmaskclient.base.utils.BuildConfigHelper;
import se.leap.bitmaskclient.base.utils.PreferenceHelper;
@@ -1709,7 +1708,7 @@ public class VpnConfigGeneratorTest {
configuration.experimentalTransports = true;
vpnConfigGenerator = new VpnConfigGenerator(generalConfig, secrets, gateway, configuration);
HashMap<Connection.TransportType, VpnProfile> vpnProfiles = vpnConfigGenerator.generateVpnProfiles();
- assertTrue(vpnProfiles.containsKey(OBFS4_HOP) && ((Obfs4HopConnection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
+ assertTrue(vpnProfiles.containsKey(OBFS4_HOP) && ((Obfs4Connection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
assertTrue(vpnProfiles.containsKey(OPENVPN));
}
@@ -1722,7 +1721,7 @@ public class VpnConfigGeneratorTest {
configuration.experimentalTransports = true;
vpnConfigGenerator = new VpnConfigGenerator(generalConfig, secrets, gateway, configuration);
HashMap<Connection.TransportType, VpnProfile> vpnProfiles = vpnConfigGenerator.generateVpnProfiles();
- assertTrue(vpnProfiles.containsKey(OBFS4_HOP) && ((Obfs4HopConnection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("kcp"));
+ assertTrue(vpnProfiles.containsKey(OBFS4_HOP) && ((Obfs4Connection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("kcp"));
assertTrue(vpnProfiles.containsKey(OPENVPN));
}
@@ -1779,7 +1778,7 @@ public class VpnConfigGeneratorTest {
vpnConfigGenerator = new VpnConfigGenerator(generalConfig, secrets, gateway, configuration);
HashMap<Connection.TransportType, VpnProfile> vpnProfiles = vpnConfigGenerator.generateVpnProfiles();
assertTrue(vpnProfiles.containsKey(OBFS4_HOP));
- assertTrue(((Obfs4HopConnection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
+ assertTrue(((Obfs4Connection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
assertFalse(vpnProfiles.containsKey(OPENVPN));
assertFalse(vpnProfiles.containsKey(OBFS4));
}
@@ -1813,7 +1812,7 @@ public class VpnConfigGeneratorTest {
vpnConfigGenerator = new VpnConfigGenerator(generalConfig, secrets, gateway, configuration);
HashMap<Connection.TransportType, VpnProfile> vpnProfiles = vpnConfigGenerator.generateVpnProfiles();
assertTrue(vpnProfiles.containsKey(OBFS4_HOP));
- assertTrue(((Obfs4HopConnection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
+ assertTrue(((Obfs4Connection)vpnProfiles.get(OBFS4_HOP).mConnections[0]).getObfs4Options().transport.getProtocols()[0].equals("tcp"));
assertFalse(vpnProfiles.containsKey(OPENVPN));
assertFalse(vpnProfiles.containsKey(OBFS4));
}
diff --git a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
index a7d3e19c..1b94042e 100644
--- a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
+++ b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
@@ -190,16 +190,12 @@ public class MockHelper {
}
- public static BuildConfigHelper mockBuildConfigHelper(boolean useObfsvpn) {
- return mockBuildConfigHelper(useObfsvpn, true);
+ public static BuildConfigHelper mockBuildConfigHelper() {
+ return mockBuildConfigHelper(true);
}
- public static BuildConfigHelper mockBuildConfigHelper(boolean useObfsvpn, boolean isDefaultBitmask) {
+ public static BuildConfigHelper mockBuildConfigHelper(boolean isDefaultBitmask) {
return new BuildConfigHelper(new BuildConfigHelper.BuildConfigHelperInterface() {
- @Override
- public boolean useObfsVpn() {
- return useObfsvpn;
- }
@Override
public boolean hasObfuscationPinningDefaults() {