]> WPIA git - gigi.git/commitdiff
ADD: basic TTP-application-tests.
authorFelix Dörre <felix@dogcraft.de>
Sun, 21 Sep 2014 13:54:08 +0000 (15:54 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sun, 21 Sep 2014 13:54:08 +0000 (15:54 +0200)
tests/org/cacert/gigi/pages/wot/TestTTP.java [new file with mode: 0644]

diff --git a/tests/org/cacert/gigi/pages/wot/TestTTP.java b/tests/org/cacert/gigi/pages/wot/TestTTP.java
new file mode 100644 (file)
index 0000000..f118080
--- /dev/null
@@ -0,0 +1,48 @@
+package org.cacert.gigi.pages.wot;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.dbObjects.Group;
+import org.cacert.gigi.dbObjects.ObjectCache;
+import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.testUtils.IOUtils;
+import org.cacert.gigi.testUtils.ManagedTest;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+public class TestTTP extends ManagedTest {
+
+    User u = User.getById(createVerifiedUser("fn", "ln", "test-" + createUniqueName() + "@example.org", TEST_PASSWORD));
+
+    String cookie = login(u.getEmail(), TEST_PASSWORD);
+
+    URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
+
+    public TestTTP() throws IOException {}
+
+    @Test
+    public void testTTPApply() throws IOException {
+        String ttp = IOUtils.readURL(cookie(ttpPage.openConnection(), cookie));
+        assertThat(ttp, containsString("<form"));
+        executeBasicWebInteraction(cookie, RequestTTPPage.PATH, "country=0");
+
+        ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
+        assertThat(ttp, not(containsString("<form")));
+        ObjectCache.clearAllCaches();
+        u = User.getById(u.getId());
+        assertTrue(u.isInGroup(Group.getByString("ttp-applicant")));
+    }
+
+    @Test
+    public void testTTPEnoughPoints() throws IOException, GigiApiException {
+        User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
+        cookie = login(u.getEmail(), TEST_PASSWORD);
+
+        String ttp = IOUtils.readURL(cookie(new URL("https://" + getServerName() + RequestTTPPage.PATH).openConnection(), cookie));
+        assertThat(ttp, not(containsString("<form")));
+    }
+}