From: INOPIAE Date: Thu, 18 Jul 2019 12:10:00 +0000 (+0200) Subject: add: accept data protection policy during registration X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=b1732ef0669da21ed47e01f1d5675569829786a1;hp=b67f4dbc8bdda82af3012e34c48e970ec6b4a700 add: accept data protection policy during registration fixes issue #174 Change-Id: I079febbb7dbdfd89257c30a9c499f54d89db3170 --- diff --git a/src/club/wpia/gigi/pages/main/Signup.java b/src/club/wpia/gigi/pages/main/Signup.java index 6b8dd75f..cbe96c0e 100644 --- a/src/club/wpia/gigi/pages/main/Signup.java +++ b/src/club/wpia/gigi/pages/main/Signup.java @@ -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); } } diff --git a/src/club/wpia/gigi/pages/main/Signup.templ b/src/club/wpia/gigi/pages/main/Signup.templ index b50e78ea..4e30b0ca 100644 --- a/src/club/wpia/gigi/pages/main/Signup.templ +++ b/src/club/wpia/gigi/pages/main/Signup.templ @@ -50,6 +50,10 @@ + + + + diff --git a/tests/club/wpia/gigi/pages/main/RegisterPageTest.java b/tests/club/wpia/gigi/pages/main/RegisterPageTest.java index 85e34b92..02404de9 100644 --- a/tests/club/wpia/gigi/pages/main/RegisterPageTest.java +++ b/tests/club/wpia/gigi/pages/main/RegisterPageTest.java @@ -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)); diff --git a/tests/club/wpia/gigi/testUtils/ManagedTest.java b/tests/club/wpia/gigi/testUtils/ManagedTest.java index a2eb449f..aa18a304 100644 --- a/tests/club/wpia/gigi/testUtils/ManagedTest.java +++ b/tests/club/wpia/gigi/testUtils/ManagedTest.java @@ -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) {