1 package org.cacert.gigi;
3 import static org.junit.Assert.*;
5 import org.cacert.gigi.dbObjects.Domain;
6 import org.cacert.gigi.dbObjects.User;
7 import org.cacert.gigi.testUtils.ManagedTest;
10 public class TestDomain extends ManagedTest {
15 int uid = createVerifiedUser("fn", "ln", createUniqueName() + "pr@test-email.de", TEST_PASSWORD);
16 us = User.getById(uid);
20 public void testDomain() throws InterruptedException, GigiApiException {
21 assertEquals(0, us.getDomains().length);
22 Domain d = new Domain(us, "v1.example.org");
23 assertEquals(0, d.getId());
25 Domain[] domains = us.getDomains();
26 assertEquals(1, domains.length);
27 assertEquals("v1.example.org", domains[0].getSuffix());
28 assertEquals(domains[0].getOwner().getId(), us.getId());
29 assertNotEquals(0, domains[0].getId());
30 assertNotEquals(0, d.getId());
31 assertEquals(d.getId(), domains[0].getId());
33 Domain d2 = new Domain(us, "v2.example.org");
34 assertEquals(0, d2.getId());
37 domains = us.getDomains();
38 assertEquals(2, domains.length);
39 assertEquals("v2.example.org", domains[1].getSuffix());
40 assertEquals(domains[0].getOwner().getId(), us.getId());
41 assertEquals(domains[1].getOwner().getId(), us.getId());
42 assertNotEquals(0, domains[0].getId());
43 assertNotEquals(0, d.getId());
44 assertEquals(d.getId(), domains[0].getId());
49 public void testDoubleDomain() throws InterruptedException, GigiApiException {
50 Domain d = new Domain(us, "dub.example.org");
53 Domain d2 = new Domain(us, "dub.example.org");
55 fail("expected exception");
56 } catch (GigiApiException e) {
62 public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
63 Domain d = new Domain(us, "del.example.org");
66 Domain d2 = new Domain(us, "del.example.org");
71 public void testDoubleDomainPrefix() throws InterruptedException, GigiApiException {
72 Domain d = new Domain(us, "pref.aexample.org");
74 Domain d2 = new Domain(us, "a.pref.aexample.org");
77 fail("expected exception");
78 } catch (GigiApiException e) {
81 Domain d3 = new Domain(us, "aexample.org");
84 fail("expected exception");
85 } catch (GigiApiException e) {
91 public void testDoubleInsertDomain() throws InterruptedException, GigiApiException {
92 Domain d = new Domain(us, "dins.example.org");
96 fail("expected exception");
97 } catch (GigiApiException e) {