summaryrefslogtreecommitdiff
path: root/app/src/test/java/se
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test/java/se')
-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() {