summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-09-18 12:38:24 +0200
committercyBerta <cyberta@riseup.net>2017-09-18 12:38:24 +0200
commitafa289cbcce4a431f6bd587b490b6470ed6caa50 (patch)
tree2f44dc405415cbf03f81eff0c0967f29abec7c7e
parentdc9a7d39dc4cfe4c752704ffb4d1f02990da2dd1 (diff)
change expiration offset to 15 days before actual certificate expires
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java40
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java6
2 files changed, 13 insertions, 33 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java
index 323e7e6d..97a0e36d 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java
@@ -16,17 +16,15 @@
*/
package se.leap.bitmaskclient.test;
-import android.content.*;
-import android.os.*;
-import android.test.*;
+import android.content.Context;
+import android.test.InstrumentationTestCase;
-import org.json.*;
+import org.json.JSONObject;
-import java.io.*;
-import java.util.*;
+import java.util.Calendar;
-import se.leap.bitmaskclient.*;
-import se.leap.bitmaskclient.eip.*;
+import se.leap.bitmaskclient.Provider;
+import se.leap.bitmaskclient.eip.VpnCertificateValidator;
/**
* @author parmegv
@@ -72,35 +70,17 @@ public class TestVpnCertificateValidator extends InstrumentationTestCase {
assertTrue(validator.isValid());
calendar.set(Calendar.YEAR, 2022);
- calendar.set(Calendar.MONTH, Calendar.AUGUST);
- calendar.set(Calendar.DAY_OF_MONTH, 5);
+ calendar.set(Calendar.MONTH, Calendar.OCTOBER);
+ calendar.set(Calendar.DAY_OF_MONTH, 21);
validator.setCalendarProvider(new TestCalendarProvider(calendar.getTimeInMillis()));
assertTrue(validator.isValid());
calendar.set(Calendar.YEAR, 2022);
- calendar.set(Calendar.MONTH, Calendar.AUGUST);
- calendar.set(Calendar.DAY_OF_MONTH, 6);
+ calendar.set(Calendar.MONTH, Calendar.OCTOBER);
+ calendar.set(Calendar.DAY_OF_MONTH, 22);
validator.setCalendarProvider(new TestCalendarProvider(calendar.getTimeInMillis()));
assertFalse(validator.isValid());
-
}
- private void setTime(int year, int month, int day) {
- shellCommand("adb shell chmod 666 /dev/alarm");
- Calendar c = Calendar.getInstance();
- c.set(year, month, day, 12, 00, 00);
- SystemClock.setCurrentTimeMillis(c.getTimeInMillis());
- shellCommand("adb shell chmod 664 /dev/alarm");
- }
-
- private int shellCommand(String command) {
- int result = 0;
- try {
- Runtime.getRuntime().exec(command);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return result;
- }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
index 709dda34..28099f06 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
@@ -38,7 +38,7 @@ public class VpnCertificateValidator {
/**
*
- * @return true if there's a certificate that is valid for more than 3 more months
+ * @return true if there's a certificate that is valid for more than 15 more days
*/
public boolean isValid() {
if (certificate.isEmpty()) {
@@ -69,8 +69,8 @@ public class VpnCertificateValidator {
if (startDate.getTime() >= limitDate.getTime().getTime()) {
return limitDate;
}
- // else add an offset of 3 months to the current date
- limitDate.add(Calendar.MONTH, 3);
+ // else add an offset of 15 days to the current date
+ limitDate.add(Calendar.DAY_OF_YEAR, 15);
return limitDate;
}