]> WPIA git - gigi.git/blob - tests/club/wpia/gigi/testUtils/ClientTest.java
1cd12d2656ab7cc4e3386bf4418b2c29814ed774
[gigi.git] / tests / club / wpia / gigi / testUtils / ClientTest.java
1 package club.wpia.gigi.testUtils;
2
3 import java.io.IOException;
4 import java.net.HttpURLConnection;
5
6 import club.wpia.gigi.dbObjects.User;
7
8 /**
9  * Superclass for testsuites in a scenario where there is an registered member,
10  * who is already logged on.
11  */
12 public abstract class ClientTest extends ManagedTest {
13
14     /**
15      * Email of the member.
16      */
17     protected String email = createUniqueName() + "@example.org";
18
19     /**
20      * Id of the member
21      */
22     protected int id = createVerifiedUser("a", "b", email, TEST_PASSWORD);
23
24     /**
25      * {@link User} object of the member
26      */
27     protected User u = User.getById(id);
28
29     /**
30      * Session cookie of the member.
31      */
32     protected String cookie;
33
34     public ClientTest() {
35         try {
36             cookie = login(email, TEST_PASSWORD);
37         } catch (IOException e) {
38             throw new Error(e);
39         }
40     }
41
42     public HttpURLConnection post(String path, String query) throws IOException {
43         return post(path, query, 0);
44     }
45
46     public HttpURLConnection post(String path, String query, int formIndex) throws IOException {
47         return post(cookie, path, query, formIndex);
48     }
49
50     public HttpURLConnection get(String path) throws IOException {
51         return get(cookie, path);
52     }
53
54 }