summaryrefslogtreecommitdiff
path: root/app/src/test/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-11-23 14:51:33 +0100
committercyBerta <cyberta@riseup.net>2021-11-23 14:51:33 +0100
commitf29ee8ac7378408e070be1130c9cadc8e947ddb3 (patch)
tree5b6cf94738065434a41ca5a69be049d3b261d3cf /app/src/test/java
parent438b2b866b64f63dc1346ca89cf3e56847def6da (diff)
sort locations by transport
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java57
1 files changed, 57 insertions, 0 deletions
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 33abfbed..43a6a496 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
@@ -451,6 +451,63 @@ public class GatewaysManagerTest {
}
}
+
+ @Test
+ public void testGetSortedLocations_openvpn() {
+ Provider provider = getProvider(null, null, null, null, null, null, "v4/riseup_eipservice_for_geoip_v4.json", "v4/riseup_geoip_v4_bad_obfs4_gateway.json");
+
+ MockHelper.mockProviderObservable(provider);
+ mockStatic(PreferenceHelper.class);
+ when(PreferenceHelper.getUseBridges(any(Context.class))).thenReturn(false);
+ GatewaysManager gatewaysManager = new GatewaysManager(mockContext);
+ List<Location> locations = gatewaysManager.getSortedGatewayLocations(OPENVPN);
+
+ assertEquals(3, locations.size());
+
+ /** -> v4/riseup_geoip_v4_bad_obfs4_gateway.json OPENVPN
+ * Paris = 0.527
+ * 0.36 - zarapito
+ * 0.92 - hoazin
+ * 0.3 - mouette
+ *
+ * Montreal = 0.59
+ * 0.59 - yal
+ *
+ * Amsterdam = 0.8
+ * 0.8 - redshank
+ */
+ assertEquals("Paris", locations.get(0).getName());
+ assertEquals("Montreal", locations.get(1).getName());
+ assertEquals("Amsterdam", locations.get(2).getName());
+ }
+
+ @Test
+ public void testGetSortedLocations_obfs4() {
+ Provider provider = getProvider(null, null, null, null, null, null, "v4/riseup_eipservice_for_geoip_v4.json", "v4/riseup_geoip_v4_bad_obfs4_gateway.json");
+
+ MockHelper.mockProviderObservable(provider);
+ mockStatic(PreferenceHelper.class);
+ when(PreferenceHelper.getUseBridges(any(Context.class))).thenReturn(false);
+ GatewaysManager gatewaysManager = new GatewaysManager(mockContext);
+ List<Location> locations = gatewaysManager.getSortedGatewayLocations(OBFS4);
+
+ assertEquals(3, locations.size());
+
+ /** -> v4/riseup_geoip_v4_bad_obfs4_gateway.json OBFS4
+ * Paris = 0.92
+ * 0.92 - hoazin
+ *
+ * Montreal = 0.59
+ * 0.59 - yal
+ *
+ * Amsterdam = 0.0 - no obfs4
+ * 0.0 - redshank
+ */
+ assertEquals("Montreal", locations.get(0).getName());
+ assertEquals("Paris", locations.get(1).getName());
+ assertEquals("Amsterdam", locations.get(2).getName());
+ }
+
private String getJsonStringFor(String filename) throws IOException {
return TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream(filename));
}