summaryrefslogtreecommitdiff
path: root/app/src/test/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-08-07 18:05:20 +0200
committercyBerta <cyberta@riseup.net>2022-08-07 18:05:20 +0200
commita457170cf50138104b5215d8affae0bc9874867c (patch)
tree90ab7bf0333d98ca477e22f532297b57858dccc8 /app/src/test/java
parentcc354bc34d4c801242eee89a416b088934f9935c (diff)
set riseup's main_url to black.riseup.net while still showing riseup.net as domain in the UI
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java16
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java1
2 files changed, 15 insertions, 2 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java b/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
index 75552226..6e0ceb56 100644
--- a/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
@@ -1,5 +1,7 @@
package se.leap.bitmaskclient.base.utils;
+import static org.junit.Assert.assertEquals;
+
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
@@ -9,8 +11,6 @@ import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.junit.Assert.assertEquals;
-
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(DataProviderRunner.class)
public class ConfigHelperTest {
@@ -45,4 +45,16 @@ public class ConfigHelperTest {
public void testisIPv4_validIPs_returnsTrue(String ip, boolean isValidExpected) {
assertEquals(isValidExpected, ConfigHelper.isIPv4(ip));
}
+
+ @Test
+ public void testGetDomainFromMainURL_ignoreSubdomain() {
+ assertEquals("riseup.net", ConfigHelper.getDomainFromMainURL("https://black.riseup.net"));
+ assertEquals("riseup.net", ConfigHelper.getDomainFromMainURL("https://riseup.net"));
+ }
+
+ @Test
+ public void testGetDomainFromMainURL_handleSuffix() {
+ assertEquals("domain.co.uk", ConfigHelper.getDomainFromMainURL("https://subdomain.domain.co.uk"));
+ assertEquals("domain.co.uk", ConfigHelper.getDomainFromMainURL("https://domain.co.uk"));
+ }
} \ No newline at end of file
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 a455a4bf..c6ba1e6f 100644
--- a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
+++ b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
@@ -425,6 +425,7 @@ public class MockHelper {
when(ConfigHelper.timezoneDistance(anyInt(), anyInt())).thenCallRealMethod();
when(ConfigHelper.isIPv4(anyString())).thenCallRealMethod();
when(ConfigHelper.isDefaultBitmask()).thenReturn(true);
+ when(ConfigHelper.getDomainFromMainURL(anyString())).thenCallRealMethod();
when(ConfigHelper.parseRsaKeyFromString(anyString())).thenReturn(new RSAPrivateKey() {
@Override
public BigInteger getPrivateExponent() {