]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/wot/TestTTP.java
UPD: clean up/document/beatufy testcases.
[gigi.git] / tests / org / cacert / gigi / pages / wot / TestTTP.java
1 package org.cacert.gigi.pages.wot;
2
3 import static org.hamcrest.CoreMatchers.*;
4 import static org.junit.Assert.*;
5
6 import java.io.IOException;
7 import java.net.URL;
8
9 import org.cacert.gigi.GigiApiException;
10 import org.cacert.gigi.dbObjects.Group;
11 import org.cacert.gigi.dbObjects.ObjectCache;
12 import org.cacert.gigi.dbObjects.User;
13 import org.cacert.gigi.testUtils.ClientTest;
14 import org.cacert.gigi.testUtils.IOUtils;
15 import org.junit.Test;
16
17 public class TestTTP extends ClientTest {
18
19     URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
20
21     public TestTTP() throws IOException {}
22
23     @Test
24     public void testTTPApply() throws IOException {
25         String ttp = IOUtils.readURL(cookie(ttpPage.openConnection(), cookie));
26         assertThat(ttp, containsString("<form"));
27         executeBasicWebInteraction(cookie, RequestTTPPage.PATH, "country=0");
28
29         ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
30         assertThat(ttp, not(containsString("<form")));
31         ObjectCache.clearAllCaches();
32         u = User.getById(u.getId());
33         assertTrue(u.isInGroup(Group.getByString("ttp-applicant")));
34     }
35
36     @Test
37     public void testTTPEnoughPoints() throws IOException, GigiApiException {
38         User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
39         cookie = login(u.getEmail(), TEST_PASSWORD);
40
41         String ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
42         assertThat(ttp, not(containsString("<form")));
43     }
44 }