]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/orga/TestOrgDomain.java
0ee3b4094ece94ab7c2106271a9c096af0bc85c4
[gigi.git] / tests / org / cacert / gigi / pages / orga / TestOrgDomain.java
1 package org.cacert.gigi.pages.orga;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.net.URLEncoder;
7
8 import org.cacert.gigi.GigiApiException;
9 import org.cacert.gigi.dbObjects.Domain;
10 import org.cacert.gigi.dbObjects.Group;
11 import org.cacert.gigi.dbObjects.Organisation;
12 import org.cacert.gigi.testUtils.ClientTest;
13 import org.junit.Test;
14
15 public class TestOrgDomain extends ClientTest {
16
17     public TestOrgDomain() throws IOException {
18         makeAssurer(u.getId());
19         u.grantGroup(u, Group.ORGASSURER);
20         clearCaches();
21         cookie = login(email, TEST_PASSWORD);
22     }
23
24     @Test
25     public void testAdd() throws IOException, GigiApiException {
26         Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
27         String dom = createUniqueName() + ".de";
28         assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId(), "addDomain&domain=" + URLEncoder.encode(dom, "UTF-8"), 3));
29         Domain[] d = o1.getDomains();
30         assertEquals(1, d.length);
31         assertEquals(dom, d[0].getSuffix());
32     }
33
34     @Test
35     public void testDel() throws IOException, GigiApiException {
36         Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", u);
37         String dom = createUniqueName() + ".de";
38         Domain d = new Domain(u, o1, dom);
39         assertEquals(1, o1.getDomains().length);
40         assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId(), "delete=" + d.getId(), 2));
41         assertEquals(0, o1.getDomains().length);
42     }
43 }