]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/pages/account/TestContactInformation.java
ADD: Test for contact information
[gigi.git] / tests / org / cacert / gigi / pages / account / TestContactInformation.java
1 package org.cacert.gigi.pages.account;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.net.URL;
7 import java.net.URLConnection;
8
9 import org.cacert.gigi.testUtils.IOUtils;
10 import org.cacert.gigi.testUtils.ManagedTest;
11 import org.junit.Test;
12
13 public class TestContactInformation extends ManagedTest {
14
15     @Test
16     public void testDirectoryListingToggle() throws IOException {
17         String email = createUniqueName() + "@e.fg";
18         createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD);
19         String cookie = login(email, TEST_PASSWORD);
20         assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=&processContact", 1));
21         URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
22         url.setRequestProperty("Cookie", cookie);
23         String res = IOUtils.readURL(url);
24         res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
25         assertTrue(res.contains("value=\"1\" selected"));
26         assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=0&contactinfo=&processContact", 1));
27         url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
28         url.setRequestProperty("Cookie", cookie);
29         res = IOUtils.readURL(url);
30         res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
31         assertTrue(res.contains("value=\"0\" selected"));
32     }
33
34     @Test
35     public void testContactinfoSet() throws IOException {
36         String email = createUniqueName() + "@e.fg";
37         createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD);
38         String cookie = login(email, TEST_PASSWORD);
39         String text = createUniqueName();
40         assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=" + text + "&processContact", 1));
41         URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
42         url.setRequestProperty("Cookie", cookie);
43         String res = IOUtils.readURL(url);
44         res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
45         assertTrue(res.contains(text));
46     }
47 }