1 package org.cacert.gigi.pages.orga;
3 import static org.junit.Assert.*;
5 import java.io.IOException;
6 import java.net.URLEncoder;
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;
15 public class TestOrgDomain extends ClientTest {
17 public TestOrgDomain() throws IOException {
18 makeAssurer(u.getId());
19 u.grantGroup(u, Group.ORGASSURER);
21 cookie = login(email, TEST_PASSWORD);
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());
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);