From 95174abcb87af9d07465cda5c23cc35e1987b6d9 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 20 Mar 2021 17:15:37 +0100 Subject: add test for city based gateway selection with geo-ip service v1 --- .../se/leap/bitmaskclient/eip/GatewaysManagerTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/src/test/java') 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 @@ -249,6 +249,22 @@ public class GatewaysManagerTest { assertEquals("zarapito.riseup.net", gatewaysManager.select(2).getHost()); } + @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); -- cgit v1.2.3