From f493b1ed80384349511ba31f7099e4576b0a92d3 Mon Sep 17 00:00:00 2001 From: Random Committer Date: Fri, 20 Apr 2018 08:03:45 -0700 Subject: [PATCH] Added test for class Proxy --- .../com/rarchives/ripme/tst/proxyTest.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/test/java/com/rarchives/ripme/tst/proxyTest.java diff --git a/src/test/java/com/rarchives/ripme/tst/proxyTest.java b/src/test/java/com/rarchives/ripme/tst/proxyTest.java new file mode 100644 index 00000000..32b7958c --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/proxyTest.java @@ -0,0 +1,42 @@ +package com.rarchives.ripme.tst; + +import java.io.IOException; +import java.net.URL; +import com.rarchives.ripme.utils.Proxy; +import com.rarchives.ripme.utils.Utils; +import junit.framework.TestCase; +import com.rarchives.ripme.utils.Http; + + +public class proxyTest extends TestCase { + // This test will only run on machines where the user has added a entry for socks.server + public void testSocksProxy() throws IOException { + URL url = new URL("https://icanhazip.com"); + String proxyConfig = Utils.getConfigString("socks.server", ""); + if (!proxyConfig.equals("")) { + String ip1 = Http.url(url).ignoreContentType().get().text(); + Proxy.setSocks(Utils.getConfigString("socks.server", "")); + String ip2 = Http.url(url).ignoreContentType().get().text(); + assertFalse(ip1.equals(ip2)); + } else { + System.out.println("Skipping testSocksProxy"); + assert(true); + } + } + + // This test will only run on machines where the user has added a entry for proxy.server + public void testHTTPProxy() throws IOException { + URL url = new URL("https://icanhazip.com"); + String proxyConfig = Utils.getConfigString("proxy.server", ""); + if (!proxyConfig.equals("")) { + String ip1 = Http.url(url).ignoreContentType().get().text(); + Proxy.setHTTPProxy(Utils.getConfigString("proxy.server", "")); + String ip2 = Http.url(url).ignoreContentType().get().text(); + assertFalse(ip1.equals(ip2)); + } else { + System.out.println("Skipping testHTTPProxy"); + assert(true); + } + } + +}