diff options
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/providersetup/connectivity/DnsResolver.java | 2 | ||||
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/connectivity/DnsResolver.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/connectivity/DnsResolver.java index f4654d0b..e8249692 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/connectivity/DnsResolver.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/connectivity/DnsResolver.java @@ -20,7 +20,7 @@ import se.leap.bitmaskclient.base.models.Provider; import se.leap.bitmaskclient.base.models.ProviderObservable; import se.leap.bitmaskclient.base.utils.IPAddress; -class DnsResolver implements Dns { +public class DnsResolver implements Dns { OkHttpClient dohHttpClient; boolean preferDoH; 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 d30e8b7e..c272970d 100644 --- a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java +++ b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java @@ -74,6 +74,7 @@ import se.leap.bitmaskclient.base.utils.ConfigHelper; import se.leap.bitmaskclient.base.utils.FileHelper; import se.leap.bitmaskclient.base.utils.InputStreamHelper; import se.leap.bitmaskclient.base.utils.PreferenceHelper; +import se.leap.bitmaskclient.providersetup.connectivity.DnsResolver; import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator; import se.leap.bitmaskclient.testutils.BackendMockResponses.BackendMockProvider; import se.leap.bitmaskclient.testutils.matchers.BundleMatcher; @@ -577,13 +578,14 @@ public class MockHelper { public static OkHttpClientGenerator mockClientGenerator(boolean resolveDNS) throws UnknownHostException { OkHttpClientGenerator mockClientGenerator = mock(OkHttpClientGenerator.class); - OkHttpClient mockedOkHttpClient = mock(OkHttpClient.class, RETURNS_DEEP_STUBS); + OkHttpClient mockedOkHttpClient = mock(OkHttpClient.class); + DnsResolver mockedDnsResolver = mock(DnsResolver.class); when(mockClientGenerator.initCommercialCAHttpClient(any(JSONObject.class), anyInt())).thenReturn(mockedOkHttpClient); when(mockClientGenerator.initSelfSignedCAHttpClient(anyString(), anyInt(), any(JSONObject.class))).thenReturn(mockedOkHttpClient); if (resolveDNS) { - when(mockedOkHttpClient.dns().lookup(anyString())).thenReturn(new ArrayList<>()); + when(mockedDnsResolver.lookup(anyString())).thenReturn(new ArrayList<>()); } else { - when(mockedOkHttpClient.dns().lookup(anyString())).thenThrow(new UnknownHostException()); + when(mockedDnsResolver.lookup(anyString())).thenThrow(new UnknownHostException()); } return mockClientGenerator; } |