X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FTestMailManagement.java;h=44bb5246b2f8fc4beb9f00bb48c14dcd349ac36d;hp=42786d48213c6c754df86889f6d08d2899bb7e35;hb=ef879cc75485cba100021f268ba73242a8eab934;hpb=7006bd42c191b4f4ebd39b31e08fb2a865763be9 diff --git a/tests/org/cacert/gigi/pages/account/TestMailManagement.java b/tests/org/cacert/gigi/pages/account/TestMailManagement.java index 42786d48..44bb5246 100644 --- a/tests/org/cacert/gigi/pages/account/TestMailManagement.java +++ b/tests/org/cacert/gigi/pages/account/TestMailManagement.java @@ -28,12 +28,13 @@ public class TestMailManagement extends ManagedTest { @Test public void testMailAddInternal() throws InterruptedException, GigiApiException { - EmailAddress adrr = new EmailAddress("test@test.tld", u); + EmailAddress adrr = new EmailAddress(createUniqueName() + "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); + getMailReciever().clearMails(); } @Test @@ -72,4 +73,45 @@ public class TestMailManagement extends ManagedTest { } } } + + @Test + public void testMailSetDefaultWeb() throws MalformedURLException, UnsupportedEncodingException, IOException, + InterruptedException, GigiApiException { + EmailAddress adrr = new EmailAddress(createUniqueName() + "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); + assertNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId())); + assertEquals(User.getById(u.getId()).getEmail(), adrr.getAddress()); + getMailReciever().clearMails(); + } + + @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(); + } }