]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/admin/TestSEAdminPage.java
5c2cb2995b17563c2f125fd9552ed40109d5cc4c
[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.pages.admin.support.SupportUserDetailsPage;
16 import org.cacert.gigi.testUtils.ClientTest;
17 import org.junit.Test;
18
19 public class TestSEAdminPage extends ClientTest {
20
21     public TestSEAdminPage() throws IOException {
22         grant(email, Group.SUPPORTER);
23     }
24
25     @Test
26     public void testFulltextMailSearch() throws MalformedURLException, UnsupportedEncodingException, IOException {
27         String mail = createUniqueName() + "@example.com";
28         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
29         URLConnection uc = new URL("https://" + getServerName() + FindUserPage.PATH).openConnection();
30         uc.addRequestProperty("Cookie", cookie);
31         String csrf = getCSRF(uc, 0);
32
33         uc = new URL("https://" + getServerName() + FindUserPage.PATH).openConnection();
34         uc.addRequestProperty("Cookie", cookie);
35         uc.setDoOutput(true);
36         OutputStream os = uc.getOutputStream();
37         os.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8") + "&" //
38                 + "process&email=" + URLEncoder.encode(mail, "UTF-8")).getBytes("UTF-8"));
39         os.flush();
40         assertEquals("https://" + getServerName() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
41     }
42 }