1 package org.cacert.gigi.testUtils;
3 import java.io.IOException;
4 import java.net.HttpURLConnection;
6 import java.net.URLConnection;
8 import org.cacert.gigi.dbObjects.User;
11 * Superclass for testsuites in a scenario where there is an registered member,
12 * who is already logged on.
14 public abstract class ClientTest extends ManagedTest {
17 * Email of the member.
19 protected String email = createUniqueName() + "@example.org";
24 protected int id = createVerifiedUser("a", "b", email, TEST_PASSWORD);
27 * {@link User} object of the member
29 protected User u = User.getById(id);
32 * Session cookie of the member.
34 protected String cookie;
38 cookie = login(email, TEST_PASSWORD);
39 } catch (IOException e) {
44 public HttpURLConnection post(String path, String query) throws IOException {
45 return post(path, query, 0);
48 public HttpURLConnection post(String path, String query, int formIndex) throws IOException {
49 return post(cookie, path, query, formIndex);
52 public HttpURLConnection get(String path) throws IOException {
56 public HttpURLConnection get(String path, int formIndex) throws IOException {
57 URLConnection uc = new URL("https://" + getServerName() + path).openConnection();
58 uc.addRequestProperty("Cookie", cookie);
59 return (HttpURLConnection) uc;