From a457170cf50138104b5215d8affae0bc9874867c Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 7 Aug 2022 18:05:20 +0200 Subject: set riseup's main_url to black.riseup.net while still showing riseup.net as domain in the UI --- .../leap/bitmaskclient/base/utils/ConfigHelperTest.java | 16 ++++++++++++++-- .../java/se/leap/bitmaskclient/testutils/MockHelper.java | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'app/src/test/java/se/leap/bitmaskclient') 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() { -- cgit v1.2.3