]> WPIA git - gigi.git/commitdiff
Merge "upd: fixes wording"
authorFelix Dörre <felix@dogcraft.de>
Thu, 4 Aug 2016 19:30:24 +0000 (21:30 +0200)
committerGerrit Code Review <gigi-system@dogcraft.de>
Thu, 4 Aug 2016 19:30:24 +0000 (21:30 +0200)
15 files changed:
src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/dbObjects/EmailAddress.java
src/org/cacert/gigi/localisation/Language.java
src/org/cacert/gigi/output/AssurancesDisplay.java
src/org/cacert/gigi/pages/admin/support/FindUserByDomainForm.java [moved from src/org/cacert/gigi/pages/admin/support/FindDomainForm.java with 87% similarity]
src/org/cacert/gigi/pages/admin/support/FindUserByDomainForm.templ [moved from src/org/cacert/gigi/pages/admin/support/FindDomainForm.templ with 100% similarity]
src/org/cacert/gigi/pages/admin/support/FindUserByDomainPage.java [moved from src/org/cacert/gigi/pages/admin/support/FindDomainPage.java with 79% similarity]
src/org/cacert/gigi/pages/admin/support/FindUserByEmailForm.java [moved from src/org/cacert/gigi/pages/admin/support/FindUserForm.java with 61% similarity]
src/org/cacert/gigi/pages/admin/support/FindUserByEmailForm.templ [moved from src/org/cacert/gigi/pages/admin/support/FindUserForm.templ with 93% similarity]
src/org/cacert/gigi/pages/admin/support/FindUserByEmailPage.java [moved from src/org/cacert/gigi/pages/admin/support/FindUserPage.java with 71% similarity]
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java
tests/org/cacert/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java
tests/org/cacert/gigi/pages/admin/TestSEAdminPageUserMailSearch.java
tests/org/cacert/gigi/pages/admin/TestSEAdminTicketSetting.java
tests/org/cacert/gigi/testUtils/ManagedTest.java

index 812f61fb1ac5e6db25ab36ab462718913b0beaa0..9e111ae78449c50b600e7d08294c41c5fa712716 100644 (file)
@@ -58,8 +58,8 @@ import org.cacert.gigi.pages.account.certs.Certificates;
 import org.cacert.gigi.pages.account.domain.DomainOverview;
 import org.cacert.gigi.pages.account.mail.MailOverview;
 import org.cacert.gigi.pages.admin.TTPAdminPage;
-import org.cacert.gigi.pages.admin.support.FindDomainPage;
-import org.cacert.gigi.pages.admin.support.FindUserPage;
+import org.cacert.gigi.pages.admin.support.FindUserByDomainPage;
+import org.cacert.gigi.pages.admin.support.FindUserByEmailPage;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
 import org.cacert.gigi.pages.error.AccessDenied;
@@ -153,8 +153,8 @@ public final class Gigi extends HttpServlet {
             putPage(ViewOrgPage.DEFAULT_PATH + "/*", new ViewOrgPage(), "Organisation Admin");
 
             putPage(SupportEnterTicketPage.PATH, new SupportEnterTicketPage(), "Support Console");
-            putPage(FindUserPage.PATH, new FindUserPage(), "Support Console");
-            putPage(FindDomainPage.PATH, new FindDomainPage(), "Support Console");
+            putPage(FindUserByEmailPage.PATH, new FindUserByEmailPage(), "Support Console");
+            putPage(FindUserByDomainPage.PATH, new FindUserByDomainPage(), "Support Console");
 
             putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage(), null);
             putPage(ChangePasswordPage.PATH, new ChangePasswordPage(), "My Account");
index 964d1b68ec8dda6cb2afb7685d43c46415f303d7..a3208165b4d324bbfa13b6fca59fdee75ab40acf 100644 (file)
@@ -2,6 +2,7 @@ package org.cacert.gigi.dbObjects;
 
 import java.io.IOException;
 import java.util.Date;
+import java.util.LinkedList;
 import java.util.Locale;
 
 import org.cacert.gigi.GigiApiException;
@@ -149,4 +150,20 @@ public class EmailAddress implements IdCachable, Verifyable {
         }
         return em;
     }
