summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-03-20 17:15:37 +0100
committercyberta <cyberta@riseup.net>2021-04-22 22:53:01 +0200
commit95174abcb87af9d07465cda5c23cc35e1987b6d9 (patch)
tree6a58f3d441789593b4671936c02db0c5ba142b5c /app
parent1d2e09736a0526c574fe4c541d2f83c1ef44ccc0 (diff)
add test for city based gateway selection with geo-ip service v1
Diffstat (limited to 'app')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java16
-rw-r--r--app/src/test/resources/v4/riseup_geoip_v1.json14
2 files changed, 30 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 69c54db9..255d98e0 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
@@ -250,6 +250,22 @@ public class GatewaysManagerTest {
}
@Test
+ public void testSelectN_selectFromCityWithGeoIpServiceV1_returnsGatewaysInPresortedOrder() {
+ Provider provider = getProvider(null, null, null, null, null, null, "v4/riseup_eipservice_for_geoip_v4.json", "v4/riseup_geoip_v1.json");
+
+ MockHelper.mockProviderObserver(provider);
+ //use openvpn, not pluggable transports
+ mockStatic(PreferenceHelper.class);
+ when(PreferenceHelper.getUsePluggableTransports(any(Context.class))).thenReturn(false);
+ when(PreferenceHelper.getPreferredCity(any(Context.class))).thenReturn("Paris");
+ GatewaysManager gatewaysManager = new GatewaysManager(mockContext);
+
+ assertEquals("mouette.riseup.net", gatewaysManager.select(0).getHost());
+ assertEquals("hoatzin.riseup.net", gatewaysManager.select(1).getHost());
+ assertEquals("zarapito.riseup.net", gatewaysManager.select(2).getHost());
+ }
+
+ @Test
public void testSelectN_selectFromCityWithTimezoneCalculation_returnsRandomizedGatewaysOfSelectedCity() {
Provider provider = getProvider(null, null, null, null, null, null, "v4/riseup_eipservice_for_geoip_v4.json", null);
diff --git a/app/src/test/resources/v4/riseup_geoip_v1.json b/app/src/test/resources/v4/riseup_geoip_v1.json
new file mode 100644
index 00000000..4e3bda2a
--- /dev/null
+++ b/app/src/test/resources/v4/riseup_geoip_v1.json
@@ -0,0 +1,14 @@
+{
+ "ip":"51.158.144.32",
+ "cc":"FR",
+ "city":"Paris",
+ "lat":48.8628,
+ "lon":2.3292,
+ "gateways":[
+ "mouette.riseup.net",
+ "hoatzin.riseup.net",
+ "yal.riseup.net",
+ "redshank.riseup.net",
+ "zarapito.riseup.net"
+ ]
+} \ No newline at end of file