summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-07-24 13:51:33 +0200
committercyBerta <cyberta@riseup.net>2020-07-24 13:51:33 +0200
commitd8b9f60f961e55d0a9204149eb0e8604b9479f55 (patch)
tree3144c5d5feada185ff736b14c02a6e9d95e62474 /app/src/test
parentacdd39af9962863b6d210b005e6aab340460bdaf (diff)
add test that geoip service is only fetched when the timeout was reached
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
index 469ccfc9..60a60580 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
@@ -501,5 +501,33 @@ public class ProviderApiManagerTest {
}
+ @Test
+ public void test_handleIntentGetGeoip_noNeedToUpdate_returnsFailure() throws IOException, NoSuchAlgorithmException, CertificateEncodingException, JSONException {
+ if ("insecure".equals(BuildConfig.FLAVOR_implementation)) {
+ return;
+ }
+
+ Provider provider = getConfiguredProvider();
+ provider.setLastGeoIpUpdate(System.currentTimeMillis());
+ mockFingerprintForCertificate("a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494");
+ mockProviderApiConnector(NO_ERROR);
+ providerApiManager = new ProviderApiManager(mockPreferences, mockResources, mockClientGenerator(), new TestProviderApiServiceCallback());
+
+ Bundle expectedResult = mockBundle();
+ expectedResult.putBoolean(EIP_ACTION_START, true);
+ expectedResult.putBoolean(BROADCAST_RESULT_KEY, false);
+ expectedResult.putParcelable(PROVIDER_KEY, provider);
+
+ Intent providerApiCommand = mockIntent();
+
+ providerApiCommand.setAction(ProviderAPI.DOWNLOAD_GEOIP_JSON);
+ Bundle extrasBundle = mockBundle();
+ extrasBundle.putBoolean(EIP_ACTION_START, true);
+ providerApiCommand.putExtra(ProviderAPI.RECEIVER_KEY, mockResultReceiver(INCORRECTLY_DOWNLOADED_GEOIP_JSON, expectedResult));
+ providerApiCommand.putExtra(PROVIDER_KEY, provider);
+ providerApiCommand.putExtra(PARAMETERS, extrasBundle);
+
+ providerApiManager.handleIntent(providerApiCommand);
+ }
}