]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/admin/TestSEAdminPage.java
ADD: Fulltext mail based user search test (SE)
[gigi.git] / tests / org / cacert / gigi / pages / admin / TestSEAdminPage.java
1 package org.cacert.gigi.pages.admin;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.io.OutputStream;
7 import java.io.UnsupportedEncodingException;
8 import java.net.MalformedURLException;
9 import java.net.URL;
10 import java.net.URLConnection;
11 import java.net.URLEncoder;
12
13 import org.cacert.gigi.dbObjects.Group;
14 import org.cacert.gigi.pages.admin.support.FindUserPage;
15 import org.cacert.gigi.testUtils.ClientTest;
16 import org.junit.Test;
17
18 public class TestSEAdminPage extends ClientTest {
19
20     public TestSEAdminPage() throws IOException {
21         grant(email, Group.SUPPORTER);
22     }
23
24     @Test
25     public void testFulltextMailSearch() throws MalformedURLException, UnsupportedEncodingException, IOException {
26         String mail = createUniqueName() + "@example.com";
27         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
28         URLConnection uc = new URL("https://" + getServerName() + FindUserPage.PATH).openConnection();
29         uc.addRequestProperty("Cookie", cookie);
30         String csrf = getCSRF(uc, 0);
31
32         uc = new URL("https://" + getServerName() + FindUserPage.PATH).openConnection();
33         uc.addRequestProperty("Cookie", cookie);
34         uc.setDoOutput(true);
35         OutputStream os = uc.getOutputStream();
36         os.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8") + "&" //
37                 + "process&email=" + URLEncoder.encode(mail, "UTF-8")).getBytes("UTF-8"));
38         os.flush();
39         assertEquals("https://" + getServerName() + "/support/user/" + id, uc.getHeaderField("Location"));
40     }
41 }