diff options
author | cyBerta <cyberta@riseup.net> | 2019-10-05 23:36:27 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-10-05 23:36:27 +0200 |
commit | c637bffe1c9843b9de7366eee3584c51360e3867 (patch) | |
tree | 020bca50e13207abfab391c5cb94b176a39cdc3a /app/src/test/java/se/leap | |
parent | b07bdead9919324113fc53c465dcc600f6fa222e (diff) |
ignore gateways with invalid transports while still adding gateways with valid configurations
Diffstat (limited to 'app/src/test/java/se/leap')
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/eip/GatewaySelectorTest.java | 3 | ||||
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaySelectorTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaySelectorTest.java index 2f5ae9b6..5089de54 100644 --- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaySelectorTest.java +++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaySelectorTest.java @@ -49,6 +49,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import de.blinkt.openvpn.core.ConfigParser; import se.leap.bitmaskclient.Provider; import se.leap.bitmaskclient.utils.ConfigHelper; @@ -99,7 +100,7 @@ public class GatewaySelectorTest { ArrayList<Gateway> gatewayList = new ArrayList<>(); @Before - public void setup() throws IOException, JSONException { + public void setup() throws IOException, JSONException, ConfigParser.ConfigParseError { mockStatic(ConfigHelper.class); eipDefinition = new JSONObject(getInputAsString(getClass().getClassLoader().getResourceAsStream("eip-service-four-gateways.json"))); JSONArray gateways = eipDefinition.getJSONArray("gateways"); diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java index e4c5f390..46e166d4 100644 --- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java +++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java @@ -14,12 +14,14 @@ import org.mockito.junit.MockitoJUnitRunner; import java.io.IOException; +import de.blinkt.openvpn.core.connection.Connection; import se.leap.bitmaskclient.Constants; import se.leap.bitmaskclient.Provider; import se.leap.bitmaskclient.testutils.TestSetupHelper; import static junit.framework.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyInt; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; @@ -68,6 +70,15 @@ public class GatewaysManagerTest { } @Test + public void testFromEipServiceJson_ignoreGatewaysWithMisconfiguredTransportsWhileAddingValidOnes() throws Exception { + String eipServiceJson = TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream("ptdemo_misconfigured_mixed_gateways.json")); + gatewaysManager.fromEipServiceJson(new JSONObject(eipServiceJson)); + assertEquals(1, gatewaysManager.size()); + assertNull(gatewaysManager.select(0).getProfile(Connection.TransportType.OBFS4)); + assertNotNull(gatewaysManager.select(0).getProfile(Connection.TransportType.OPENVPN)); + } + + @Test public void testFromEipServiceJson_ignoreDuplicateGateways() throws Exception { String eipServiceJson = TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream("eip-service-two-gateways.json")); gatewaysManager.fromEipServiceJson(new JSONObject(eipServiceJson)); |