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.IOUtils;
14 import org.cacert.gigi.testUtils.ManagedTest;
15 import org.junit.Test;
17 public class TestTTP extends ManagedTest {
19 User u = User.getById(createVerifiedUser("fn", "ln", "test-" + createUniqueName() + "@example.org", TEST_PASSWORD));
21 String cookie = login(u.getEmail(), TEST_PASSWORD);
23 URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
25 public TestTTP() throws IOException {}
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");
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")));
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);
45 String ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
46 assertThat(ttp, not(containsString("<form")));