1 package org.cacert.gigi.pages.account;
3 import static org.junit.Assert.*;
5 import java.io.IOException;
6 import java.net.URLEncoder;
8 import org.cacert.gigi.dbObjects.Domain;
9 import org.cacert.gigi.pages.account.domain.DomainOverview;
10 import org.cacert.gigi.testUtils.ClientTest;
11 import org.junit.Test;
13 public class TestDomain extends ClientTest {
15 public TestDomain() throws IOException {}
18 public void testAdd() throws IOException {
19 assertNull(addDomain(cookie, uniq + ".de"));
20 assertNotNull(addDomain(cookie, uniq + ".de"));
24 public void testInvalid() throws IOException {
25 assertNotNull(addDomain(cookie, uniq + ".invalid"));
29 public void testHighFinancialValue() throws IOException {
30 assertNotNull(addDomain(cookie, "google.com"));
34 public void testDelete() throws IOException {
35 String domain = uniq + ".de";
36 assertNull(addDomain(cookie, domain));
37 Domain d0 = Domain.searchDomain(domain);
38 assertNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d0.getId(), 0));
40 assertNotNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d0.getId(), 0));
42 assertNull(addDomain(cookie, domain));
43 Domain d1 = Domain.searchDomain(domain);
44 assertNotEquals(d0.getId(), d1.getId());
45 assertNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d1.getId(), 0));
48 public static String addDomain(String session, String domain) throws IOException {
49 return executeBasicWebInteraction(session, DomainOverview.PATH, "adddomain&newdomain=" + URLEncoder.encode(domain, "UTF-8"), 1);