X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Fclub%2Fwpia%2Fgigi%2FtestUtils%2FManagedTest.java;h=aa18a30482111b9a20b6d0fc49d9476ada1091aa;hb=010f5d1a8bb003834222e6d854194a6c6e5e5cb7;hp=2574922196c28d5262ba3778070ab6941dc42839;hpb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;p=gigi.git diff --git a/tests/club/wpia/gigi/testUtils/ManagedTest.java b/tests/club/wpia/gigi/testUtils/ManagedTest.java index 25749221..aa18a304 100644 --- a/tests/club/wpia/gigi/testUtils/ManagedTest.java +++ b/tests/club/wpia/gigi/testUtils/ManagedTest.java @@ -101,11 +101,11 @@ public class ManagedTest extends ConfiguredTest { return mainProps; } inited = true; + url = testProps.getProperty("name.www") + ":" + testProps.getProperty("serverPort.https"); purgeDatabase(); String type = testProps.getProperty("type"); generateMainProps(mainProps); if (type.equals("local")) { - url = testProps.getProperty("name.www") + ":" + testProps.getProperty("serverPort.https"); String[] parts = testProps.getProperty("mail").split(":", 2); ter = new TestEmailReceiver(new InetSocketAddress(parts[0], Integer.parseInt(parts[1]))); ter.start(); @@ -114,7 +114,6 @@ public class ManagedTest extends ConfiguredTest { } return mainProps; } - url = testProps.getProperty("name.www") + ":" + testProps.getProperty("serverPort.https"); gigi = Runtime.getRuntime().exec(testProps.getProperty("java")); DataOutputStream toGigi = new DataOutputStream(gigi.getOutputStream()); System.out.println("... starting server"); @@ -168,14 +167,18 @@ public class ManagedTest extends ConfiguredTest { public static void purgeDatabase() throws SQLException, IOException { purgeOnlyDB(); - clearCaches(); + if (gigi != null) { + clearCaches(); + } } public static void clearCaches() throws IOException { ObjectCache.clearAllCaches(); // String type = testProps.getProperty("type"); URL u = new URL("https://" + getServerName() + "/manage"); - u.openConnection().getHeaderField("Location"); + URLConnection connection = u.openConnection(); + connection.getHeaderField("Location"); + connection.getInputStream().close(); } private static void generateMainProps(Properties mainProps) { @@ -196,6 +199,14 @@ public class ManagedTest extends ConfiguredTest { String type = testProps.getProperty("type"); ter.destroy(); if (type.equals("local")) { + if (testProps.getProperty("withSigner", "false").equals("true")) { + try { + SimpleSigner.stopSigner(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + inited = false; return; } gigi.destroy(); @@ -204,6 +215,7 @@ public class ManagedTest extends ConfiguredTest { } catch (InterruptedException e) { e.printStackTrace(); } + inited = false; } public final String uniq = createUniqueName(); @@ -266,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) { @@ -279,7 +291,7 @@ public class ManagedTest extends ConfiguredTest { public static int createVerifiedUser(String firstName, String lastName, String email, String password) { registerUser(firstName, lastName, email, password); try { - ter.receive().verify(); + ter.receive(email).verify(); try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `id` FROM `users` WHERE `email`=?")) { ps.setString(1, email); @@ -315,10 +327,10 @@ public class ManagedTest extends ConfiguredTest { * the password * @return a new userid. */ - public static int createAssuranceUser(String firstName, String lastName, String email, String password) { + public static int createVerificationUser(String firstName, String lastName, String email, String password) { int uid = createVerifiedUser(firstName, lastName, email, password); - makeAssurer(uid); + makeAgent(uid); return uid; } @@ -484,11 +496,10 @@ public class ManagedTest extends ConfiguredTest { public EmailAddress createVerifiedEmail(User u, String email) throws InterruptedException, GigiApiException { EmailAddress addr = new EmailAddress(u, email, Locale.ENGLISH); - TestMail testMail = getMailReceiver().receive(); - assertEquals(addr.getAddress(), testMail.getTo()); + TestMail testMail = getMailReceiver().receive(addr.getAddress()); String hash = testMail.extractLink().substring(testMail.extractLink().lastIndexOf('=') + 1); addr.verify(hash); - getMailReceiver().clearMails(); + getMailReceiver().assertEmpty(); return addr; }