X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Fadmin%2FTestSEAdminPageDetails.java;h=f27a26a4642af0557cf4be5a7d0f824e29a8277a;hb=e9625bad15becfac8c9e0a616986c85f32b31dd9;hp=b554a2c3390e1ff1782d586fe1dfdc2162d621e1;hpb=9af691cb9d611b73907468af22e40cafa8b0200b;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java b/tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java index b554a2c3..f27a26a4 100644 --- a/tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java +++ b/tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java @@ -7,12 +7,17 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.cacert.gigi.GigiApiException; +import org.cacert.gigi.dbObjects.EmailAddress; import org.cacert.gigi.dbObjects.Group; +import org.cacert.gigi.dbObjects.ObjectCache; +import org.cacert.gigi.dbObjects.User; +import org.cacert.gigi.pages.account.History; import org.cacert.gigi.pages.account.MyDetails; -import org.cacert.gigi.pages.account.UserHistory; import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage; import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage; import org.cacert.gigi.testUtils.ClientTest; @@ -41,6 +46,31 @@ public class TestSEAdminPageDetails extends ClientTest { assertThat(res, containsString(email)); } + @Test + public void testUserDetailsEmail() throws MalformedURLException, IOException, GigiApiException { + String email = createUniqueName() + "@example.com"; + String fname = "Först"; + String lname = "Secönd"; + int id = createVerifiedUser(fname, lname, email, TEST_PASSWORD); + String email2 = createUniqueName() + "@example.com"; + EmailAddress ea = new EmailAddress(User.getById(id), email2, Locale.ENGLISH); + getMailReciever().receive().verify(); + // Refresh email Object + ObjectCache.clearAllCaches(); + ea = EmailAddress.getById(ea.getId()); + assertTrue(ea.isVerified()); + + String res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id)); + assertEquals(2, countRegex(res, Pattern.quote(email))); + assertEquals(1, countRegex(res, Pattern.quote(email2))); + + User.getById(id).updateDefaultEmail(ea); + clearCaches(); + res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id)); + assertEquals(1, countRegex(res, Pattern.quote(email))); + assertEquals(2, countRegex(res, Pattern.quote(email2))); + } + @Test public void testUserDetailsEdit() throws MalformedURLException, IOException { String email = createUniqueName() + "@example.com"; @@ -104,11 +134,11 @@ public class TestSEAdminPageDetails extends ClientTest { } private int logCountAdmin(int id) throws IOException { - return getLogEntryCount(IOUtils.readURL(get(UserHistory.SUPPORT_PATH.replace("*", Integer.toString(id))))); + return getLogEntryCount(IOUtils.readURL(get(History.SUPPORT_PATH.replace("*", Integer.toString(id))))); } private int logCountUser(String cookie) throws IOException { - return getLogEntryCount(IOUtils.readURL(get(cookie, UserHistory.PATH))); + return getLogEntryCount(IOUtils.readURL(get(cookie, History.PATH))); } private int getLogEntryCount(String readURL) {