diff options
Diffstat (limited to 'app/src/test/java/se')
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java | 83 |
1 files changed, 79 insertions, 4 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java b/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java index aaf3f255..8bff690b 100644 --- a/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java +++ b/app/src/test/java/se/leap/bitmaskclient/base/models/ProviderTest.java @@ -1,21 +1,36 @@ package se.leap.bitmaskclient.base.models; +import static junit.framework.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.mockStatic; + +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashSet; import java.util.Set; -import se.leap.bitmaskclient.base.models.Provider; +import se.leap.bitmaskclient.base.utils.ConfigHelper; import se.leap.bitmaskclient.testutils.TestSetupHelper; -import static junit.framework.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - /** * Created by cyberta on 12.02.18. */ + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ConfigHelper.ObfsVpnHelper.class}) public class ProviderTest { + @Before + public void setup() { + mockStatic(ConfigHelper.ObfsVpnHelper.class); + when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(false); + } + @Test public void testEquals_sameFields_returnsTrue() throws Exception { Provider p1 = TestSetupHelper.getConfiguredProvider(); @@ -84,4 +99,64 @@ public class ProviderTest { assertFalse(p1.supportsPluggableTransports()); } + @Test + public void testIsExperimentalPluggableTransportsSupported_Obfs4_returnsFalse() throws Exception { + Provider p1 = TestSetupHelper.getProvider( + "https://pt.demo.bitmask.net", + null, + null, + null, + null, + null, + "ptdemo.bitmask.eip-service.json", + null); + assertFalse(p1.supportsExperimentalPluggableTransports()); + } + + @Test + public void testIsExperimentalPluggableTransportsSupported_Obfs4Kcp_returnsTrue() throws Exception { + Provider p1 = TestSetupHelper.getProvider( + "https://pt.demo.bitmask.net", + null, + null, + null, + null, + null, + "ptdemo_kcp_gateways.json", + null); + assertTrue(p1.supportsExperimentalPluggableTransports()); + } + + @Test + public void testSupportsPluggableTransports_Obfs4Kcp_noObsvpn_returnsFalse() throws Exception { + when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(false); + + Provider p1 = TestSetupHelper.getProvider( + "https://pt.demo.bitmask.net", + null, + null, + null, + null, + null, + "ptdemo_only_experimental_transports_gateways.json", + null); + assertFalse(p1.supportsPluggableTransports()); + } + + @Test + public void testSupportsPluggableTransports_Obfs4Kcp_obsvpn_returnsTrue() throws Exception { + when(ConfigHelper.ObfsVpnHelper.useObfsVpn()).thenReturn(true); + + Provider p1 = TestSetupHelper.getProvider( + "https://pt.demo.bitmask.net", + null, + null, + null, + null, + null, + "ptdemo_only_experimental_transports_gateways.json", + null); + assertTrue(p1.supportsPluggableTransports()); + } + } |