X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FTestContactInformation.java;fp=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FTestContactInformation.java;h=65fd0779991007555a97fed64392827a4acd7546;hb=2cef253ba7943a41231e703674bdaad9b9770968;hp=0000000000000000000000000000000000000000;hpb=7d143b2edcb0ea7bfe149fd6b77b35ffcf94acf5;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/account/TestContactInformation.java b/tests/org/cacert/gigi/pages/account/TestContactInformation.java new file mode 100644 index 00000000..65fd0779 --- /dev/null +++ b/tests/org/cacert/gigi/pages/account/TestContactInformation.java @@ -0,0 +1,47 @@ +package org.cacert.gigi.pages.account; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +import org.cacert.gigi.testUtils.IOUtils; +import org.cacert.gigi.testUtils.ManagedTest; +import org.junit.Test; + +public class TestContactInformation extends ManagedTest { + + @Test + public void testDirectoryListingToggle() throws IOException { + String email = createUniqueName() + "@e.fg"; + createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD); + String cookie = login(email, TEST_PASSWORD); + assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=&processContact", 1)); + URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection(); + url.setRequestProperty("Cookie", cookie); + String res = IOUtils.readURL(url); + res = res.split(java.util.regex.Pattern.quote(""))[1]; + assertTrue(res.contains("value=\"1\" selected")); + assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=0&contactinfo=&processContact", 1)); + url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection(); + url.setRequestProperty("Cookie", cookie); + res = IOUtils.readURL(url); + res = res.split(java.util.regex.Pattern.quote(""))[1]; + assertTrue(res.contains("value=\"0\" selected")); + } + + @Test + public void testContactinfoSet() throws IOException { + String email = createUniqueName() + "@e.fg"; + createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD); + String cookie = login(email, TEST_PASSWORD); + String text = createUniqueName(); + assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=" + text + "&processContact", 1)); + URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection(); + url.setRequestProperty("Cookie", cookie); + String res = IOUtils.readURL(url); + res = res.split(java.util.regex.Pattern.quote(""))[1]; + assertTrue(res.contains(text)); + } +}