From: Janis Streib Date: Sun, 24 Aug 2014 10:06:17 +0000 (+0200) Subject: ADD: Test for contact information X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=2cef253ba7943a41231e703674bdaad9b9770968;ds=sidebyside ADD: Test for contact information --- 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)); + } +}