X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FtestUtils%2FPingTest.java;h=967fdb2ded062a95e998f640767bd77ecbee4cfc;hb=6d1b746247f6e1eab7d1da17112beb9cf5abb089;hp=31f45c99b8143c3e0d40e66ffccc70568a186d0e;hpb=ed2d14a0fb2a1ce8df9537c0e8895bb2f783adfc;p=gigi.git diff --git a/tests/org/cacert/gigi/testUtils/PingTest.java b/tests/org/cacert/gigi/testUtils/PingTest.java index 31f45c99..967fdb2d 100644 --- a/tests/org/cacert/gigi/testUtils/PingTest.java +++ b/tests/org/cacert/gigi/testUtils/PingTest.java @@ -46,30 +46,27 @@ public abstract class PingTest extends ClientTest { } } - protected URL sendDomainForm(URL u, String content) throws IOException, MalformedURLException { - URLConnection openConnection = u.openConnection(); - openConnection.setRequestProperty("Cookie", cookie); + protected String sendDomainForm(String content) throws IOException, MalformedURLException { + URLConnection openConnection = get(DomainOverview.PATH); openConnection.setDoOutput(true); openConnection.getOutputStream().write(content.getBytes("UTF-8")); openConnection.getHeaderField("Location"); - if (((HttpURLConnection) openConnection).getResponseCode() != 302) { - throw new Error(IOUtils.readURL(openConnection)); + int code = ((HttpURLConnection) openConnection).getResponseCode(); + if (code != 302) { + throw new Error("Code was: " + code + "\ncontent was: " + IOUtils.readURL(openConnection)); } - String newcontent = IOUtils.readURL(cookie(u.openConnection(), cookie)); + String newcontent = IOUtils.readURL(get(DomainOverview.PATH)); Pattern dlink = Pattern.compile(DomainOverview.PATH + "([0-9]+)'>"); Matcher m1 = dlink.matcher(newcontent); if ( !m1.find()) { throw new Error(newcontent); } - URL u2 = new URL(u.toString() + m1.group(1)); - return u2; + return DomainOverview.PATH + m1.group(1); } - protected Matcher initailizeDomainForm(URL u) throws IOException, Error { - URLConnection openConnection = u.openConnection(); - openConnection.setRequestProperty("Cookie", cookie); - String content1 = IOUtils.readURL(openConnection); + protected Matcher initailizeDomainForm() throws IOException, Error { + String content1 = IOUtils.readURL(get(DomainOverview.PATH)); csrf = getCSRF(1, content1); Pattern p = Pattern.compile("([A-Za-z0-9]+)._cacert._auth IN TXT ([A-Za-z0-9]+)");