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