1 package org.cacert.gigi;
3 import static org.junit.Assert.*;
5 import org.cacert.gigi.testUtils.ManagedTest;
8 public class TestDomain extends ManagedTest {
12 int uid = createVerifiedUser("fn", "ln", createUniqueName() + "pr@test-email.de", TEST_PASSWORD);
13 us = User.getById(uid);
17 public void testDomain() throws InterruptedException, GigiApiException {
18 assertEquals(0, us.getDomains().length);
19 Domain d = new Domain(us, "v1.example.org");
20 assertEquals(0, d.getId());
22 Domain[] domains = us.getDomains();
23 assertEquals(1, domains.length);
24 assertEquals("v1.example.org", domains[0].getSuffix());
25 assertEquals(domains[0].getOwner().getId(), us.getId());
26 assertNotEquals(0, domains[0].getId());
27 assertNotEquals(0, d.getId());
28 assertEquals(d.getId(), domains[0].getId());
30 Domain d2 = new Domain(us, "v2.example.org");
31 assertEquals(0, d2.getId());
34 domains = us.getDomains();
35 assertEquals(2, domains.length);
36 assertEquals("v2.example.org", domains[1].getSuffix());
37 assertEquals(domains[0].getOwner().getId(), us.getId());
38 assertEquals(domains[1].getOwner().getId(), us.getId());
39 assertNotEquals(0, domains[0].getId());
40 assertNotEquals(0, d.getId());
41 assertEquals(d.getId(), domains[0].getId());
46 public void testDoubleDomain() throws InterruptedException, GigiApiException {
47 Domain d = new Domain(us, "dub.example.org");
50 Domain d2 = new Domain(us, "dub.example.org");
52 fail("expected exception");
53 } catch (GigiApiException e) {
59 public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
60 Domain d = new Domain(us, "del.example.org");
63 Domain d2 = new Domain(us, "del.example.org");
68 public void testDoubleDomainPrefix() throws InterruptedException, GigiApiException {
69 Domain d = new Domain(us, "pref.aexample.org");
71 Domain d2 = new Domain(us, "a.pref.aexample.org");
74 fail("expected exception");
75 } catch (GigiApiException e) {
78 Domain d3 = new Domain(us, "aexample.org");
81 fail("expected exception");
82 } catch (GigiApiException e) {
88 public void testDoubleInsertDomain() throws InterruptedException, GigiApiException {
89 Domain d = new Domain(us, "dins.example.org");
93 fail("expected exception");
94 } catch (GigiApiException e) {