public void testLoginUnverified() throws IOException {
long uniq = System.currentTimeMillis();
String email = "system" + uniq + "@testmail.org";
- String pw = "1'aAaA";
- registerUser("an", "bn", email, pw);
+ registerUser("an", "bn", email, TEST_PASSWORD);
waitForMail();
- assertFalse(isLoggedin(login(email, pw)));
+ assertFalse(isLoggedin(login(email, TEST_PASSWORD)));
}
@Test
public void testLoginVerified() throws IOException {
long uniq = System.currentTimeMillis();
String email = "system2" + uniq + "@testmail.org";
- String pw = "1'aAaA";
- createVerifiedUser("an", "bn", email, pw);
- assertTrue(isLoggedin(login(email, pw)));
+ createVerifiedUser("an", "bn", email, TEST_PASSWORD);
+ assertTrue(isLoggedin(login(email, TEST_PASSWORD)));
}
}
import java.io.IOException;
import java.net.HttpURLConnection;
+import java.net.URLEncoder;
import java.util.regex.Pattern;
import org.cacert.gigi.testUtils.InitTruststore;
}
@Test
- public void testSuccess() throws IOException {
+ public void testSuccess() throws IOException, InterruptedException {
long uniq = System.currentTimeMillis();
- registerUser("ab", "b", "correct" + uniq + "@email.de", "ap12UI.'");
+ registerUser("ab", "b", "correct" + uniq + "@email.de", TEST_PASSWORD);
+ assertSuccessfullRegMail();
+
+ 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&cca_agree=1&mname=mn&suffix=sf&email=";
+
+ String query = defaultSignup + URLEncoder.encode("correct3_" + uniq + "@email.de", "UTF-8")
+ + "&general=1&country=1®ional=1&radius=1";
+ String data = fetchStartErrorMessage(runRegister(query));
+ assertTrue(data, data.startsWith("</div>"));
+ assertSuccessfullRegMail();
+
+ getMailReciever().setEmailCheckError("400 Greylisted");
+ getMailReciever().setApproveRegex(Pattern.compile("a"));
+ query = defaultSignup + URLEncoder.encode("correct4_" + uniq + "@email.de", "UTF-8")
+ + "&general=1&country=1®ional=1&radius=1";
+ data = fetchStartErrorMessage(runRegister(query));
+ assertFalse(data, data.startsWith("</div>"));
+
+ assertNull(getMailReciever().recieve());
+
+ }
+
+ private void assertSuccessfullRegMail() {
TestMail tm = waitForMail();
String link = tm.extractLink();
assertTrue(link, link.startsWith("https://"));
@Test
public void testDoubleMail() throws IOException {
long uniq = System.currentTimeMillis();
- registerUser("RegisterTest", "User", "testmail" + uniq + "@cacert.org", "registerPW'1");
+ registerUser("RegisterTest", "User", "testmail" + uniq + "@cacert.org", TEST_PASSWORD);
try {
- registerUser("RegisterTest", "User", "testmail" + uniq + "@cacert.org", "registerPW");
+ registerUser("RegisterTest", "User", "testmail" + uniq + "@cacert.org", TEST_PASSWORD);
throw new Error("Registering a user with the same email needs to fail.");
} catch (AssertionError e) {
getMailReciever().setApproveRegex(Pattern.compile("a"));
long uniq = System.currentTimeMillis();
try {
- registerUser("RegisterTest", "User", "testInvalidMailbox" + uniq + "@cacert.org", "registerPW");
+ registerUser("RegisterTest", "User", "testInvalidMailbox" + uniq + "@cacert.org", TEST_PASSWORD);
throw new Error("Registering a user with invalid mailbox must fail.");
} catch (AssertionError e) {