public static final int MINIMUM_AGE = 16;
+ public static final int MAXIMUM_PLAUSIBLE_AGE = 110;
+
public static final int POJAM_AGE = 14;
public static final int ADULT_AGE = 18;
if (getReceivedAssurances().length != 0) {
throw new GigiApiException("No change after assurance allowed.");
}
+
+ if ( !CalendarUtil.isOfAge(dob, User.MINIMUM_AGE)) {
+ throw new GigiApiException("Entered date of birth is below the restricted age requirements.");
+ }
+
+ if (CalendarUtil.isOfAge(dob, User.MAXIMUM_PLAUSIBLE_AGE)) {
+ throw new GigiApiException("Entered date of birth exceeds the maximum age set in our policies. Please check your DoB is correct and contact support if the issue persists.");
+ }
this.dob = dob;
rawUpdateUserData();
}
}
if ( !CalendarUtil.isOfAge(myDoB.getDate(), User.MINIMUM_AGE)) {
- ga.mergeInto(new GigiApiException("Entered dated of birth is below the restricted age requirements."));
+ ga.mergeInto(new GigiApiException("Entered date of birth is below the restricted age requirements."));
+ }
+
+ if (CalendarUtil.isOfAge(myDoB.getDate(), User.MAXIMUM_PLAUSIBLE_AGE)) {
+ ga.mergeInto(new GigiApiException("Entered date of birth exceeds the maximum age set in our policies. Please check your DoB is correct and contact support if the issue persists."));
}
if ( !"1".equals(req.getParameter("tos_agree"))) {
import java.sql.Date;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.cacert.gigi.GigiApiException;
public void testChangeDOBInvalid() throws IOException {
assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "day=1&month=1&year=test&action=updateDoB", 0));
}
+
+ @Test
+ public void testChangeTooYoung() throws IOException {
+ Calendar c = GregorianCalendar.getInstance();
+ c.add(Calendar.YEAR, -User.MINIMUM_AGE);
+ c.add(Calendar.DAY_OF_MONTH, +1);
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&action=updateDoB", 0));
+ }
+
+ @Test
+ public void testChangeTooOld() throws IOException {
+ Calendar c = GregorianCalendar.getInstance();
+ c.add(Calendar.YEAR, -User.MAXIMUM_PLAUSIBLE_AGE);
+ c.add(Calendar.DAY_OF_MONTH, -1);
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&action=updateDoB", 0));
+ }
}