X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FTestMailManagement.java;h=531a2fdc4b76c72c1331fa2ec473c29060b649f7;hb=347879beace3f8d3244136b2c1f2db3666eff64c;hp=42786d48213c6c754df86889f6d08d2899bb7e35;hpb=7006bd42c191b4f4ebd39b31e08fb2a865763be9;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/account/TestMailManagement.java b/tests/org/cacert/gigi/pages/account/TestMailManagement.java index 42786d48..531a2fdc 100644 --- a/tests/org/cacert/gigi/pages/account/TestMailManagement.java +++ b/tests/org/cacert/gigi/pages/account/TestMailManagement.java @@ -12,7 +12,6 @@ import org.cacert.gigi.GigiApiException; import org.cacert.gigi.Language; import org.cacert.gigi.User; import org.cacert.gigi.testUtils.ManagedTest; -import org.cacert.gigi.testUtils.TestEmailReciever.TestMail; import org.junit.Test; public class TestMailManagement extends ManagedTest { @@ -28,12 +27,7 @@ public class TestMailManagement extends ManagedTest { @Test public void testMailAddInternal() throws InterruptedException, GigiApiException { - EmailAddress adrr = new EmailAddress("test@test.tld", u); - adrr.insert(Language.getInstance("en")); - TestMail testMail = getMailReciever().recieve(); - assertTrue(adrr.getAddress().equals(testMail.getTo())); - String hash = testMail.extractLink().substring(testMail.extractLink().lastIndexOf('=') + 1); - adrr.verify(hash); + createVerifiedEmail(u); } @Test @@ -72,4 +66,66 @@ public class TestMailManagement extends ManagedTest { } } } + + @Test + public void testMailSetDefaultWeb() throws MalformedURLException, UnsupportedEncodingException, IOException, + InterruptedException, GigiApiException { + EmailAddress adrr = createVerifiedEmail(u); + assertNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId())); + assertEquals(User.getById(u.getId()).getEmail(), adrr.getAddress()); + } + + @Test + public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, + IOException, InterruptedException, GigiApiException { + EmailAddress adrr = new EmailAddress(createUniqueName() + "test@test.tld", u); + adrr.insert(Language.getInstance("en")); + assertNotNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId())); + assertNotEquals(User.getById(u.getId()).getEmail(), adrr.getAddress()); + getMailReciever().clearMails(); + } + + @Test + public void testMailSetDefaultWebInvalidID() throws MalformedURLException, UnsupportedEncodingException, + IOException, InterruptedException, GigiApiException { + User u2 = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@example.org", TEST_PASSWORD)); + int id = -1; + EmailAddress[] emails = u2.getEmails(); + for (int i = 0; i < emails.length; i++) { + if (emails[i].getAddress().equals(u2.getEmail())) { + id = emails[i].getId(); + } + } + assertNotEquals(id, -1); + assertNotNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + id)); + assertNotEquals(User.getById(u.getId()).getEmail(), u2.getEmail()); + getMailReciever().clearMails(); + } + + @Test + public void testMailDeleteWeb() throws InterruptedException, GigiApiException, MalformedURLException, + UnsupportedEncodingException, IOException { + EmailAddress addr = createVerifiedEmail(u); + assertNull(executeBasicWebInteraction(cookie, path, "delete&delid[]=" + addr.getId(), 0)); + User u = User.getById(this.u.getId()); + EmailAddress[] addresses = u.getEmails(); + for (int i = 0; i < addresses.length; i++) { + assertNotEquals(addresses[i].getAddress(), addr.getAddress()); + } + } + + @Test + public void testMailDeleteWebMulti() throws InterruptedException, GigiApiException, MalformedURLException, + UnsupportedEncodingException, IOException { + EmailAddress[] addr = new EmailAddress[] { createVerifiedEmail(u), createVerifiedEmail(u) }; + assertNull(executeBasicWebInteraction(cookie, path, + "delete&delid[]=" + addr[0].getId() + "&delid[]=" + + addr[1].getId(), 0)); + User u = User.getById(this.u.getId()); + EmailAddress[] addresses = u.getEmails(); + for (int i = 0; i < addresses.length; i++) { + assertNotEquals(addresses[i].getAddress(), addr[0].getAddress()); + assertNotEquals(addresses[i].getAddress(), addr[1].getAddress()); + } + } }