1 package org.cacert.gigi.pages.wot;
3 import static org.hamcrest.CoreMatchers.*;
4 import static org.junit.Assert.*;
6 import java.io.IOException;
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;
17 public class TestTTP extends ClientTest {
19 URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
21 public TestTTP() throws IOException {}
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");
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")));
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);
41 String ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
42 assertThat(ttp, not(containsString("<form")));