add: accept data protection policy during registration
authorINOPIAE <m.maengel@inopiae.de>
Thu, 18 Jul 2019 12:10:00 +0000 (14:10 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 18 Jul 2019 12:10:00 +0000 (14:10 +0200)
fixes issue #174

Change-Id: I079febbb7dbdfd89257c30a9c499f54d89db3170

src/club/wpia/gigi/pages/main/Signup.java
src/club/wpia/gigi/pages/main/Signup.templ
tests/club/wpia/gigi/pages/main/RegisterPageTest.java
tests/club/wpia/gigi/testUtils/ManagedTest.java

index 6b8dd75..cbe96c0 100644 (file)
@@ -24,7 +24,6 @@ import club.wpia.gigi.output.template.SprintfCommand;
 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;
@@ -118,6 +117,11 @@ public class Signup extends Form {
         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"));
         }
@@ -182,6 +186,7 @@ public class Signup extends Form {
     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);
     }
 
 }
index b50e78e..4e30b0c 100644 (file)
     <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>
index 85e34b9..02404de 100644 (file)
@@ -47,7 +47,7 @@ public class RegisterPageTest extends ManagedTest {
         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));
@@ -71,78 +71,85 @@ public class RegisterPageTest extends ManagedTest {
 
     @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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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 {
-        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");
     }
 
     @Test
-    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);
-        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");
     }
 
     @Test
@@ -150,7 +157,7 @@ public class RegisterPageTest extends ManagedTest {
         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");
     }
 
     @Test
@@ -205,7 +212,7 @@ public class RegisterPageTest extends ManagedTest {
         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));
@@ -220,7 +227,7 @@ public class RegisterPageTest extends ManagedTest {
         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));
index a2eb449..aa18a30 100644 (file)
@@ -278,7 +278,7 @@ public class ManagedTest extends ConfiguredTest {
 
     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) {