]> WPIA git - gigi.git/commitdiff
Pullup "login" to managed test
authorFelix Dörre <felix@dogcraft.de>
Fri, 27 Jun 2014 08:48:55 +0000 (10:48 +0200)
committerFelix Dörre <felix@dogcraft.de>
Fri, 27 Jun 2014 13:04:47 +0000 (15:04 +0200)
tests/org/cacert/gigi/LoginTest.java
tests/org/cacert/gigi/testUtils/ManagedTest.java

index 9aa24c763c5de083eaf18ae48ede7620f15fc6c5..729a5988e8053f4f4cf4e3b26828acec9b801a63 100644 (file)
@@ -35,18 +35,5 @@ public class LoginTest extends ManagedTest {
                huc.addRequestProperty("Cookie", cookie);
                return huc.getResponseCode() == 200;
        }
-       public String login(String email, String pw) throws IOException {
-               URL u = new URL("https://" + getServerName() + "/login");
-               HttpURLConnection huc = (HttpURLConnection) u.openConnection();
-               huc.setDoOutput(true);
-               OutputStream os = huc.getOutputStream();
-               String data = "username=" + URLEncoder.encode(email, "UTF-8")
-                               + "&password=" + URLEncoder.encode(pw, "UTF-8");
-               os.write(data.getBytes());
-               os.flush();
-               String headerField = huc.getHeaderField("Set-Cookie");
-               headerField = headerField.substring(0, headerField.indexOf(';'));
-               return headerField;
-       }
 
 }
index 25ae8bb6ed503aa02a77a82ab8f463618fc73183..20fa9147bebf6e91f9bdf768e655e9ebf0d678f0 100644 (file)
@@ -8,6 +8,7 @@ import java.io.DataOutputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
@@ -231,4 +232,17 @@ public class ManagedTest {
        public String createUniqueName() {
                return "test" + System.currentTimeMillis() + "a" + (count++);
        }
+       public String login(String email, String pw) throws IOException {
+               URL u = new URL("https://" + getServerName() + "/login");
+               HttpURLConnection huc = (HttpURLConnection) u.openConnection();
+               huc.setDoOutput(true);
+               OutputStream os = huc.getOutputStream();
+               String data = "username=" + URLEncoder.encode(email, "UTF-8")
+                               + "&password=" + URLEncoder.encode(pw, "UTF-8");
+               os.write(data.getBytes());
+               os.flush();
+               String headerField = huc.getHeaderField("Set-Cookie");
+               headerField = headerField.substring(0, headerField.indexOf(';'));
+               return headerField;
+       }
 }