]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/account/TestDomain.java
fix: ResultSet.getDate is often wrong as it fetches day-precision times
[gigi.git] / tests / org / cacert / gigi / pages / account / TestDomain.java
1 package org.cacert.gigi.pages.account;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.net.URLEncoder;
7
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;
12
13 public class TestDomain extends ClientTest {
14
15     public TestDomain() throws IOException {}
16
17     @Test
18     public void testAdd() throws IOException {
19         assertNull(addDomain(cookie, uniq + ".de"));
20         assertNotNull(addDomain(cookie, uniq + ".de"));
21     }
22
23     @Test
24     public void testInvalid() throws IOException {
25         assertNotNull(addDomain(cookie, uniq + ".invalid"));
26     }
27
28     @Test
29     public void testHighFinancialValue() throws IOException {
30         assertNotNull(addDomain(cookie, "google.com"));
31     }
32
33     @Test
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));
39         // double delete
40         assertNotNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d0.getId(), 0));
41         // re-add
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));
46     }
47
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);
50     }
51 }