1 package org.cacert.gigi;
3 import static org.junit.Assert.*;
5 import org.cacert.gigi.testUtils.ManagedTest;
8 public class TestDomain extends ManagedTest {
13 int uid = createVerifiedUser("fn", "ln", createUniqueName() + "pr@test-email.de", TEST_PASSWORD);
14 us = User.getById(uid);
18 public void testDomain() throws InterruptedException, GigiApiException {
19 assertEquals(0, us.getDomains().length);
20 Domain d = new Domain(us, "v1.example.org");
21 assertEquals(0, d.getId());
23 Domain[] domains = us.getDomains();
24 assertEquals(1, domains.length);
25 assertEquals("v1.example.org", domains[0].getSuffix());
26 assertEquals(domains[0].getOwner().getId(), us.getId());
27 assertNotEquals(0, domains[0].getId());
28 assertNotEquals(0, d.getId());
29 assertEquals(d.getId(), domains[0].getId());
31 Domain d2 = new Domain(us, "v2.example.org");
32 assertEquals(0, d2.getId());
35 domains = us.getDomains();
36 assertEquals(2, domains.length);
37 assertEquals("v2.example.org", domains[1].getSuffix());
38 assertEquals(domains[0].getOwner().getId(), us.getId());
39 assertEquals(domains[1].getOwner().getId(), us.getId());
40 assertNotEquals(0, domains[0].getId());
41 assertNotEquals(0, d.getId());
42 assertEquals(d.getId(), domains[0].getId());
47 public void testDoubleDomain() throws InterruptedException, GigiApiException {
48 Domain d = new Domain(us, "dub.example.org");
51 Domain d2 = new Domain(us, "dub.example.org");
53 fail("expected exception");
54 } catch (GigiApiException e) {
60 public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
61 Domain d = new Domain(us, "del.example.org");
64 Domain d2 = new Domain(us, "del.example.org");
69 public void testDoubleDomainPrefix() throws InterruptedException, GigiApiException {
70 Domain d = new Domain(us, "pref.aexample.org");
72 Domain d2 = new Domain(us, "a.pref.aexample.org");
75 fail("expected exception");
76 } catch (GigiApiException e) {
79 Domain d3 = new Domain(us, "aexample.org");
82 fail("expected exception");
83 } catch (GigiApiException e) {
89 public void testDoubleInsertDomain() throws InterruptedException, GigiApiException {
90 Domain d = new Domain(us, "dins.example.org");
94 fail("expected exception");
95 } catch (GigiApiException e) {