From e6c74ce9b83815f1f58f9987ce7c8996ce3f0914 Mon Sep 17 00:00:00 2001 From: Janis Streib Date: Sun, 24 Aug 2014 03:35:01 +0200 Subject: [PATCH] ADD: Assurance listing tests --- .../cacert/gigi/pages/wot/TestAssurance.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/org/cacert/gigi/pages/wot/TestAssurance.java b/tests/org/cacert/gigi/pages/wot/TestAssurance.java index 6e4d5ea2..55e0c6d9 100644 --- a/tests/org/cacert/gigi/pages/wot/TestAssurance.java +++ b/tests/org/cacert/gigi/pages/wot/TestAssurance.java @@ -1,5 +1,7 @@ package org.cacert.gigi.pages.wot; +import static org.junit.Assert.*; + import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; @@ -11,6 +13,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.regex.Pattern; import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.testUtils.IOUtils; @@ -18,8 +21,6 @@ import org.cacert.gigi.testUtils.ManagedTest; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - public class TestAssurance extends ManagedTest { private String assurerM; @@ -148,6 +149,33 @@ public class TestAssurance extends ManagedTest { assertTrue(error, !error.startsWith("")); } + @Test + public void testAssureListingValid() throws IOException { + String uniqueLoc = createUniqueName(); + String error = getError("date=2000-01-01&location=" + uniqueLoc + "&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10"); + assertNull(error); + String cookie = login(assureeM, TEST_PASSWORD); + URLConnection url = new URL("https://" + getServerName() + MyPoints.PATH).openConnection(); + url.setRequestProperty("Cookie", cookie); + String resp = IOUtils.readURL(url); + resp = resp.split(Pattern.quote(""))[0]; + assertTrue(resp.contains(uniqueLoc)); + } + + + @Test + public void testAssurerListingValid() throws IOException { + String uniqueLoc = createUniqueName(); + String error = getError("date=2000-01-01&location=" + uniqueLoc + "&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10"); + assertNull(error); + String cookie = login(assurerM, TEST_PASSWORD); + URLConnection url = new URL("https://" + getServerName() + MyPoints.PATH).openConnection(); + url.setRequestProperty("Cookie", cookie); + String resp = IOUtils.readURL(url); + resp = resp.split(Pattern.quote(""))[1]; + assertTrue(resp.contains(uniqueLoc)); + } + private String getError(String query) throws MalformedURLException, IOException { URLConnection uc = buildupAssureFormConnection(true); uc.getOutputStream().write((query).getBytes()); -- 2.39.2