]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/account/TestMailManagement.java
ADD: Test for faulty mail deletion
[gigi.git] / tests / org / cacert / gigi / pages / account / TestMailManagement.java
index 119d4bc62216e93a626f7c03c4d150c497a70250..053aa32f5c604714e4a7250fbbb4e8be188969d2 100644 (file)
@@ -102,4 +102,38 @@ public class TestMailManagement extends ManagedTest {
                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());
+               }
+       }
+
+       @Test
+       public void testMailDeleteWebFaulty() throws MalformedURLException, UnsupportedEncodingException, IOException {
+               User u2 = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@test.tld", TEST_PASSWORD));
+               EmailAddress em = u2.getEmails()[0];
+               assertNotNull(executeBasicWebInteraction(cookie, path, "delete&delid[]=" + em.getId(), 0));
+               u2 = User.getById(u2.getId());
+               assertNotEquals(u2.getEmails().length, 0);
+       }
 }