fixes issue #174
Change-Id: I079febbb7dbdfd89257c30a9c499f54d89db3170
import club.wpia.gigi.output.template.Template;
import club.wpia.gigi.output.template.TranslateCommand;
import club.wpia.gigi.pages.Page;
import club.wpia.gigi.output.template.Template;
import club.wpia.gigi.output.template.TranslateCommand;
import club.wpia.gigi.pages.Page;
-import club.wpia.gigi.passwords.PasswordStrengthChecker;
import club.wpia.gigi.util.CalendarUtil;
import club.wpia.gigi.util.HTMLEncoder;
import club.wpia.gigi.util.Notary;
import club.wpia.gigi.util.CalendarUtil;
import club.wpia.gigi.util.HTMLEncoder;
import club.wpia.gigi.util.Notary;
if ( !"1".equals(req.getParameter("tos_agree"))) {
ga.mergeInto(new GigiApiException("Acceptance of the ToS is required to continue."));
}
if ( !"1".equals(req.getParameter("tos_agree"))) {
ga.mergeInto(new GigiApiException("Acceptance of the ToS is required to continue."));
}
+
+ if ( !"1".equals(req.getParameter("dp_agree"))) {
+ ga.mergeInto(new GigiApiException("Acceptance of the Data Protection Policy is required to continue."));
+ }
+
if (email.equals("")) {
ga.mergeInto(new GigiApiException("Email Address was blank"));
}
if (email.equals("")) {
ga.mergeInto(new GigiApiException("Email Address was blank"));
}
private void run(HttpServletRequest req, String password) throws GigiApiException {
User u = new User(email, password, myDoB.getDate(), Page.getLanguage(req).getLocale(), cs.getCountry(), ni.getNameParts());
Notary.writeUserAgreement(u, "ToS", "account creation", "", true, 0);
private void run(HttpServletRequest req, String password) throws GigiApiException {
User u = new User(email, password, myDoB.getDate(), Page.getLanguage(req).getLocale(), cs.getCountry(), ni.getNameParts());
Notary.writeUserAgreement(u, "ToS", "account creation", "", true, 0);
+ Notary.writeUserAgreement(u, "Data Protection Policy", "account creation", "", true, 0);
<td colspan="3"><input type="checkbox" name="tos_agree" id="tos_agree" value="1"><label for="tos_agree"><?=_I agree to the Terms of Service (!(/policy/ToS)ToS!'</a>').?></label></td>
</tr>
<td colspan="3"><input type="checkbox" name="tos_agree" id="tos_agree" value="1"><label for="tos_agree"><?=_I agree to the Terms of Service (!(/policy/ToS)ToS!'</a>').?></label></td>
</tr>
+ <tr>
+ <td colspan="3"><input type="checkbox" name="dp_agree" id="dp_agree" value="1"><label for="dp_agree"><?=_I accept the (!(/policy/dataPrivacy)Data Protection Policy!'</a>').?></label></td>
+ </tr>
+
<tr>
<td colspan="3"><?=_When you click on next, we will send a confirmation email to the email address you have entered above.?></td>
</tr>
<tr>
<td colspan="3"><?=_When you click on next, we will send a confirmation email to the email address you have entered above.?></td>
</tr>
registerUser("ab", "b", "correct" + uniq + "@email.de", TEST_PASSWORD);
assertSuccessfullRegMail("correct" + uniq + "@email.de");
registerUser("ab", "b", "correct" + uniq + "@email.de", TEST_PASSWORD);
assertSuccessfullRegMail("correct" + uniq + "@email.de");
- String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
+ String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1&mname=mn&suffix=sf&email=";
String query = defaultSignup + URLEncoder.encode("correct3_" + uniq + "@email.de", "UTF-8") + "&name-type=western";
String data = fetchStartErrorMessage(runRegister(query));
String query = defaultSignup + URLEncoder.encode("correct3_" + uniq + "@email.de", "UTF-8") + "&name-type=western";
String data = fetchStartErrorMessage(runRegister(query));
@Test
public void testNoFname() throws IOException {
@Test
public void testNoFname() throws IOException {
- testFailedForm("lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=1");
+ testFailedForm("lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoLname() throws IOException {
}
@Test
public void testNoLname() throws IOException {
- testFailedForm("fname=a" + createBase() + "&day=1&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a" + createBase() + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoEmail() throws IOException {
}
@Test
public void testNoEmail() throws IOException {
- testFailedForm("fname=a&lname=b&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoPword() throws IOException {
}
@Test
public void testNoPword() throws IOException {
- testFailedForm("fname=a&lname=b&email=e&pword2=ap&day=1&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b&email=e&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testDiffPword() throws IOException {
}
@Test
public void testDiffPword() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "2&day=1&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "2&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoDay() throws IOException {
}
@Test
public void testNoDay() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoMonth() throws IOException {
}
@Test
public void testNoMonth() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testNoYear() throws IOException {
}
@Test
public void testNoYear() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&tos_agree=1&dp_agree=1");
}
@Test
public void testInvDay() throws IOException {
}
@Test
public void testInvDay() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=40&month=1&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=0&month=1&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=-1&month=1&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=a&month=1&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=40&month=1&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=0&month=1&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=-1&month=1&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=a&month=1&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testInvMonth() throws IOException {
}
@Test
public void testInvMonth() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=20&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=0&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=-1&year=1910&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=a&year=1910&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=20&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=0&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=-1&year=1910&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=a&year=1910&tos_agree=1&dp_agree=1");
}
@Test
public void testInvYear() throws IOException {
}
@Test
public void testInvYear() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=0&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=100&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=a&tos_agree=1");
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=-1&tos_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=0&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=100&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=a&tos_agree=1&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=-1&tos_agree=1&dp_agree=1");
- public void testNoAgree() throws IOException {
- testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=a");
+ public void testNoTosAgree() throws IOException {
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=a&dp_agree=1");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=1910&dp_agree=1");
+ }
+
+ @Test
+ public void testNoDPAgree() throws IOException {
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=a");
+ testFailedForm("fname=a&lname=b" + createBase() + "&day=1&month=1&year=1910&tos_agree=1");
}
@Test
public void testTooYoung() throws IOException {
Calendar c = GregorianCalendar.getInstance();
c.add(Calendar.YEAR, -User.MINIMUM_AGE + 2);
}
@Test
public void testTooYoung() throws IOException {
Calendar c = GregorianCalendar.getInstance();
c.add(Calendar.YEAR, -User.MINIMUM_AGE + 2);
- testFailedForm("fname=a&lname=b&email=" + createUniqueName() + "@email.de" + p + "&day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&tos_agree=1");
+ testFailedForm("fname=a&lname=b&email=" + createUniqueName() + "@email.de" + p + "&day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&tos_agree=1&dp_agree=1");
Calendar c = GregorianCalendar.getInstance();
c.add(Calendar.YEAR, -User.MAXIMUM_PLAUSIBLE_AGE);
c.add(Calendar.DAY_OF_MONTH, -1);
Calendar c = GregorianCalendar.getInstance();
c.add(Calendar.YEAR, -User.MAXIMUM_PLAUSIBLE_AGE);
c.add(Calendar.DAY_OF_MONTH, -1);
- testFailedForm("fname=a&lname=b&email=" + createUniqueName() + "@email.de" + p + "&day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&tos_agree=1");
+ testFailedForm("fname=a&lname=b&email=" + createUniqueName() + "@email.de" + p + "&day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&tos_agree=1&dp_agree=1");
long uniq = System.currentTimeMillis();
String email = "country" + uniq + "@email.de";
long uniq = System.currentTimeMillis();
String email = "country" + uniq + "@email.de";
- String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
+ String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1&mname=mn&suffix=sf&email=";
String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=DE";
String data = fetchStartErrorMessage(runRegister(query));
String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=DE";
String data = fetchStartErrorMessage(runRegister(query));
long uniq = System.currentTimeMillis();
String email = "countryno" + uniq + "@email.de";
long uniq = System.currentTimeMillis();
String email = "countryno" + uniq + "@email.de";
- String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
+ String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1&mname=mn&suffix=sf&email=";
String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=invalid";
String data = fetchStartErrorMessage(runRegister(query));
String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=invalid";
String data = fetchStartErrorMessage(runRegister(query));
public static void registerUser(String firstName, String lastName, String email, String password) {
try {
public static void registerUser(String firstName, String lastName, String email, String password) {
try {
- String query = "name-type=western&fname=" + URLEncoder.encode(firstName, "UTF-8") + "&lname=" + URLEncoder.encode(lastName, "UTF-8") + "&email=" + URLEncoder.encode(email, "UTF-8") + "&pword1=" + URLEncoder.encode(password, "UTF-8") + "&pword2=" + URLEncoder.encode(password, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1";
+ String query = "name-type=western&fname=" + URLEncoder.encode(firstName, "UTF-8") + "&lname=" + URLEncoder.encode(lastName, "UTF-8") + "&email=" + URLEncoder.encode(email, "UTF-8") + "&pword1=" + URLEncoder.encode(password, "UTF-8") + "&pword2=" + URLEncoder.encode(password, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&dp_agree=1";
String data = fetchStartErrorMessage(runRegister(query));
assertNull(data);
} catch (UnsupportedEncodingException e) {
String data = fetchStartErrorMessage(runRegister(query));
assertNull(data);
} catch (UnsupportedEncodingException e) {