+
+    public User getOwner() {
+        return owner;
+    }
+
+    public static EmailAddress[] findByAllEmail(String mail) {
+        LinkedList<EmailAddress> results = new LinkedList<EmailAddress>();
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `emails`.`id` FROM `emails` INNER JOIN `users` ON `users`.`id` = `emails`.`memid` INNER JOIN `certOwners` ON `certOwners`.`id` = `users`.`id` WHERE `emails`.`email` LIKE ? AND `emails`.`deleted` IS NULL AND `certOwners`.`deleted` IS NULL ORDER BY `users`.`id`, `emails`.`email` LIMIT 100")) {
+            ps.setString(1, mail);
+            GigiResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                results.add(EmailAddress.getById(rs.getInt(1)));
+            }
+            return results.toArray(new EmailAddress[results.size()]);
+        }
+    }
 }
index 95971120f39df4151e997ff2af1d4694cd1bfcee..4caaa79beb698533b0bb8de4f26f4aeb12945a67 100644 (file)
@@ -99,6 +99,9 @@ public class Language {
     }
 
     public String getTranslation(String text) {
+        if (text == null || text.equals("")) {
+            return text;
+        }
         String string = translations.get(text);
         if (string == null || string.equals("")) {
             return text;
index 595872ac3ac778f98c8760beac6887a14b5c62b7..8f0e6cabb54085287700e059db012ec1729aec35 100644 (file)
@@ -4,6 +4,7 @@ import java.io.PrintWriter;
 import java.util.Map;
 
 import org.cacert.gigi.dbObjects.Assurance;
+import org.cacert.gigi.dbObjects.Name;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.template.IterableDataset;
 import org.cacert.gigi.output.template.Outputable;
@@ -44,12 +45,13 @@ public class AssurancesDisplay implements Outputable {
                     Assurance assurance = assurances[i];
                     vars.put("id", assurance.getId());
                     vars.put("method", assurance.getMethod());
+                    Name to = assurance.getTo();
                     if (assurer) {
-                        vars.put("verbVal", assurance.getTo().getOwner().getId());
-                        vars.put("myName", assurance.getTo());
+                        vars.put("verbVal", to == null ? l.getTranslation("applicant's name removed") : to.getOwner().getId());
+                        vars.put("myName", to == null ? l.getTranslation("applicant's name removed") : to);
                     } else {
                         vars.put("verbVal", assurance.getFrom().getPreferredName());
-                        vars.put("myName", assurance.getTo());
+                        vars.put("myName", to == null ? l.getTranslation("own name removed") : to);
                     }
                     vars.put("date", assurance.getDate());
                     vars.put("location", assurance.getLocation());
similarity index 87%
rename from src/org/cacert/gigi/pages/admin/support/FindDomainForm.java
rename to src/org/cacert/gigi/pages/admin/support/FindUserByDomainForm.java
index 93c4b0c158bfffe0eb00f14b2afaac09bac1f0a8..779b0026bb83aeefbdbc98c4ff80defc5559d363 100644 (file)
@@ -13,13 +13,13 @@ import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.SprintfCommand;
 import org.cacert.gigi.output.template.Template;
 
-public class FindDomainForm extends Form {
+public class FindUserByDomainForm extends Form {
 
     private CertificateOwner res = null;
 
-    private static final Template t = new Template(FindDomainForm.class.getResource("FindDomainForm.templ"));
+    private static final Template t = new Template(FindUserByDomainForm.class.getResource("FindUserByDomainForm.templ"));
 
-    public FindDomainForm(HttpServletRequest hsr) {
+    public FindUserByDomainForm(HttpServletRequest hsr) {
         super(hsr);
     }
 
similarity index 79%
rename from src/org/cacert/gigi/pages/admin/support/FindDomainPage.java
rename to src/org/cacert/gigi/pages/admin/support/FindUserByDomainPage.java
index 06d41621def5495df91c8c4a5ce923fa600da601..ee5192b0225051f32bdd18d900953b7f13f334c1 100644 (file)
@@ -7,17 +7,17 @@ import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.pages.OneFormPage;
 import org.cacert.gigi.util.AuthorizationContext;
 
-public class FindDomainPage extends OneFormPage {
+public class FindUserByDomainPage extends OneFormPage {
 
     public static final String PATH = "/support/find/domain";
 
-    public FindDomainPage() {
-        super("Find Domain", FindDomainForm.class);
+    public FindUserByDomainPage() {
+        super("Find Domain", FindUserByDomainForm.class);
     }
 
     @Override
     public String getSuccessPath(Form f) {
-        CertificateOwner res = ((FindDomainForm) f).getRes();
+        CertificateOwner res = ((FindUserByDomainForm) f).getRes();
         if (res instanceof User) {
             return SupportUserDetailsPage.PATH + res.getId();
         } else if (res instanceof Organisation) {
similarity index 61%
rename from src/org/cacert/gigi/pages/admin/support/FindUserForm.java
rename to src/org/cacert/gigi/pages/admin/support/FindUserByEmailForm.java
index 3a7bf07c1e979191005d378c6aa07d111d54359d..12c33e97d75fcac13c077ad47986439bc0ccc0a3 100644 (file)
@@ -6,29 +6,29 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.SprintfCommand;
 import org.cacert.gigi.output.template.Template;
 
-public class FindUserForm extends Form {
+public class FindUserByEmailForm extends Form {
 
-    private User users[];
+    private EmailAddress emails[];
 
-    private static final Template t = new Template(FindDomainForm.class.getResource("FindUserForm.templ"));
+    private static final Template t = new Template(FindUserByDomainForm.class.getResource("FindUserByEmailForm.templ"));
 
-    public FindUserForm(HttpServletRequest hsr) {
+    public FindUserByEmailForm(HttpServletRequest hsr) {
         super(hsr);
     }
 
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
-        User[] users = User.findByEmail(req.getParameter("email"));
-        if (users.length == 0) {
+        EmailAddress[] emails = EmailAddress.findByAllEmail(req.getParameter("email"));
+        if (emails.length == 0) {
             throw new GigiApiException(SprintfCommand.createSimple("No users found matching {0}", req.getParameter("email")));
         }
-        this.users = users;
+        this.emails = emails;
         return true;
     }
 
@@ -37,8 +37,8 @@ public class FindUserForm extends Form {
         t.output(out, l, vars);
     }
 
-    public User[] getUsers() {
-        return users;
+    public EmailAddress[] getEmails() {
+        return emails;
     }
 
 }
similarity index 93%
rename from src/org/cacert/gigi/pages/admin/support/FindUserForm.templ
rename to src/org/cacert/gigi/pages/admin/support/FindUserByEmailForm.templ
index 01682243f2162aae16c0ca10bff6d8b2a4ca7baf..0461bc39dad56d6556fca30cd5fc563457dd615f 100644 (file)
@@ -11,7 +11,7 @@
 <? if($first) {?>
 <table class="table">
   <tbody><tr>
-    <th colspan="2"><?=_Find User?></th>
+    <th colspan="2"><?=_Find User by Email?></th>
   </tr>
   <tr>
     <td><?=_Email?>:</td>
similarity index 71%
rename from src/org/cacert/gigi/pages/admin/support/FindUserPage.java
rename to src/org/cacert/gigi/pages/admin/support/FindUserByEmailPage.java
index 059298f8227c556f4230a56c26e7f4d4c741685f..42d9e8d00ec6826df87a610885fe388f03003d2b 100644 (file)
@@ -8,36 +8,36 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.IterableDataset;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.AuthorizationContext;
 
-public class FindUserPage extends Page {
+public class FindUserByEmailPage extends Page {
 
-    public static final String PATH = "/support/find/user";
+    public static final String PATH = "/support/find/email";
 
-    public FindUserPage() {
-        super("Find User");
+    public FindUserByEmailPage() {
+        super("Find Email");
     }
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         HashMap<String, Object> vars = new HashMap<String, Object>();
         vars.put("first", true);
-        new FindUserForm(req).output(resp.getWriter(), Page.getLanguage(req), vars);
+        new FindUserByEmailForm(req).output(resp.getWriter(), Page.getLanguage(req), vars);
     }
 
     @Override
     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        FindUserForm form = Form.getForm(req, FindUserForm.class);
+        FindUserByEmailForm form = Form.getForm(req, FindUserByEmailForm.class);
         try {
             form.submit(resp.getWriter(), req);
-            final User[] users = form.getUsers();
-            if (users.length == 1) {
-                resp.sendRedirect(SupportUserDetailsPage.PATH + users[0].getId());
+            final EmailAddress[] emails = form.getEmails();
+            if (emails.length == 1) {
+                resp.sendRedirect(SupportUserDetailsPage.PATH + emails[0].getOwner().getId());
             } else {
                 HashMap<String, Object> vars = new HashMap<String, Object>();
                 vars.put("first", false);
@@ -47,11 +47,11 @@ public class FindUserPage extends Page {
 
                     @Override
                     public boolean next(Language l, Map<String, Object> vars) {
-                        if (i == users.length) {
+                        if (i == emails.length) {
                             return false;
                         }
-                        vars.put("usrid", users[i].getId());
-                        vars.put("usermail", users[i].getEmail());
+                        vars.put("usrid", emails[i].getOwner().getId());
+                        vars.put("usermail", emails[i].getAddress());
                         i++;
                         return true;
                     }
index bf6f1488b998d2eda8287dfd5d88ed798236a882..f97b2c44e0601d9eccecb6356899ff282400379e 100644 (file)
@@ -26,7 +26,7 @@ import org.cacert.gigi.pages.PasswordResetPage;
 
 public class SupportUserDetailsForm extends Form {
 
-    private static final Template t = new Template(FindDomainForm.class.getResource("SupportUserDetailsForm.templ"));
+    private static final Template t = new Template(FindUserByDomainForm.class.getResource("SupportUserDetailsForm.templ"));
 
     private SupportedUser user;
 
index 5c0f1e0b3c96037ec85e75a8ba508aaf3c9a2b44..a4fb4b437b77d6084087d782ff69c53490d11bad 100644 (file)
@@ -13,7 +13,7 @@ import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.User;
-import org.cacert.gigi.pages.admin.support.FindDomainPage;
+import org.cacert.gigi.pages.admin.support.FindUserByDomainPage;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
 import org.cacert.gigi.testUtils.ClientTest;
@@ -45,20 +45,20 @@ public class TestSEAdminPageUserDomainSearch extends ClientTest {
 
     @Test
     public void testDomainSearch() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
-        URLConnection uc = post(FindDomainPage.PATH, "process&domain=" + URLEncoder.encode(domainName, "UTF-8"));
+        URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=" + URLEncoder.encode(domainName, "UTF-8"));
 
         assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid, uc.getHeaderField("Location"));
     }
 
     @Test
     public void testDomainSearchById() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
-        URLConnection uc = post(FindDomainPage.PATH, "process&domain=#" + d.getId());
+        URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=#" + d.getId());
         assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid, uc.getHeaderField("Location"));
     }
 
     @Test
     public void testDomainSearchNonExist() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
-        URLConnection uc = post(FindDomainPage.PATH, "process&domain=" + URLEncoder.encode(createUniqueName() + ".de", "UTF-8"));
+        URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=" + URLEncoder.encode(createUniqueName() + ".de", "UTF-8"));
         assertNotNull(fetchStartErrorMessage(IOUtils.readURL(uc)));
     }
 
@@ -76,7 +76,7 @@ public class TestSEAdminPageUserDomainSearch extends ClientTest {
             found = true;
         }
         assumeTrue(found);
-        URLConnection uc = post(FindDomainPage.PATH, "process&domain=#" + id);
+        URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=#" + id);
         assertNotNull(fetchStartErrorMessage(IOUtils.readURL(uc)));
     }
 }
index 70e5bd4f098464819ed1a9ef8d239ccfce5d632e..bb05a71b71b04b8de58bd76b0b5d3da748606e57 100644 (file)
@@ -9,8 +9,10 @@ import java.net.MalformedURLException;
 import java.net.URLConnection;
 import java.net.URLEncoder;
 
+import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Group;
-import org.cacert.gigi.pages.admin.support.FindUserPage;
+import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.pages.admin.support.FindUserByEmailPage;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
 import org.cacert.gigi.testUtils.ClientTest;
@@ -30,7 +32,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         String mail = createUniqueName() + "@example.com";
         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
 
-        URLConnection uc = post(cookie, FindUserPage.PATH, "process&email=" + URLEncoder.encode(mail, "UTF-8"), 0);
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode(mail, "UTF-8"), 0);
         assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
     }
 
@@ -39,7 +41,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         String mail = createUniqueName() + "@example.tld";
         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
 
-        URLConnection uc = post(cookie, FindUserPage.PATH, "process&email=" + URLEncoder.encode("%@example.tld", "UTF-8"), 0);
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example.tld", "UTF-8"), 0);
         assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
     }
 
@@ -49,7 +51,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
         String mail2 = createUniqueName() + "@example.org";
         int id2 = createVerifiedUser("Först", "Secönd", mail2, TEST_PASSWORD);
-        URLConnection uc = post(cookie, FindUserPage.PATH, "process&email=" + URLEncoder.encode("%@example.org", "UTF-8"), 0);
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example.org", "UTF-8"), 0);
 
         String res = IOUtils.readURL(uc);
         assertThat(res, containsString(SupportUserDetailsPage.PATH + id));
@@ -63,7 +65,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         String mail2 = createUniqueName() + "@fxample.org";
         int id2 = createVerifiedUser("Först", "Secönd", mail2, TEST_PASSWORD);
 
-        URLConnection uc = post(cookie, FindUserPage.PATH, "process&email=" + URLEncoder.encode("%@_xample.org", "UTF-8"), 0);
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@_xample.org", "UTF-8"), 0);
 
         String res = IOUtils.readURL(uc);
         assertThat(res, containsString(SupportUserDetailsPage.PATH + id));
@@ -72,14 +74,95 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
 
     @Test
     public void testWildcardMailSearchNoRes() throws MalformedURLException, UnsupportedEncodingException, IOException {
-        URLConnection uc = post(FindUserPage.PATH, "process&email=" + URLEncoder.encode("%@_humpfelkumpf.org", "UTF-8"));
+        URLConnection uc = post(FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@_humpfelkumpf.org", "UTF-8"));
         assertNotNull(fetchStartErrorMessage(IOUtils.readURL(uc)));
     }
 
     @Test
     public void testFulltextMailSearchNoRes() throws MalformedURLException, UnsupportedEncodingException, IOException {
-        URLConnection uc = post(cookie, FindUserPage.PATH, "process&email=" + URLEncoder.encode(createUniqueName() + "@example.org", "UTF-8"), 0);
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode(createUniqueName() + "@example.org", "UTF-8"), 0);
 
         assertNotNull(fetchStartErrorMessage(IOUtils.readURL(uc)));
     }
+
+    @Test
+    public void testSearchSecondEmailAddress() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
+        String mail = createUniqueName() + "@example1.org";
+        int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
+        User testuser = User.getById(id);
+        String mail2 = createUniqueName() + "@example1.org";
+        createVerifiedEmail(testuser, mail2);
+
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode(mail2, "UTF-8"), 0);
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+    }
+
+    @Test
+    public void testWildcardMailSearchSecondEmailAddress() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
+        clearCaches();
+        String mail = createUniqueName() + "@example2.org";
+        int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
+        User testuser = User.getById(id);
+        String mail2 = createUniqueName() + "@example2.org";
+        createVerifiedEmail(testuser, mail2);
+
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example2.org", "UTF-8"), 0);
+
+        String res = IOUtils.readURL(uc);
+        assertThat(res, containsString(mail));
+        assertThat(res, containsString(mail2));
+    }
+
+    @Test
+    public void testWildcardMailSearchMultipleEmailAddressOneAccount() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
+        clearCaches();
+        String mail = createUniqueName() + "@example3.org";
+        int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
+        User testuser = User.getById(id);
+        String mail2 = createUniqueName() + "@test3.org";
+        createVerifiedEmail(testuser, mail2);
+        String mail3 = createUniqueName() + "@test3.org";
+        createVerifiedEmail(testuser, mail3);
+
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example3.org", "UTF-8"), 0);
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+
+        uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@test3.org", "UTF-8"), 0);
+
+        String res = IOUtils.readURL(uc);
+        assertThat(res, not(containsString(mail)));
+        assertThat(res, containsString(mail2));
+        assertThat(res, containsString(mail3));
+    }
+
+    @Test
+    public void testWildcardMailSearchMultipleEmailAddressMultipleAccounts() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
+        String mail = createUniqueName() + "1@example4.org";
+        int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
+        User testuser = User.getById(id);
+        String mail2 = createUniqueName() + "@test4.org";
+        createVerifiedEmail(testuser, mail2);
+
+        String mail3 = createUniqueName() + "2@example4.org";
+        int id2 = createVerifiedUser("Först", "Secönd", mail3, TEST_PASSWORD);
+        User testuser2 = User.getById(id2);
+        String mail4 = createUniqueName() + "@test4.org";
+        createVerifiedEmail(testuser2, mail4);
+
+        URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example4.org", "UTF-8"), 0);
+
+        String res = IOUtils.readURL(uc);
+        assertThat(res, containsString(mail));
+        assertThat(res, not(containsString(mail2)));
+        assertThat(res, containsString(mail3));
+        assertThat(res, not(containsString(mail4)));
+
+        uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@test4.org", "UTF-8"), 0);
+
+        res = IOUtils.readURL(uc);
+        assertThat(res, not(containsString(mail)));
+        assertThat(res, containsString(mail2));
+        assertThat(res, not(containsString(mail3)));
+        assertThat(res, containsString(mail4));
+    }
 }
index c4c1a30541594ae06cf9da8ddac7262c3e97cc39..62d89de297e2ab527fcd0c83721b68ba90b80ee9 100644 (file)
@@ -7,8 +7,8 @@ import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 
 import org.cacert.gigi.dbObjects.Group;
-import org.cacert.gigi.pages.admin.support.FindDomainPage;
-import org.cacert.gigi.pages.admin.support.FindUserPage;
+import org.cacert.gigi.pages.admin.support.FindUserByDomainPage;
+import org.cacert.gigi.pages.admin.support.FindUserByEmailPage;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
@@ -21,12 +21,12 @@ public class TestSEAdminTicketSetting extends ClientTest {
 
     @Test
     public void testFulltextMailSearch() throws MalformedURLException, UnsupportedEncodingException, IOException {
-        assertEquals(403, get(FindUserPage.PATH).getResponseCode());
+        assertEquals(403, get(FindUserByEmailPage.PATH).getResponseCode());
         assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-        assertEquals(200, get(FindUserPage.PATH).getResponseCode());
-        assertEquals(200, get(FindDomainPage.PATH).getResponseCode());
+        assertEquals(200, get(FindUserByEmailPage.PATH).getResponseCode());
+        assertEquals(200, get(FindUserByDomainPage.PATH).getResponseCode());
         assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&deleteTicket=action", 0).getResponseCode());
-        assertEquals(403, get(FindUserPage.PATH).getResponseCode());
+        assertEquals(403, get(FindUserByEmailPage.PATH).getResponseCode());
     }
 
 }
index 036adc92003fd53745e7b865c7f5f72035c4d0db..aab620a39e845f14d9dc31d73563e9a84f56a7a8 100644 (file)
@@ -468,13 +468,17 @@ public class ManagedTest extends ConfiguredTest {
     }
 
     public EmailAddress createVerifiedEmail(User u) throws InterruptedException, GigiApiException {
-        EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld", Locale.ENGLISH);
+        return createVerifiedEmail(u, createUniqueName() + "test@test.tld");
+    }
+
+    public EmailAddress createVerifiedEmail(User u, String email) throws InterruptedException, GigiApiException {
+        EmailAddress addr = new EmailAddress(u, email, Locale.ENGLISH);
         TestMail testMail = getMailReceiver().receive();
-        assertEquals(adrr.getAddress(), testMail.getTo());
+        assertEquals(addr.getAddress(), testMail.getTo());
         String hash = testMail.extractLink().substring(testMail.extractLink().lastIndexOf('=') + 1);
-        adrr.verify(hash);
+        addr.verify(hash);
         getMailReceiver().clearMails();
-        return adrr;
+        return addr;
     }
 
     public static URLConnection cookie(URLConnection openConnection, String cookie) {