]> WPIA git - gigi.git/commitdiff
add: test cases for domain/email case-sensitivity #15
authorFelix Dörre <felix@dogcraft.de>
Fri, 17 Jun 2016 15:34:58 +0000 (17:34 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sat, 18 Jun 2016 13:19:20 +0000 (15:19 +0200)
Change-Id: I8665aad5dea38a8b24ee3bbc5fde9f21e63c5e77

tests/org/cacert/gigi/TestDomain.java
tests/org/cacert/gigi/pages/account/TestMailManagement.java

index 00919975224b3cb9bd3740c624ab107008767559..91f29c7a0389daaab33e9c25be80806c69218905 100644 (file)
@@ -51,7 +51,19 @@ public class TestDomain extends ManagedTest {
         new Domain(us, us, "dub-example.org");
         try {
             new Domain(us, us, "dub-example.org");
         new Domain(us, us, "dub-example.org");
         try {
             new Domain(us, us, "dub-example.org");
-            fail("expected exception");
+            fail("expected exception, was able to insert domain (with different case) a second time");
+        } catch (GigiApiException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testDoubleDomainCase() throws InterruptedException, GigiApiException {
+        Domain d = new Domain(us, us, "dub2-ExaMple.Org");
+        assertEquals("dub2-example.org", d.getSuffix());
+        try {
+            new Domain(us, us, "duB2-eXample.oRG");
+            fail("expected exception, was able to insert domain (with different case) a second time");
         } catch (GigiApiException e) {
             // expected
         }
         } catch (GigiApiException e) {
             // expected
         }
index 958954a36cfa0d7ab5a9c884f4846cc4182164b3..5fd14212ca9773b8a393c04eebd545d56e80ee40 100644 (file)
@@ -44,26 +44,46 @@ public class TestMailManagement extends ClientTest {
     @Test
     public void testMailAddWeb() throws MalformedURLException, UnsupportedEncodingException, IOException {
         String newMail = createUniqueName() + "uni@example.org";
     @Test
     public void testMailAddWeb() throws MalformedURLException, UnsupportedEncodingException, IOException {
         String newMail = createUniqueName() + "uni@example.org";
-        assertNull(executeBasicWebInteraction(cookie, path, "addmail&newemail=" + URLEncoder.encode(newMail, "UTF-8"), 1));
-        EmailAddress[] addrs = u.getEmails();
-        for (int i = 0; i < addrs.length; i++) {
-            if (addrs[i].getAddress().equals(newMail)) {
-                return;
-            }
-        }
-        fail();
+        assertNull(addMail(newMail));
+        assertTrue(existsEmail(newMail));
     }
 
     @Test
     public void testMailAddWebFaulty() throws MalformedURLException, UnsupportedEncodingException, IOException {
         String newMail = createUniqueName() + "uniexample.org";
     }
 
     @Test
     public void testMailAddWebFaulty() throws MalformedURLException, UnsupportedEncodingException, IOException {
         String newMail = createUniqueName() + "uniexample.org";
-        assertNotNull(executeBasicWebInteraction(cookie, path, "addmail&newemail=" + URLEncoder.encode(newMail, "UTF-8"), 1));
+        assertNotNull(addMail(newMail));
+        assertFalse(existsEmail(newMail));
+    }
+
+    @Test
+    public void testMailAddWebMultiple() throws MalformedURLException, UnsupportedEncodingException, IOException {
+        String u = createUniqueName();
+        String newMail = u + "uni@eXample.org";
+        assertNull(addMail(newMail));
+        assertTrue(existsEmail(newMail.toLowerCase()));
+
+        String newMail2 = u + "uni@eXamPlE.org";
+        assertNotNull(addMail(newMail2));
+        assertTrue(existsEmail(newMail2.toLowerCase()));
+
+        String newMail3 = u + "-buni@eXamPlE.org";
+        assertNull(addMail(newMail3));
+        assertTrue(existsEmail(newMail.toLowerCase()));
+        assertTrue(existsEmail(newMail3.toLowerCase()));
+    }
+
+    private String addMail(String newMail) throws IOException, MalformedURLException, UnsupportedEncodingException {
+        return executeBasicWebInteraction(cookie, path, "addmail&newemail=" + URLEncoder.encode(newMail, "UTF-8"), 1);
+    }
+
+    private boolean existsEmail(String newMail) {
         EmailAddress[] addrs = u.getEmails();
         for (int i = 0; i < addrs.length; i++) {
             if (addrs[i].getAddress().equals(newMail)) {
         EmailAddress[] addrs = u.getEmails();
         for (int i = 0; i < addrs.length; i++) {
             if (addrs[i].getAddress().equals(newMail)) {
-                fail();
+                return true;
             }
         }
             }
         }
+        return false;
     }
 
     @Test
     }
 
     @Test