]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/wot/TestTTP.java
[EMPTY] Organize all imports
[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.IOUtils;
14 import org.cacert.gigi.testUtils.ManagedTest;
15 import org.junit.Test;
16
17 public class TestTTP extends ManagedTest {
18
19     User u = User.getById(createVerifiedUser("fn", "ln", "test-" + createUniqueName() + "@example.org", TEST_PASSWORD));
20
21     String cookie = login(u.getEmail(), TEST_PASSWORD);
22
23     URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
24
25     public TestTTP() throws IOException {}
26
27     @Test
28     public void testTTPApply() throws IOException {
29         String ttp = IOUtils.readURL(cookie(ttpPage.openConnection(), cookie));
30         assertThat(ttp, containsString("<form"));
31         executeBasicWebInteraction(cookie, RequestTTPPage.PATH, "country=0");
32
33         ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
34         assertThat(ttp, not(containsString("<form")));
35         ObjectCache.clearAllCaches();
36         u = User.getById(u.getId());
37         assertTrue(u.isInGroup(Group.getByString("ttp-applicant")));
38     }
39
40     @Test
41     public void testTTPEnoughPoints() throws IOException, GigiApiException {
42         User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
43         cookie = login(u.getEmail(), TEST_PASSWORD);
44
45         String ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
46         assertThat(ttp, not(containsString("<form")));
47     }
48 }