]> WPIA git - gigi.git/commitdiff
add: yet another org-domain testcase (org-add while in other org)
authorFelix Dörre <felix@dogcraft.de>
Sun, 26 Jun 2016 22:21:25 +0000 (00:21 +0200)
committerFelix Dörre <felix@dogcraft.de>
Mon, 27 Jun 2016 07:47:07 +0000 (09:47 +0200)
Change-Id: Ic461858b6af635a09f346b8fd5f62754f2a8f743

tests/org/cacert/gigi/pages/orga/TestOrgDomain.java

index 6d59f5ea5fc5b48d3ec0c04bc951bf529dedcc24..15eec419f14bf3b2c3fda373d15fed23d659eef2 100644 (file)
@@ -23,7 +23,7 @@ public class TestOrgDomain extends ClientTest {
 
     @Test
     public void testAdd() throws IOException, GigiApiException {
 
     @Test
     public void testAdd() throws IOException, GigiApiException {
-        Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
+        Organisation o1 = createUniqueOrg();
         String dom = createUniqueName() + ".de";
         assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId(), "addDomain&domain=" + URLEncoder.encode(dom, "UTF-8"), 3));
         Domain[] d = o1.getDomains();
         String dom = createUniqueName() + ".de";
         assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId(), "addDomain&domain=" + URLEncoder.encode(dom, "UTF-8"), 3));
         Domain[] d = o1.getDomains();
@@ -33,7 +33,7 @@ public class TestOrgDomain extends ClientTest {
 
     @Test
     public void testDel() throws IOException, GigiApiException {
 
     @Test
     public void testDel() throws IOException, GigiApiException {
-        Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
+        Organisation o1 = createUniqueOrg();
         String dom = createUniqueName() + ".de";
         Domain d = new Domain(u, o1, dom);
         assertEquals(1, o1.getDomains().length);
         String dom = createUniqueName() + ".de";
         Domain d = new Domain(u, o1, dom);
         assertEquals(1, o1.getDomains().length);
@@ -43,7 +43,7 @@ public class TestOrgDomain extends ClientTest {
 
     @Test
     public void testBusinessAddWhileUser() throws IOException, GigiApiException {
 
     @Test
     public void testBusinessAddWhileUser() throws IOException, GigiApiException {
-        Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
+        Organisation o1 = createUniqueOrg();
         String dom = createUniqueName() + ".de";
         new Domain(u, u, dom);
         try {
         String dom = createUniqueName() + ".de";
         new Domain(u, u, dom);
         try {
@@ -58,8 +58,32 @@ public class TestOrgDomain extends ClientTest {
     }
 
     @Test
     }
 
     @Test
-    public void testBusinessAddInvalid() throws IOException, GigiApiException {
+    public void testBusinessAddWhileOtherOrg() throws IOException, GigiApiException {
+        Organisation o1 = createUniqueOrg();
+        Organisation o2 = createUniqueOrg();
+
+        String dom = createUniqueName() + ".de";
+        new Domain(u, o1, dom);
+        try {
+            new Domain(u, o2, dom);
+            fail("Was able to add domain twice.");
+        } catch (GigiApiException e) {
+            assertEquals("Domain could not be inserted. Domain is already known to the system.", e.getMessage());
+            // expected
+        }
+        assertEquals(1, o1.getDomains().length);
+        assertEquals(0, o2.getDomains().length);
+        assertEquals(0, u.getDomains().length);
+    }
+
+    private Organisation createUniqueOrg() throws GigiApiException {
         Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
         Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
+        return o1;
+    }
+
+    @Test
+    public void testBusinessAddInvalid() throws IOException, GigiApiException {
+        Organisation o1 = createUniqueOrg();
         String dom = createUniqueName() + ".invalid-tld";
         try {
             new Domain(u, o1, dom);
         String dom = createUniqueName() + ".invalid-tld";
         try {
             new Domain(u, o1, dom);