diff options
author | Björn Hagemeister | 2014-11-11 14:40:18 +0100 |
---|---|---|
committer | Björn Hagemeister | 2014-11-11 14:40:18 +0100 |
commit | e70ee5b59306ea37dd0c72603c61b33b1555def9 (patch) | |
tree | e6f09d76449da54463b9b4fa408b7dfba4b4b7bf /src/test | |
download | proxy-vole-e70ee5b59306ea37dd0c72603c61b33b1555def9.tar.gz proxy-vole-e70ee5b59306ea37dd0c72603c61b33b1555def9.tar.xz proxy-vole-e70ee5b59306ea37dd0c72603c61b33b1555def9.zip |
Added proxy java classes.
Diffstat (limited to 'src/test')
54 files changed, 3342 insertions, 0 deletions
diff --git a/src/test/java/com/btr/proxy/Examples.java b/src/test/java/com/btr/proxy/Examples.java new file mode 100644 index 0000000..e8b52f9 --- /dev/null +++ b/src/test/java/com/btr/proxy/Examples.java @@ -0,0 +1,47 @@ +package com.btr.proxy; + +import java.net.ProxySelector; + +import com.btr.proxy.search.ProxySearch; +import com.btr.proxy.search.ProxySearch.Strategy; +import com.btr.proxy.util.PlatformUtil; +import com.btr.proxy.util.PlatformUtil.Platform; + +/***************************************************************************** + * Some examples on how to use the API + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class Examples { + + public void example1() { + ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); + ProxySelector myProxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(myProxySelector); + } + + public void example2() { + ProxySearch proxySearch = new ProxySearch(); + + if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { + proxySearch.addStrategy(Strategy.IE); + proxySearch.addStrategy(Strategy.FIREFOX); + proxySearch.addStrategy(Strategy.JAVA); + } else + if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { + proxySearch.addStrategy(Strategy.GNOME); + proxySearch.addStrategy(Strategy.KDE); + proxySearch.addStrategy(Strategy.FIREFOX); + } else { + proxySearch.addStrategy(Strategy.OS_DEFAULT); + } + + ProxySelector myProxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(myProxySelector); + } + + +} + diff --git a/src/test/java/com/btr/proxy/TestUtil.java b/src/test/java/com/btr/proxy/TestUtil.java new file mode 100644 index 0000000..24fe8e9 --- /dev/null +++ b/src/test/java/com/btr/proxy/TestUtil.java @@ -0,0 +1,61 @@ +package com.btr.proxy; + +import java.io.File; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.Proxy.Type; + +/***************************************************************************** + * This class defines some constants and helper methods for the unit tests. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class TestUtil { + + public static final String TEST_DATA_FOLDER = "data"; + + public static final Proxy HTTP_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("http_proxy.unit-test.invalid", 8090)); + public static final Proxy HTTPS_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("https_proxy.unit-test.invalid", 8091)); + public static final Proxy FTP_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("ftp_proxy.unit-test.invalid", 8092)); + public static final Proxy SOCKS_TEST_PROXY = new Proxy(Type.SOCKS, InetSocketAddress.createUnresolved("socks_proxy.unit-test.invalid", 8095)); + + public static final URI NO_PROXY_TEST_URI; + public static final URI HTTP_TEST_URI; + public static final URI HTTPS_TEST_URI; + public static final URI FTP_TEST_URI; + public static final URI SOCKS_TEST_URI; + public static final URI LOCAL_TEST_URI; + public static final URI SOCKET_TEST_URI; + + // Setup some testing constants. + static { + try { + NO_PROXY_TEST_URI = new URI("http://no_proxy.unit-test.invalid/"); + HTTP_TEST_URI = new URI("http://host1.unit-test.invalid/"); + HTTPS_TEST_URI = new URI("https://host1.unit-test.invalid/"); + FTP_TEST_URI = new URI("ftp://host1.unit-test.invalid/"); + SOCKS_TEST_URI = new URI("socks://host1.unit-test.invalid/"); + LOCAL_TEST_URI = new URI("http://myhost"); + SOCKET_TEST_URI = new URI("socket://host1.unit-test.invalid/"); + } catch (URISyntaxException e) { + throw new RuntimeException("URI error"+e.getMessage()); + } + } + + /************************************************************************* + * Switch the current user home directory to the to the given test folder. + * @param folder the name of the test folder. + ************************************************************************/ + + public static final void setTestDataFolder(String folder) { + File testTargetDir = new File(TestUtil.class.getResource("/").getFile()); + System.setProperty("user.home", + testTargetDir+ + File.separator+TestUtil.TEST_DATA_FOLDER+File.separator+folder); + } + +} + diff --git a/src/test/java/com/btr/proxy/search/browser/FirefoxTest.java b/src/test/java/com/btr/proxy/search/browser/FirefoxTest.java new file mode 100644 index 0000000..2a45140 --- /dev/null +++ b/src/test/java/com/btr/proxy/search/browser/FirefoxTest.java @@ -0,0 +1,144 @@ +package com.btr.proxy.search.browser; + +import static org.junit.Assert.*; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.search.browser.firefox.FirefoxProxySearchStrategy; +import com.btr.proxy.util.ProxyException; + +/***************************************************************************** + * Unit tests for the firefox search. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +@Ignore +public class FirefoxTest { + + /************************************************************************* + * Setup environment for tests. + ************************************************************************/ + @BeforeClass + public static void setup() { + // Fake the OS for this tests. + System.setProperty("os.name", "Linux"); + } + + /************************************************************************* + * Test method. + * @throws ProxyException on error. + ************************************************************************/ + @Test + public void testNone() throws ProxyException { + TestUtil.setTestDataFolder("ff3_none"); + + FirefoxProxySearchStrategy ff = new FirefoxProxySearchStrategy(); + ProxySelector ps = ff.getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(Proxy.NO_PROXY , result.get(0)); + + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_manual"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttps() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_manual"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualFtp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_manual"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualSocks() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_manual"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.SOCKS_TEST_URI); + assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); + } + + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testPac() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_pac_script"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testWhiteList() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("ff3_white_list"); + + ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + +} + diff --git a/src/test/java/com/btr/proxy/search/browser/IeTest.java b/src/test/java/com/btr/proxy/search/browser/IeTest.java new file mode 100644 index 0000000..3c7e72c --- /dev/null +++ b/src/test/java/com/btr/proxy/search/browser/IeTest.java @@ -0,0 +1,59 @@ +package com.btr.proxy.search.browser; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.search.browser.ie.IELocalByPassFilter; +import com.btr.proxy.search.browser.ie.IEProxySearchStrategy; +import com.btr.proxy.util.PlatformUtil; +import com.btr.proxy.util.ProxyException; +import com.btr.proxy.util.PlatformUtil.Platform; +import com.btr.proxy.util.UriFilter; + +/***************************************************************************** + * Unit tests for the InternetExplorer search. + * Only limited testing as this only runs on windwos and needs a + * installed IE and IE proxy settings written to the registry. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class IeTest { + + /************************************************************************* + * Test method. + * @throws ProxyException on proxy detection error. + ************************************************************************/ + @Test + public void testInvoke() throws ProxyException { + if (Platform.WIN.equals(PlatformUtil.getCurrentPlattform())) { + IEProxySearchStrategy st = new IEProxySearchStrategy(); + + // Try at least to invoke it and test if the dll does not crash + st.getProxySelector(); + } + } + + /************************************************************************* + * Test method. + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException if url syntax is wrong. + * @throws MalformedURLException on wrong url format. + ************************************************************************/ + @Test + public void testLocalByPassFilter() throws ProxyException, MalformedURLException, URISyntaxException { + UriFilter filter = new IELocalByPassFilter(); + assertTrue(filter.accept(TestUtil.LOCAL_TEST_URI)); + assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); + assertFalse(filter.accept(new URL("http://123.45.55.6").toURI())); + } + +} + diff --git a/src/test/java/com/btr/proxy/search/desktop/DesktopProxySearchTest.java b/src/test/java/com/btr/proxy/search/desktop/DesktopProxySearchTest.java new file mode 100644 index 0000000..0f8e6be --- /dev/null +++ b/src/test/java/com/btr/proxy/search/desktop/DesktopProxySearchTest.java @@ -0,0 +1,45 @@ +package com.btr.proxy.search.desktop; + +import java.net.ProxySelector; +import java.net.URI; +import java.net.URISyntaxException; + +import org.junit.Test; + +import com.btr.proxy.search.ProxySearch; +import com.btr.proxy.util.ProxyException; + +/***************************************************************************** + * Unit tests for the desktop facade search strategy. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class DesktopProxySearchTest { + + /************************************************************************* + * Test method. + * @throws ProxyException on error. + ************************************************************************/ + @Test + public void testDesktopStrategsIsWorking() throws ProxyException { + new DesktopProxySearchStrategy().getProxySelector(); + } + + /************************************************************************* + * Test method. + * @throws URISyntaxException on error parsing the URI. + * @throws ProxyException on selector error. + ************************************************************************/ + @Test + public void emptyURIShouldNotRaiseNPE() throws URISyntaxException, ProxyException { + ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); + ProxySelector myProxySelector = proxySearch.getProxySelector(); + if (myProxySelector != null) { + myProxySelector.select(new URI("")); + } + } + + +} + diff --git a/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java b/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java new file mode 100644 index 0000000..0711a8c --- /dev/null +++ b/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java @@ -0,0 +1,78 @@ +package com.btr.proxy.search.desktop.win; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import org.junit.AfterClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.btr.proxy.TestUtil; + +/***************************************************************************** + * Unit tests for DLL loading code. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +@Ignore +public class DLLManagerTest { + + /************************************************************************* + * Reset system property at the end. + ************************************************************************/ + @AfterClass + public static void teardown() { + System.setProperty(DLLManager.LIB_DIR_OVERRIDE, ""); + } + + /************************************************************************* + * Test method + * @throws IOException on error + ************************************************************************/ + @Test + public void testFindLibFileOverride() throws IOException { + String path = TestUtil.class.getResource("/").getFile() + File.separator+"data"+File.separator+"win"; + System.setProperty(DLLManager.LIB_DIR_OVERRIDE, path); + File actual = DLLManager.findLibFile(); + assertTrue(actual.getAbsolutePath().contains(path)); + } + + /************************************************************************* + * Test method + * @throws IOException on error + ************************************************************************/ + @Test + public void testFindLibFileDefault() throws IOException { + System.setProperty(DLLManager.LIB_DIR_OVERRIDE, ""); + File actual = DLLManager.findLibFile(); + assertTrue(actual.getAbsolutePath().contains("lib"+File.separator)); + } + + /************************************************************************* + * Test method + * @throws IOException on error + ************************************************************************/ + @Test + public void testCleanupTempFiles() throws IOException { + File f1 = File.createTempFile(DLLManager.TEMP_FILE_PREFIX+"_ABC", DLLManager.DLL_EXTENSION); + assertTrue(f1.exists()); + DLLManager.cleanupTempFiles(); + assertFalse(f1.exists()); + } + + /************************************************************************* + * Test method + * @throws IOException on error + ************************************************************************/ +// @Test +// public void testFileCopy() throws IOException { +// URL originalFile = DLLManagerTest.class.getResource("/lib/proxy_util_w32.dll"); +// File tempFile = File.createTempFile(DLLManager.TEMP_FILE_PREFIX, DLLManager.TEMP_FILE_PREFIX); +// DLLManager.copy(originalFile.openStream(), new FileOutputStream(tempFile)); +// assertTrue(tempFile.exists() && tempFile.length() == originalFile.length()); +// tempFile.delete(); +// } + +} + diff --git a/src/test/java/com/btr/proxy/search/gnome/GnomeProxySearchTest.java b/src/test/java/com/btr/proxy/search/gnome/GnomeProxySearchTest.java new file mode 100644 index 0000000..875e2d5 --- /dev/null +++ b/src/test/java/com/btr/proxy/search/gnome/GnomeProxySearchTest.java @@ -0,0 +1,117 @@ +package com.btr.proxy.search.gnome; + +import static org.junit.Assert.assertEquals; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.search.desktop.gnome.GnomeProxySearchStrategy; +import com.btr.proxy.util.ProxyException; + + +/***************************************************************************** + * Unit tests for the Gnome settings search strategy. + * For every test the "user.home" system property is switched to the test/data + * folder where we provide some Gnome config files prepared for the test cases. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ +@Ignore +public class GnomeProxySearchTest { + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + ************************************************************************/ + @Test + public void testNone() throws ProxyException { + TestUtil.setTestDataFolder("gnome_none"); + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("gnome_manual"); + + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttps() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("gnome_manual"); + + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualFtp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("gnome_manual"); + + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testPac() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("gnome_pac_script"); + + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testWhiteList() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("gnome_white_list"); + + ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + +} diff --git a/src/test/java/com/btr/proxy/search/java/JavaProxySearchTest.java b/src/test/java/com/btr/proxy/search/java/JavaProxySearchTest.java new file mode 100644 index 0000000..cfc473a --- /dev/null +++ b/src/test/java/com/btr/proxy/search/java/JavaProxySearchTest.java @@ -0,0 +1,137 @@ +package com.btr.proxy.search.java; + +import static org.junit.Assert.*; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.btr.proxy.TestUtil; + + +/***************************************************************************** + * Unit tests for the Java proxy search strategy. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class JavaProxySearchTest { + + private ProxySelector selector; + + /************************************************************************* + * Setup before the tests. + ************************************************************************/ + @BeforeClass + public static void setupClass() { + System.setProperty("http.proxyHost", "http_proxy.unit-test.invalid"); + System.setProperty("http.proxyPort", "8090"); + System.setProperty("http.nonProxyHosts", "no_proxy.unit-test.invalid"); + System.setProperty("https.proxyHost", "https_proxy.unit-test.invalid"); + System.setProperty("https.proxyPort", "8091"); + System.setProperty("ftp.proxyHost", "ftp_proxy.unit-test.invalid"); + System.setProperty("ftp.nonProxyHosts", "no_proxy.unit-test.invalid"); + System.setProperty("ftp.proxyPort", "8092"); + System.setProperty("socksProxyHost", "socks_proxy.unit-test.invalid"); + System.setProperty("socksProxyPort", "8095"); + } + + /************************************************************************* + * Setup before the tests. + ************************************************************************/ + @AfterClass + public static void teardownClass() { + System.clearProperty("http.proxyHost"); + System.clearProperty("http.proxyPort"); + System.clearProperty("http.nonProxyHosts"); + System.clearProperty("https.proxyHost"); + System.clearProperty("https.proxyPort"); + System.clearProperty("ftp.proxyHost"); + System.clearProperty("ftp.nonProxyHosts"); + System.clearProperty("ftp.proxyPort"); + System.clearProperty("socksProxyHost"); + System.clearProperty("socksProxyPort"); + } + + /************************************************************************* + * Setup before every single test + ************************************************************************/ + @Before + public void setup() { + this.selector = new JavaProxySearchStrategy().getProxySelector(); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testHTTP() { + List<Proxy> result = this.selector.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on wrong URI. + ************************************************************************/ + @Test + public void testHTTPnoProxy() throws URISyntaxException { + List<Proxy> result = this.selector.select(new URI("http://no_proxy.unit-test.invalid")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testHTTPS() { + List<Proxy> result = this.selector.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on wrong URI. + ************************************************************************/ + @Test + public void testHTTPSnoProxy() throws URISyntaxException { + List<Proxy> result = this.selector.select(new URI("https://no_proxy.unit-test.invalid")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFTP() { + List<Proxy> result = this.selector.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on wrong URI. + ************************************************************************/ + @Test + public void testFTPnoProxy() throws URISyntaxException { + List<Proxy> result = this.selector.select(new URI("ftp://no_proxy.unit-test.invalid")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testSOCKS() { + List<Proxy> result = this.selector.select(TestUtil.SOCKS_TEST_URI); + assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); + } + +} + diff --git a/src/test/java/com/btr/proxy/search/kde/KdeProxySearchTest.java b/src/test/java/com/btr/proxy/search/kde/KdeProxySearchTest.java new file mode 100644 index 0000000..d600aa2 --- /dev/null +++ b/src/test/java/com/btr/proxy/search/kde/KdeProxySearchTest.java @@ -0,0 +1,177 @@ +package com.btr.proxy.search.kde; + +import static org.junit.Assert.assertEquals; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.search.desktop.kde.KdeProxySearchStrategy; +import com.btr.proxy.util.ProxyException; + + +/***************************************************************************** + * Unit tests for the KDE settings search strategy. + * For every test the "user.home" system property is switched to the test/data + * folder where we provide some KDE config files prepared for the test cases. + * + * If the env tests fail you need to set the followingenvironment variables: + * <p> + * HTTP_PROXY = http://http_proxy.unit-test.invalid:8090 <br/> + * HTTPS_PROXY = http://https_proxy.unit-test.invalid:8091 <br/> + * FTP_PROXY = http://ftp_proxy.unit-test.invalid:8092 <br/> + * </p> + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ +@Ignore +public class KdeProxySearchTest { + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + ************************************************************************/ + @Test + public void testNone() throws ProxyException { + TestUtil.setTestDataFolder("kde_none"); + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("kde_manual"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualHttps() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("kde_manual"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testManualFtp() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("kde_manual"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testPac() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("kde_pac_script"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + @Ignore + public void testEnvHttp() throws ProxyException, URISyntaxException { + // There is no good was to initialize environment variables in the running process. + //System.getenv().put("HTTP_PROXY", "http://http_proxy.unit-test.invalid:8090"); // Does not work + TestUtil.setTestDataFolder("kde_env"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + @Ignore + public void testEnvHttps() throws ProxyException, URISyntaxException { + // There is no good was to initialize environment variables in the running process. + // System.getenv().put("HTTPS_PROXY", "http://http_proxy.unit-test.invalid:8090"); // Does not work + TestUtil.setTestDataFolder("kde_env"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + @Ignore + public void testEnvFtp() throws ProxyException, URISyntaxException { + // there is no good was to initialize environment variables in the running process. + //System.getenv().put("FTP_PROXY", "http://http_proxy.unit-test.invalid:8090"); // Does not work + TestUtil.setTestDataFolder("kde_env"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testWhiteList() throws ProxyException, URISyntaxException { + TestUtil.setTestDataFolder("kde_white_list"); + + ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); + + List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + +} diff --git a/src/test/java/com/btr/proxy/selector/fixed/FixedProxyTest.java b/src/test/java/com/btr/proxy/selector/fixed/FixedProxyTest.java new file mode 100644 index 0000000..c4a7d08 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/fixed/FixedProxyTest.java @@ -0,0 +1,56 @@ +package com.btr.proxy.selector.fixed; + +import static org.junit.Assert.*; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.util.List; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; + + +/***************************************************************************** + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class FixedProxyTest { + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFixedProxy() { + ProxySelector ps = new FixedProxySelector("http_proxy.unit-test.invalid", 8090); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFixedProxy2() { + ProxySelector ps = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFixedProxy3() { + ProxySelector ps = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + +} + diff --git a/src/test/java/com/btr/proxy/selector/java/JavaProxySelectorTest.java b/src/test/java/com/btr/proxy/selector/java/JavaProxySelectorTest.java new file mode 100644 index 0000000..5701e25 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/java/JavaProxySelectorTest.java @@ -0,0 +1,28 @@ +package com.btr.proxy.selector.java; + +import static org.junit.Assert.*; + +import java.net.ProxySelector; + +import org.junit.Test; + +import com.btr.proxy.search.java.JavaProxySearchStrategy; + +/***************************************************************************** + * Some unit tests for the Java Proxy search strategy. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class JavaProxySelectorTest { + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void withoutSystemPropertyShouldReturnNull() { + ProxySelector ps = new JavaProxySearchStrategy().getProxySelector(); + assertNull(ps); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/misc/ProtocolDispatchTest.java b/src/test/java/com/btr/proxy/selector/misc/ProtocolDispatchTest.java new file mode 100644 index 0000000..da27327 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/misc/ProtocolDispatchTest.java @@ -0,0 +1,87 @@ +package com.btr.proxy.selector.misc; + +import static org.junit.Assert.*; + +import java.net.Proxy; +import java.util.List; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.selector.fixed.FixedProxySelector; + +/***************************************************************************** + * Unit Tests for the ProtocolDispatchSelector + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class ProtocolDispatchTest { + + private static ProtocolDispatchSelector ps; + + @BeforeClass + public static void setup() { + ps = new ProtocolDispatchSelector(); + ps.setSelector("http", new FixedProxySelector(TestUtil.HTTP_TEST_PROXY)); + ps.setSelector("https", new FixedProxySelector(TestUtil.HTTPS_TEST_PROXY)); + ps.setSelector("ftp", new FixedProxySelector(TestUtil.FTP_TEST_PROXY)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDispatchHttp() { + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDispatchHttps() { + List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDispatchFtp() { + List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); + assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testRemove() { + ProtocolDispatchSelector px = new ProtocolDispatchSelector(); + FixedProxySelector selector = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + px.setSelector("http", selector); + assertEquals(selector, px.getSelector("http")); + px.removeSelector("http"); + assertNull(px.getSelector("http")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFallback() { + ProtocolDispatchSelector px = new ProtocolDispatchSelector(); + FixedProxySelector selector = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + px.setFallbackSelector(selector); + + List<Proxy> proxies = px.select(TestUtil.HTTP_TEST_URI); + + assertEquals(TestUtil.HTTP_TEST_PROXY, proxies.get(0)); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/misc/ProxyListFallbackSelectorTest.java b/src/test/java/com/btr/proxy/selector/misc/ProxyListFallbackSelectorTest.java new file mode 100644 index 0000000..12c172c --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/misc/ProxyListFallbackSelectorTest.java @@ -0,0 +1,94 @@ +package com.btr.proxy.selector.misc; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; +import java.util.Arrays; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.btr.proxy.TestUtil; + +/***************************************************************************** + * Unit Tests for the ProxyListFallbackSelector + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2011 + ****************************************************************************/ + +public class ProxyListFallbackSelectorTest { + + private ProxyListFallbackSelector selector; + + /************************************************************************* + * Setup before tests. + ************************************************************************/ + @Before + public void setup() { + this.selector = new ProxyListFallbackSelector( + new ProxySelector() { + @Override + public List<Proxy> select(URI uri) { + return Arrays.asList(TestUtil.HTTP_TEST_PROXY, TestUtil.HTTPS_TEST_PROXY, Proxy.NO_PROXY); + } + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + // Not used on the delegate + } + }); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testList() { + List<Proxy> result = this.selector.select(TestUtil.HTTP_TEST_URI); + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(1)); + assertEquals(Proxy.NO_PROXY, result.get(2)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testFailedProxy() { + this.selector.connectFailed( + TestUtil.HTTP_TEST_URI, + TestUtil.HTTP_TEST_PROXY.address(), + new IOException("TEST")); + + List<Proxy> result = this.selector.select(TestUtil.HTTP_TEST_URI); + + assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); + assertEquals(Proxy.NO_PROXY, result.get(1)); + } + + /************************************************************************* + * Test method + * @throws InterruptedException if the test wait period was interrupted + ************************************************************************/ + @Test + public void testFailedProxyRetry() throws InterruptedException { + this.selector.setRetryAfterMs(100); + this.selector.connectFailed( + TestUtil.HTTP_TEST_URI, + TestUtil.HTTP_TEST_PROXY.address(), + new IOException("TEST")); + + List<Proxy> result = this.selector.select(TestUtil.HTTP_TEST_URI); + assertEquals(2, result.size()); + + Thread.sleep(200); + result = this.selector.select(TestUtil.HTTP_TEST_URI); + assertEquals(3, result.size()); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/JavaxPacScriptParserTest.java b/src/test/java/com/btr/proxy/selector/pac/JavaxPacScriptParserTest.java new file mode 100644 index 0000000..ea963f0 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/JavaxPacScriptParserTest.java @@ -0,0 +1,119 @@ +package com.btr.proxy.selector.pac; + +import java.net.MalformedURLException; +import java.util.Calendar; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.util.ProxyException; + +/***************************************************************************** + * Tests for the javax.script PAC script parser. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class JavaxPacScriptParserTest { + + /************************************************************************* + * Set calendar for date and time base tests. + * Current date for all tests is: 15. December 1994 12:00.00 + * its a Thursday + ************************************************************************/ + @BeforeClass + public static void setup() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 1994); + cal.set(Calendar.MONTH, Calendar.DECEMBER); + cal.set(Calendar.DAY_OF_MONTH, 15); + cal.set(Calendar.HOUR_OF_DAY, 12); + cal.set(Calendar.MINUTE, 00); + cal.set(Calendar.SECOND, 00); + cal.set(Calendar.MILLISECOND, 00); + + // TODO Rossi 26.08.2010 need to fake time + // JavaxPacScriptParser.setCurrentTime(cal); + } + + /************************************************************************* + * Cleanup after the tests. + ************************************************************************/ + @AfterClass + public static void teadDown() { + //JavaxPacScriptParser.setCurrentTime(null); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptExecution() throws ProxyException, MalformedURLException { + PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("test1.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testCommentsInScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("test2.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + @Ignore //Test deactivated because it will not run in Java 1.5 and time based test are unstable + public void testScriptWeekDayScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testWeekDay.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + @Ignore //Test deactivated because it will not run in Java 1.5 and time based test are unstable + public void testDateRangeScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testDateRange.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + @Ignore //Test deactivated because it will not run in Java 1.5 and time based test are unstable + public void testTimeRangeScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testTimeRange.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Helper method to build the url to the given test file + * @param testFile the name of the test file. + * @return the URL. + * @throws MalformedURLException + ************************************************************************/ + + private String toUrl(String testFile) throws MalformedURLException { + return JavaxPacScriptParserTest.class.getResource("/" + TestUtil.TEST_DATA_FOLDER + "/pac/" + testFile).toString(); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/PacPerProtocolTest.java b/src/test/java/com/btr/proxy/selector/pac/PacPerProtocolTest.java new file mode 100644 index 0000000..c0b9c67 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/PacPerProtocolTest.java @@ -0,0 +1,47 @@ +package com.btr.proxy.selector.pac; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.Proxy; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; + + +public class PacPerProtocolTest { + + /************************************************************************* + * Test the PAC selector for a given protocol. + * @throws IOException of read error. + * @throws URISyntaxException on uri syntax error. + ************************************************************************/ + @Test + public void testPacForSocket() throws IOException, URISyntaxException { + + new URI("socket://host1.unit-test.invalid/"); + + List<Proxy> result = new PacProxySelector( + new UrlPacScriptSource(toUrl("test1.pac"))).select(TestUtil.SOCKET_TEST_URI); + + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Helper method to build the url to the given test file + * @param testFile the name of the test file. + * @return the URL. + * @throws MalformedURLException + ************************************************************************/ + + private String toUrl(String testFile) throws MalformedURLException { + return PacPerProtocolTest.class.getResource("/" + TestUtil.TEST_DATA_FOLDER + "/pac/" + testFile).toString(); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/PacProxyDebugging.java b/src/test/java/com/btr/proxy/selector/pac/PacProxyDebugging.java new file mode 100644 index 0000000..695bc3a --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/PacProxyDebugging.java @@ -0,0 +1,103 @@ +package com.btr.proxy.selector.pac; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.net.ProxySelector; +import java.net.URL; +import java.net.URLConnection; +import java.text.MessageFormat; + +import com.btr.proxy.search.ProxySearch; +import com.btr.proxy.util.Logger; +import com.btr.proxy.util.Logger.LogLevel; + +/***************************************************************************** + * Test program submitted to test the issue 27 with PAC proxy selector that is + * while downloading the PAC file invoking itself. This has lead to a endless + * loop. The issue is now solved but I keep this test program for future PAC + * testing. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class PacProxyDebugging { + + private static final String TEST_URL = "http://www.asetune.com"; + + /************************************************************************* + * Setup a console logger. + ************************************************************************/ + + private void installLogger() { + Logger.setBackend(new Logger.LogBackEnd() { + public void log(Class<?> clazz, LogLevel loglevel, String msg, Object... params) { + System.out.println(loglevel + "\t"+ MessageFormat.format(msg, params)); + } + + public boolean isLogginEnabled(LogLevel logLevel) { + return true; + } + }); + } + + /************************************************************************* + * Main entry point for the test application. + * @param args the command line arguments. + ************************************************************************/ + + public static void main(String[] args) { + // System.setProperty("http.proxyHost", "10.65.12.21"); + // System.setProperty("http.proxyPort", "8080"); + // System.setProperty("java.net.useSystemProxies", "true"); + + PacProxyDebugging pt = new PacProxyDebugging(); + pt.installLogger(); + + ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); + + // ProxySearch proxySearch = new ProxySearch(); + // proxySearch.addStrategy(Strategy.JAVA); + // proxySearch.addStrategy(Strategy.BROWSER); + // proxySearch.addStrategy(Strategy.OS_DEFAULT); + // proxySearch.addStrategy(Strategy.ENV_VAR); + + ProxySelector myProxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(myProxySelector); + System.out.println("Using proxy selector: " + myProxySelector); + + // String webAddress = "http://www.google.com"; + String webAddress = TEST_URL; + try { + URL url = new URL(webAddress); + // List<Proxy> result = myProxySelector.select(url.toURI()); + // if (result == null || result.size() == 0) + // { + // System.out.println("No proxy found for this url."); + // return; + // } + // System.out.println("Proxy Settings found using 'xxx' strategy.\n" + // + + // "Proxy used for URL is: "+result.get(0)); + + System.out.println("Now open a connection to the url: "+ webAddress); + System.out.println("=============================================="); + + // open the connection and prepare it to POST + URLConnection conn = url.openConnection(); + conn.setConnectTimeout(10 * 1000); + + // Return the response + InputStream in = conn.getInputStream(); + LineNumberReader lr = new LineNumberReader(new InputStreamReader(in)); + String line; + while ((line = lr.readLine()) != null) { + System.out.println("response line " + lr.getLineNumber() + ": " + line); + } + System.out.println("---- END -------------------------------------"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/com/btr/proxy/selector/pac/PacProxySelectorTest.java b/src/test/java/com/btr/proxy/selector/pac/PacProxySelectorTest.java new file mode 100644 index 0000000..a08f9c1 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/PacProxySelectorTest.java @@ -0,0 +1,133 @@ +package com.btr.proxy.selector.pac; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.Proxy; +import java.net.Proxy.Type; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; +import java.util.List; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.util.ProxyException; + + +/***************************************************************************** + * Tests for the Pac script parser and proxy selector. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class PacProxySelectorTest { + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptExecution() throws ProxyException, MalformedURLException { + List<Proxy> result = new PacProxySelector( + new UrlPacScriptSource(toUrl("test1.pac"))).select(TestUtil.HTTP_TEST_URI); + + assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptExecution2() throws ProxyException, MalformedURLException { + PacProxySelector pacProxySelector = new PacProxySelector( + new UrlPacScriptSource(toUrl("test2.pac"))); + List<Proxy> result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + + result = pacProxySelector.select(TestUtil.HTTPS_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test download fix to prevent infinite loop. + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void pacDownloadFromURLShouldNotUseProxy() throws ProxyException, MalformedURLException { + ProxySelector oldOne = ProxySelector.getDefault(); + try { + ProxySelector.setDefault(new ProxySelector() { + @Override + public List<Proxy> select(URI uri) { + throw new IllegalStateException("Should not download via proxy"); + } + + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + // Not used + } + }); + + PacProxySelector pacProxySelector = new PacProxySelector( + new UrlPacScriptSource("http://www.test.invalid/wpad.pac")); + pacProxySelector.select(TestUtil.HTTPS_TEST_URI); + } finally { + ProxySelector.setDefault(oldOne); + } + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptMuliProxy() throws ProxyException, MalformedURLException { + PacProxySelector pacProxySelector = new PacProxySelector( + new UrlPacScriptSource(toUrl("testMultiProxy.pac"))); + List<Proxy> result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); + assertEquals(2, result.size()); + assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy.com", 80)), result.get(0)); + assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy2.com", 8080)), result.get(1)); + } + + /************************************************************************* + * Test method for the override local IP feature. + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testLocalIPOverride() throws ProxyException, MalformedURLException { + System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, "123.123.123.123"); + try { + PacProxySelector pacProxySelector = new PacProxySelector( + new UrlPacScriptSource(toUrl("testLocalIP.pac"))); + List<Proxy> result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); + assertEquals(result.get(0), new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("123.123.123.123", 8080))); + } finally { + System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, ""); + } + + } + + /************************************************************************* + * Helper method to build the url to the given test file + * @param testFile the name of the test file. + * @return the URL. + * @throws MalformedURLException + ************************************************************************/ + + private String toUrl(String testFile) throws MalformedURLException { + return PacProxySelectorTest.class.getResource("/" + TestUtil.TEST_DATA_FOLDER + "/pac/" + testFile).toString(); + } + + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/PacScriptMethodsTest.java b/src/test/java/com/btr/proxy/selector/pac/PacScriptMethodsTest.java new file mode 100644 index 0000000..0d69a1e --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/PacScriptMethodsTest.java @@ -0,0 +1,165 @@ +package com.btr.proxy.selector.pac; + +import static org.junit.Assert.assertEquals; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Calendar; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; + +/***************************************************************************** + * Tests for the global PAC script methods that are used as context inside of + * the scripts. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class PacScriptMethodsTest { + + /************************************************************************* + * Get a methods implementation with a calendar for date and time base tests + * set to a hardcoded data. + * Current date for all tests is: 15. December 1994 12:00.00 + * its a Thursday + ************************************************************************/ + + private PacScriptMethods buildParser() { + PacScriptMethods result = new PacScriptMethods(); + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 1994); + cal.set(Calendar.MONTH, Calendar.DECEMBER); + cal.set(Calendar.DAY_OF_MONTH, 15); + cal.set(Calendar.HOUR_OF_DAY, 12); + cal.set(Calendar.MINUTE, 00); + cal.set(Calendar.SECOND, 00); + cal.set(Calendar.MILLISECOND, 00); + result.setCurrentTime(cal); + + return result; + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDnsDomainIs() { + assertEquals(true, buildParser().dnsDomainIs("host1.unit-test.invalid", "unit-test.invalid")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDnsDomainLevels() { + assertEquals(2, buildParser().dnsDomainLevels(TestUtil.HTTP_TEST_URI.toString())); + } + + /************************************************************************* + * Test method + * @throws UnknownHostException on resolve error. + ************************************************************************/ + @Test + public void testDnsResolve() throws UnknownHostException { + InetAddress adr = Inet4Address.getLocalHost(); + assertEquals(adr.getHostAddress(), buildParser().dnsResolve(adr.getHostName())); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testIsInNet() { + assertEquals(true, buildParser().isInNet("192.168.0.122", "192.168.0.0", "255.255.255.0")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testIsInNet2() { + assertEquals(true, buildParser().isInNet("10.13.75.47", "10.13.72.0", "255.255.252.0")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testIsPlainHostName() { + assertEquals(false, buildParser().isPlainHostName("host1.unit-test.invalid")); + assertEquals(true, buildParser().isPlainHostName("host1")); + } + + /************************************************************************* + * Test method + * @throws UnknownHostException on resolve error. + ************************************************************************/ + @Test + public void testIsResolveable() throws UnknownHostException { + InetAddress adr = Inet4Address.getLocalHost(); + assertEquals(true, buildParser().isResolvable(adr.getHostName())); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testLocalHostOrDomainIs() { + assertEquals(true, buildParser().localHostOrDomainIs("host1.unit-test.invalid", "host1.unit-test.invalid")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testShExpMatch() { + assertEquals(true, buildParser().shExpMatch("host1.unit-test.invalid", "host1.unit-test.*")); + assertEquals(true, buildParser().shExpMatch("host1.unit-test.invalid", "*.unit-test.invalid")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testWeekdayRange() { + assertEquals(true, buildParser().weekdayRange("MON", "SUN", "GMT")); + assertEquals(true, buildParser().weekdayRange("SUN", "SAT", null)); + assertEquals(false, buildParser().weekdayRange("MON", "WED", null)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testDateRange() { + assertEquals(true, buildParser().dateRange(15, "undefined", "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange(15, "DEC", "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange(15, "DEC", 1994, "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange(15, 17, "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange("OCT", "JAN", "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange(1994, 1994, "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().dateRange(1, "DEC", 1994, 1, "JAN", 1995, "GTM")); + + assertEquals(false, buildParser().dateRange(16, "DEC", 1994, 1, "JAN", 1995, "GTM")); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testTimeRange() { + assertEquals(true, buildParser().timeRange(12, "undefined", "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().timeRange(11, 13, "undefined", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().timeRange(11, 13, "gmt", "undefined", "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().timeRange(11, 30, 13, 30, "undefined", "undefined", "undefined")); + assertEquals(true, buildParser().timeRange(11, 30, 15, 13, 30, 15, "undefined")); + assertEquals(true, buildParser().timeRange(11, 30, 15, 13, 30, 15, "GMT")); + + assertEquals(false, buildParser().timeRange(12, 50, 00, 9, 30, 00, "GMT")); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/RhinoPacScriptParserTest.java b/src/test/java/com/btr/proxy/selector/pac/RhinoPacScriptParserTest.java new file mode 100644 index 0000000..f7d245a --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/RhinoPacScriptParserTest.java @@ -0,0 +1,114 @@ +package com.btr.proxy.selector.pac; + +import java.net.MalformedURLException; +import java.util.Calendar; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.util.ProxyException; + +/***************************************************************************** + * Tests for the Rhino PAC script parser. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class RhinoPacScriptParserTest { + + /************************************************************************* + * Set calendar for date and time base tests. + * Current date for all tests is: 15. December 1994 12:00.00 + * its a Thursday + ************************************************************************/ + @BeforeClass + public static void setup() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 1994); + cal.set(Calendar.MONTH, Calendar.DECEMBER); + cal.set(Calendar.DAY_OF_MONTH, 15); + cal.set(Calendar.HOUR_OF_DAY, 12); + cal.set(Calendar.MINUTE, 00); + cal.set(Calendar.SECOND, 00); + cal.set(Calendar.MILLISECOND, 00); + + RhinoPacScriptParser.setCurrentTime(cal); + } + + /************************************************************************* + * Cleanup after the tests. + ************************************************************************/ + @AfterClass + public static void teadDown() { + RhinoPacScriptParser.setCurrentTime(null); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptExecution() throws ProxyException, MalformedURLException { + PacScriptParser p = new RhinoPacScriptParser(new UrlPacScriptSource(toUrl("test1.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testCommentsInScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new RhinoPacScriptParser(new UrlPacScriptSource(toUrl("test2.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testScriptWeekDayScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new RhinoPacScriptParser(new UrlPacScriptSource(toUrl("testWeekDay.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testDateRangeScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new RhinoPacScriptParser(new UrlPacScriptSource(toUrl("testDateRange.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Test method + * @throws ProxyException on proxy detection error. + * @throws MalformedURLException on URL erros + ************************************************************************/ + @Test + public void testTimeRangeScript() throws ProxyException, MalformedURLException { + PacScriptParser p = new RhinoPacScriptParser(new UrlPacScriptSource(toUrl("testTimeRange.pac"))); + p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); + } + + /************************************************************************* + * Helper method to build the url to the given test file + * @param testFile the name of the test file. + * @return the URL. + * @throws MalformedURLException + ************************************************************************/ + + private String toUrl(String testFile) throws MalformedURLException { + return RhinoPacScriptParserTest.class.getResource("/" + TestUtil.TEST_DATA_FOLDER + "/pac/" + testFile).toString(); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/pac/UrlPacScriptSourceTest.java b/src/test/java/com/btr/proxy/selector/pac/UrlPacScriptSourceTest.java new file mode 100644 index 0000000..61c8cd0 --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/pac/UrlPacScriptSourceTest.java @@ -0,0 +1,34 @@ +package com.btr.proxy.selector.pac; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/***************************************************************************** + * Tests for the UrlPacScriptSource. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class UrlPacScriptSourceTest { + + /************************************************************************* + * Unit Test + ************************************************************************/ + @Test + public void testHttpCharsetParser() { + UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); + String charset = scriptSource.parseCharsetFromHeader("application/x-ns-proxy-autoconfig; charset=UTF-8"); + assertEquals("UTF-8", charset); + } + + /************************************************************************* + * Unit Test + ************************************************************************/ + @Test + public void testHttpCharsetParserDefault() { + UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); + String charset = scriptSource.parseCharsetFromHeader("application/octet-stream;"); + assertEquals("ISO-8859-1", charset); + } + +} + diff --git a/src/test/java/com/btr/proxy/selector/whitelist/NoProxyTest.java b/src/test/java/com/btr/proxy/selector/whitelist/NoProxyTest.java new file mode 100644 index 0000000..9d187ba --- /dev/null +++ b/src/test/java/com/btr/proxy/selector/whitelist/NoProxyTest.java @@ -0,0 +1,108 @@ +package com.btr.proxy.selector.whitelist; + +import static org.junit.Assert.*; + +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.selector.fixed.FixedProxySelector; + +/***************************************************************************** + * Some unit tests for the white list selector. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class NoProxyTest { + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testWhiteList() { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("no_prox.*", delegate); + + assertEquals(delegate.select(TestUtil.HTTP_TEST_URI).get(0), ps.select(TestUtil.HTTP_TEST_URI).get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testWhiteList2() { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid", delegate); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testWhiteList3() throws URISyntaxException { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid, localhost, 127.0.0.1", delegate); + + List<Proxy> result = ps.select(new URI("http://localhost:65/getDocument")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + + result = ps.select(new URI("http://127.0.0.1:65/getDocument")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testWhiteList4() { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid, ", delegate); + + List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testWhiteList5() throws URISyntaxException { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid localhost 127.0.0.1", delegate); + + List<Proxy> result = ps.select(new URI("http://localhost:65/getDocument")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + + result = ps.select(new URI("http://127.0.0.1:65/getDocument")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testIpRange() throws URISyntaxException { + ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); + ProxyBypassListSelector ps = new ProxyBypassListSelector("192.168.0.0/24", delegate); + + List<Proxy> result = ps.select(new URI("http://192.168.0.100:81/test.data")); + assertEquals(Proxy.NO_PROXY, result.get(0)); + + result = ps.select(new URI("http://192.168.1.100:81/test.data")); + assertEquals(delegate.select(TestUtil.HTTP_TEST_URI).get(0), result.get(0)); + } + +} + diff --git a/src/test/java/com/btr/proxy/util/PListParserTest.java b/src/test/java/com/btr/proxy/util/PListParserTest.java new file mode 100644 index 0000000..98ea57b --- /dev/null +++ b/src/test/java/com/btr/proxy/util/PListParserTest.java @@ -0,0 +1,101 @@ +package com.btr.proxy.util; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.util.PListParser.Dict; +import com.btr.proxy.util.PListParser.XmlParseException; + +/***************************************************************************** + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class PListParserTest { + + private static final String TEST_SETTINGS = TestUtil.class.getResource("/").getFile() + "data"+File.separator+"osx"+File.separator+"osx_all.plist"; + + private static Dict pList; + + /************************************************************************* + * Setup the dictionary from the test data file. + ************************************************************************/ + @BeforeClass + public static void setupClass() throws XmlParseException, + IOException { + pList = PListParser.load(new File(TEST_SETTINGS)); + } + + /** + * Test method for {@link com.btr.proxy.util.PListParser#load(java.io.File)}. + */ + @Test + public void testLoadFile() { + pList.dump(); + assertTrue(pList.size() > 0); + } + + /************************************************************************* + * Test method + ************************************************************************/ + + @Test + public void testStructure() { + String currentSet = (String) pList.get("CurrentSet"); + assertNotNull(currentSet); + Object networkServices = pList.get("NetworkServices"); + assertTrue(networkServices instanceof Dict); + } + + /************************************************************************* + * Test method + ************************************************************************/ + + @Test + public void testNavigate() { + Object result = pList.getAtPath("NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk"); + assertNotNull(result); + assertTrue(result instanceof Dict); + } + + /************************************************************************* + * Test method + ************************************************************************/ + + @Test + public void testNavigate2() { + Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk"); + assertNotNull(result); + assertTrue(result instanceof Dict); + } + + /************************************************************************* + * Test method + ************************************************************************/ + + @Test + public void testNavigate3() { + Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk/"); + assertNotNull(result); + assertTrue(result instanceof Dict); + } + + /************************************************************************* + * Test method + ************************************************************************/ + + @Test + public void testNavigate4() { + Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalkXXX/"); + assertNull(result); + } + + + +} + diff --git a/src/test/java/com/btr/proxy/util/ProxyUtilTest.java b/src/test/java/com/btr/proxy/util/ProxyUtilTest.java new file mode 100644 index 0000000..d8e10c5 --- /dev/null +++ b/src/test/java/com/btr/proxy/util/ProxyUtilTest.java @@ -0,0 +1,78 @@ +package com.btr.proxy.util; + +import static junit.framework.Assert.*; + +import java.net.Proxy; +import java.util.List; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.selector.fixed.FixedProxySelector; + + +/***************************************************************************** + * Unit tests for proxy util methods + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class ProxyUtilTest { + + /************************************************************************* + * Test parsing method. + ************************************************************************/ + + @Test + public void testParseProxySettings() { + FixedProxySelector rs = ProxyUtil.parseProxySettings("http://http_proxy.unit-test.invalid/"); + List<Proxy> psList = rs.select(TestUtil.HTTP_TEST_URI); + assertEquals("HTTP @ http_proxy.unit-test.invalid:80", psList.get(0).toString()); + } + + /************************************************************************* + * Test parsing method. + ************************************************************************/ + + @Test + public void testParseProxySettings2() { + FixedProxySelector rs = ProxyUtil.parseProxySettings("http://http_proxy.unit-test.invalid:8080/"); + List<Proxy> psList = rs.select(TestUtil.HTTP_TEST_URI); + assertEquals("HTTP @ http_proxy.unit-test.invalid:8080", psList.get(0).toString()); + } + + /************************************************************************* + * Test parsing method. + ************************************************************************/ + + @Test + public void testParseProxySettings3() { + FixedProxySelector rs = ProxyUtil.parseProxySettings("http_proxy.unit-test.invalid"); + List<Proxy> psList = rs.select(TestUtil.HTTP_TEST_URI); + assertEquals("HTTP @ http_proxy.unit-test.invalid:80", psList.get(0).toString()); + } + + /************************************************************************* + * Test parsing method. + ************************************************************************/ + + @Test + public void testParseProxySettings4() { + FixedProxySelector rs = ProxyUtil.parseProxySettings("http_proxy.unit-test.invalid:8080"); + List<Proxy> psList = rs.select(TestUtil.HTTP_TEST_URI); + assertEquals("HTTP @ http_proxy.unit-test.invalid:8080", psList.get(0).toString()); + } + + /************************************************************************* + * Test parsing method. + ************************************************************************/ + + @Test + public void testParseProxySettings5() { + FixedProxySelector rs = ProxyUtil.parseProxySettings("192.123.123.1:8080"); + List<Proxy> psList = rs.select(TestUtil.HTTP_TEST_URI); + assertEquals("HTTP @ 192.123.123.1:8080", psList.get(0).toString()); + } + + +} + diff --git a/src/test/java/com/btr/proxy/util/UriFilterTest.java b/src/test/java/com/btr/proxy/util/UriFilterTest.java new file mode 100644 index 0000000..f1750ad --- /dev/null +++ b/src/test/java/com/btr/proxy/util/UriFilterTest.java @@ -0,0 +1,122 @@ +package com.btr.proxy.util; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.junit.Test; + +import com.btr.proxy.TestUtil; +import com.btr.proxy.selector.whitelist.HostnameFilter; +import com.btr.proxy.selector.whitelist.IpRangeFilter; +import com.btr.proxy.selector.whitelist.HostnameFilter.Mode; + + +/***************************************************************************** + * Some unit tests for the UriFilter class. + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class UriFilterTest { + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testBeginsWithFilter1() { + UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); + + assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testBeginsWithFilter2() { + UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); + + assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testBeginsWithFilter3() throws URISyntaxException { + UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "192.168.0"); + + assertTrue(filter.accept(new URI("http://192.168.0.100:81/test.data"))); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testBeginsWithFilter4() throws URISyntaxException { + UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "192.168.0"); + + assertFalse(filter.accept(new URI("http://192.168.1.100:81/test.data"))); + } + + /************************************************************************* + * Test method + ************************************************************************/ + @Test + public void testBeginsWithFilter() { + UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); + + assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); + assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testEndsWithFilter() throws URISyntaxException { + UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".unit-test.invalid"); + + assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testEndsWithFilter2() throws URISyntaxException { + UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".unit-test.invalid"); + + assertFalse(filter.accept(new URI("http://test.no-host.invalid:81/test.data"))); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testEndsWithFilter3() throws URISyntaxException { + UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".100"); + + assertTrue(filter.accept(new URI("http://192.168.1.100:81/test.data"))); + } + + /************************************************************************* + * Test method + * @throws URISyntaxException on invalid URL syntax. + ************************************************************************/ + @Test + public void testIpRangeFilter() throws URISyntaxException { + UriFilter filter = new IpRangeFilter("192.168.0.0/24"); + + assertTrue(filter.accept(new URI("http://192.168.0.100:81/test.data"))); + assertFalse(filter.accept(new URI("http://192.168.1.100:81/test.data"))); + } + +} + diff --git a/src/test/resources/data/ff3_manual/.mozilla/firefox/9f1uyzzu.default/prefs.js b/src/test/resources/data/ff3_manual/.mozilla/firefox/9f1uyzzu.default/prefs.js new file mode 100644 index 0000000..568d96e --- /dev/null +++ b/src/test/resources/data/ff3_manual/.mozilla/firefox/9f1uyzzu.default/prefs.js @@ -0,0 +1,76 @@ +# Mozilla User Preferences + +/* Do not edit this file. + * + * If you make changes to this file while the application is running, + * the changes will be overwritten when the application exits. + * + * To make a manual change to preferences, you can visit the URL about:config + * For more information, see http://www.mozilla.org/unix/customizing.html#prefs + */ + +user_pref("accessibility.typeaheadfind.flashBar", 0); +user_pref("app.update.auto", false); +user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); +user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); +user_pref("browser.download.dir", "/home/rossi/Downloads"); +user_pref("browser.download.folderList", 2); +user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); +user_pref("browser.download.save_converter_index", 0); +user_pref("browser.feeds.showFirstRunUI", false); +user_pref("browser.history_expire_days.mirror", 180); +user_pref("browser.history_expire_days_min", 3); +user_pref("browser.migration.version", 1); +user_pref("browser.places.importBookmarksHTML", false); +user_pref("browser.places.importDefaults", false); +user_pref("browser.places.leftPaneFolderId", -1); +user_pref("browser.places.migratePostDataAnnotations", false); +user_pref("browser.places.smartBookmarksVersion", 1); +user_pref("browser.places.updateRecentTagsUri", false); +user_pref("browser.preferences.advanced.selectedTabIndex", 1); +user_pref("browser.rights.3.shown", true); +user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); +user_pref("browser.startup.page", 0); +user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); +user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); +user_pref("distribution.canonical.bookmarksProcessed", true); +user_pref("dom.disable_window_move_resize", true); +user_pref("dom.event.contextmenu.enabled", false); +user_pref("extensions.adblockplus.currentVersion", "1.0.2"); +user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); +user_pref("extensions.lastAppVersion", "3.0.10"); +user_pref("extensions.update.notifyUser", false); +user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); +user_pref("javascript.enabled", true); +user_pref("network.cookie.lifetimePolicy", 2); +user_pref("network.cookie.prefsMigrated", true); +user_pref("network.proxy.autoconfig_url", "http://www.xxx.de/"); +user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); +user_pref("network.proxy.ftp_port", 8092); +user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); +user_pref("network.proxy.gopher_port", 8093); +user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); +user_pref("network.proxy.http_port", 8090); +user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); +user_pref("network.proxy.socks_port", 8095); +user_pref("network.proxy.socks_version", 4); +user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); +user_pref("network.proxy.ssl_port", 8091); +user_pref("network.proxy.type", 1); +user_pref("noscript.badInstall", false); +user_pref("noscript.global", true); +user_pref("noscript.gtemp", ""); +user_pref("noscript.notify", false); +user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); +user_pref("noscript.policynames", ""); +user_pref("noscript.temp", ""); +user_pref("noscript.version", "1.9.2.8"); +user_pref("pref.advanced.javascript.disable_button.advanced", false); +user_pref("pref.downloads.disable_button.edit_actions", false); +user_pref("privacy.item.offlineApps", true); +user_pref("signon.rememberSignons", false); +user_pref("spellchecker.dictionary", "de_AT"); +user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); diff --git a/src/test/resources/data/ff3_none/.mozilla/firefox/9f1uyzzu.default/prefs.js b/src/test/resources/data/ff3_none/.mozilla/firefox/9f1uyzzu.default/prefs.js new file mode 100644 index 0000000..81a560c --- /dev/null +++ b/src/test/resources/data/ff3_none/.mozilla/firefox/9f1uyzzu.default/prefs.js @@ -0,0 +1,77 @@ +# Mozilla User Preferences + +/* Do not edit this file. + * + * If you make changes to this file while the application is running, + * the changes will be overwritten when the application exits. + * + * To make a manual change to preferences, you can visit the URL about:config + * For more information, see http://www.mozilla.org/unix/customizing.html#prefs + */ + +user_pref("accessibility.typeaheadfind.flashBar", 0); +user_pref("app.update.auto", false); +user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); +user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); +user_pref("browser.download.dir", "/home/rossi/Downloads"); +user_pref("browser.download.folderList", 2); +user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); +user_pref("browser.download.save_converter_index", 0); +user_pref("browser.feeds.showFirstRunUI", false); +user_pref("browser.history_expire_days.mirror", 180); +user_pref("browser.history_expire_days_min", 3); +user_pref("browser.migration.version", 1); +user_pref("browser.places.importBookmarksHTML", false); +user_pref("browser.places.importDefaults", false); +user_pref("browser.places.leftPaneFolderId", -1); +user_pref("browser.places.migratePostDataAnnotations", false); +user_pref("browser.places.smartBookmarksVersion", 1); +user_pref("browser.places.updateRecentTagsUri", false); +user_pref("browser.preferences.advanced.selectedTabIndex", 1); +user_pref("browser.rights.3.shown", true); +user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); +user_pref("browser.startup.page", 0); +user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); +user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); +user_pref("distribution.canonical.bookmarksProcessed", true); +user_pref("dom.disable_window_move_resize", true); +user_pref("dom.event.contextmenu.enabled", false); +user_pref("extensions.adblockplus.currentVersion", "1.0.2"); +user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); +user_pref("extensions.lastAppVersion", "3.0.10"); +user_pref("extensions.update.notifyUser", false); +user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); +user_pref("javascript.enabled", true); +user_pref("network.cookie.lifetimePolicy", 2); +user_pref("network.cookie.prefsMigrated", true); +user_pref("network.proxy.autoconfig_url", "http://www.xxx.de/"); +user_pref("network.proxy.ftp", "Test2"); +user_pref("network.proxy.ftp_port", 222); +user_pref("network.proxy.gopher", "Test3"); +user_pref("network.proxy.gopher_port", 333); +user_pref("network.proxy.http", "TEST"); +user_pref("network.proxy.http_port", 999); +user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1, test4454,"); +user_pref("network.proxy.socks", "Test4"); +user_pref("network.proxy.socks_port", 444); +user_pref("network.proxy.socks_version", 4); +user_pref("network.proxy.ssl", "Test1"); +user_pref("network.proxy.ssl_port", 111); +user_pref("network.proxy.type", 0); +user_pref("noscript.badInstall", false); +user_pref("noscript.global", true); +user_pref("noscript.gtemp", ""); +user_pref("noscript.notify", false); +user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); +user_pref("noscript.policynames", ""); +user_pref("noscript.temp", ""); +user_pref("noscript.version", "1.9.2.8"); +user_pref("pref.advanced.javascript.disable_button.advanced", false); +user_pref("pref.downloads.disable_button.edit_actions", false); +user_pref("privacy.item.offlineApps", true); +user_pref("signon.rememberSignons", false); +user_pref("spellchecker.dictionary", "de_AT"); +user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); diff --git a/src/test/resources/data/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default/prefs.js b/src/test/resources/data/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default/prefs.js new file mode 100644 index 0000000..906bdb5 --- /dev/null +++ b/src/test/resources/data/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default/prefs.js @@ -0,0 +1,76 @@ +# Mozilla User Preferences + +/* Do not edit this file. + * + * If you make changes to this file while the application is running, + * the changes will be overwritten when the application exits. + * + * To make a manual change to preferences, you can visit the URL about:config + * For more information, see http://www.mozilla.org/unix/customizing.html#prefs + */ + +user_pref("accessibility.typeaheadfind.flashBar", 0); +user_pref("app.update.auto", false); +user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); +user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); +user_pref("browser.download.dir", "/home/rossi/Downloads"); +user_pref("browser.download.folderList", 2); +user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); +user_pref("browser.download.save_converter_index", 0); +user_pref("browser.feeds.showFirstRunUI", false); +user_pref("browser.history_expire_days.mirror", 180); +user_pref("browser.history_expire_days_min", 3); +user_pref("browser.migration.version", 1); +user_pref("browser.places.importBookmarksHTML", false); +user_pref("browser.places.importDefaults", false); +user_pref("browser.places.leftPaneFolderId", -1); +user_pref("browser.places.migratePostDataAnnotations", false); +user_pref("browser.places.smartBookmarksVersion", 1); +user_pref("browser.places.updateRecentTagsUri", false); +user_pref("browser.preferences.advanced.selectedTabIndex", 1); +user_pref("browser.rights.3.shown", true); +user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); +user_pref("browser.startup.page", 0); +user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); +user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); +user_pref("distribution.canonical.bookmarksProcessed", true); +user_pref("dom.disable_window_move_resize", true); +user_pref("dom.event.contextmenu.enabled", false); +user_pref("extensions.adblockplus.currentVersion", "1.0.2"); +user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); +user_pref("extensions.lastAppVersion", "3.0.10"); +user_pref("extensions.update.notifyUser", false); +user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); +user_pref("javascript.enabled", true); +user_pref("network.cookie.lifetimePolicy", 2); +user_pref("network.cookie.prefsMigrated", true); +user_pref("network.proxy.autoconfig_url", "test/data/pac/test1.pac"); +user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); +user_pref("network.proxy.ftp_port", 8092); +user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); +user_pref("network.proxy.gopher_port", 8093); +user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); +user_pref("network.proxy.http_port", 8090); +user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); +user_pref("network.proxy.socks_port", 8095); +user_pref("network.proxy.socks_version", 4); +user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); +user_pref("network.proxy.ssl_port", 8091); +user_pref("network.proxy.type", 2); +user_pref("noscript.badInstall", false); +user_pref("noscript.global", true); +user_pref("noscript.gtemp", ""); +user_pref("noscript.notify", false); +user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); +user_pref("noscript.policynames", ""); +user_pref("noscript.temp", ""); +user_pref("noscript.version", "1.9.2.8"); +user_pref("pref.advanced.javascript.disable_button.advanced", false); +user_pref("pref.downloads.disable_button.edit_actions", false); +user_pref("privacy.item.offlineApps", true); +user_pref("signon.rememberSignons", false); +user_pref("spellchecker.dictionary", "de_AT"); +user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); diff --git a/src/test/resources/data/ff3_white_list/.mozilla/firefox/9f1uyzzu.default/prefs.js b/src/test/resources/data/ff3_white_list/.mozilla/firefox/9f1uyzzu.default/prefs.js new file mode 100644 index 0000000..7da855d --- /dev/null +++ b/src/test/resources/data/ff3_white_list/.mozilla/firefox/9f1uyzzu.default/prefs.js @@ -0,0 +1,77 @@ +# Mozilla User Preferences + +/* Do not edit this file. + * + * If you make changes to this file while the application is running, + * the changes will be overwritten when the application exits. + * + * To make a manual change to preferences, you can visit the URL about:config + * For more information, see http://www.mozilla.org/unix/customizing.html#prefs + */ + +user_pref("accessibility.typeaheadfind.flashBar", 0); +user_pref("app.update.auto", false); +user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); +user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); +user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); +user_pref("browser.download.dir", "/home/rossi/Downloads"); +user_pref("browser.download.folderList", 2); +user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); +user_pref("browser.download.save_converter_index", 0); +user_pref("browser.feeds.showFirstRunUI", false); +user_pref("browser.history_expire_days.mirror", 180); +user_pref("browser.history_expire_days_min", 3); +user_pref("browser.migration.version", 1); +user_pref("browser.places.importBookmarksHTML", false); +user_pref("browser.places.importDefaults", false); +user_pref("browser.places.leftPaneFolderId", -1); +user_pref("browser.places.migratePostDataAnnotations", false); +user_pref("browser.places.smartBookmarksVersion", 1); +user_pref("browser.places.updateRecentTagsUri", false); +user_pref("browser.preferences.advanced.selectedTabIndex", 1); +user_pref("browser.rights.3.shown", true); +user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); +user_pref("browser.startup.page", 0); +user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); +user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); +user_pref("distribution.canonical.bookmarksProcessed", true); +user_pref("dom.disable_window_move_resize", true); +user_pref("dom.event.contextmenu.enabled", false); +user_pref("extensions.adblockplus.currentVersion", "1.0.2"); +user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); +user_pref("extensions.lastAppVersion", "3.0.10"); +user_pref("extensions.update.notifyUser", false); +user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); +user_pref("javascript.enabled", true); +user_pref("network.cookie.lifetimePolicy", 2); +user_pref("network.cookie.prefsMigrated", true); +user_pref("network.proxy.autoconfig_url", "file://~/wpad/wpad.txt"); +user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); +user_pref("network.proxy.ftp_port", 8092); +user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); +user_pref("network.proxy.gopher_port", 8093); +user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); +user_pref("network.proxy.http_port", 8090); +user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1, no_proxy.unit-test.invalid"); +user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); +user_pref("network.proxy.socks_port", 8095); +user_pref("network.proxy.socks_version", 4); +user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); +user_pref("network.proxy.ssl_port", 8091); +user_pref("network.proxy.type", 1); +user_pref("noscript.badInstall", false); +user_pref("noscript.global", true); +user_pref("noscript.gtemp", ""); +user_pref("noscript.notify", false); +user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); +user_pref("noscript.policynames", ""); +user_pref("noscript.temp", ""); +user_pref("noscript.version", "1.9.2.8"); +user_pref("pref.advanced.javascript.disable_button.advanced", false); +user_pref("pref.downloads.disable_button.edit_actions", false); +user_pref("privacy.item.offlineApps", true); +user_pref("signon.rememberSignons", false); +user_pref("spellchecker.dictionary", "de_AT"); +user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); diff --git a/src/test/resources/data/gnome_manual/.gconf/system/http_proxy/%gconf.xml b/src/test/resources/data/gnome_manual/.gconf/system/http_proxy/%gconf.xml new file mode 100755 index 0000000..c3881c5 --- /dev/null +++ b/src/test/resources/data/gnome_manual/.gconf/system/http_proxy/%gconf.xml @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<gconf> + <entry name="port" mtime="1243184973" type="int" value="8090"> + </entry> + <entry name="use_same_proxy" mtime="1243184977" type="bool" value="false"> + </entry> + <entry name="ignore_hosts" mtime="1242841133" type="list" ltype="string"> + <li type="string"> + <stringvalue>localhost</stringvalue> + </li> + <li type="string"> + <stringvalue>127.0.0.0/8</stringvalue> + </li> + <li type="string"> + <stringvalue>*.local</stringvalue> + </li> + </entry> + <entry name="host" mtime="1243184967" type="string"> + <stringvalue>http_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="use_http_proxy" mtime="1243184951" type="bool" value="true"> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_manual/.gconf/system/proxy/%gconf.xml b/src/test/resources/data/gnome_manual/.gconf/system/proxy/%gconf.xml new file mode 100755 index 0000000..8818703 --- /dev/null +++ b/src/test/resources/data/gnome_manual/.gconf/system/proxy/%gconf.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<gconf> + <entry name="old_socks_port" mtime="1243184977" type="int" value="8889"> + </entry> + <entry name="old_socks_host" mtime="1243184977" type="string"> + <stringvalue>sodddddd</stringvalue> + </entry> + <entry name="old_ftp_port" mtime="1243184977" type="int" value="8099"> + </entry> + <entry name="old_ftp_host" mtime="1243184977" type="string"> + <stringvalue>ftpproxy</stringvalue> + </entry> + <entry name="old_secure_port" mtime="1243184977" type="int" value="8090"> + </entry> + <entry name="old_secure_host" mtime="1243184977" type="string"> + <stringvalue>sslproxy</stringvalue> + </entry> + <entry name="socks_port" mtime="1243185041" type="int" value="8093"> + </entry> + <entry name="socks_host" mtime="1243185029" type="string"> + <stringvalue>socks_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="ftp_port" mtime="1243185020" type="int" value="8092"> + </entry> + <entry name="ftp_host" mtime="1243185014" type="string"> + <stringvalue>ftp_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="secure_port" mtime="1243185005" type="int" value="8091"> + </entry> + <entry name="secure_host" mtime="1243184991" type="string"> + <stringvalue>https_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="mode" mtime="1243184951" type="string"> + <stringvalue>manual</stringvalue> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_none/.gconf/system/http_proxy/%gconf.xml b/src/test/resources/data/gnome_none/.gconf/system/http_proxy/%gconf.xml new file mode 100755 index 0000000..fadaef0 --- /dev/null +++ b/src/test/resources/data/gnome_none/.gconf/system/http_proxy/%gconf.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<gconf> + <entry name="use_same_proxy" mtime="1242844189" type="bool" value="true"> + </entry> + <entry name="ignore_hosts" mtime="1242841133" type="list" ltype="string"> + <li type="string"> + <stringvalue>localhost</stringvalue> + </li> + <li type="string"> + <stringvalue>127.0.0.0/8</stringvalue> + </li> + <li type="string"> + <stringvalue>*.local</stringvalue> + </li> + </entry> + <entry name="host" mtime="1242840330" type="string"> + <stringvalue>test.proxy.invalid</stringvalue> + </entry> + <entry name="use_http_proxy" mtime="1242848237" type="bool" value="false"> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_pac_script/.gconf/system/http_proxy/%gconf.xml b/src/test/resources/data/gnome_pac_script/.gconf/system/http_proxy/%gconf.xml new file mode 100755 index 0000000..527b0bd --- /dev/null +++ b/src/test/resources/data/gnome_pac_script/.gconf/system/http_proxy/%gconf.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<gconf> + <entry name="port" mtime="1243184973" type="int" value="8090"> + </entry> + <entry name="use_same_proxy" mtime="1243184977" type="bool" value="false"> + </entry> + <entry name="ignore_hosts" mtime="1243185198" type="list" ltype="string"> + <li type="string"> + <stringvalue>localhost</stringvalue> + </li> + <li type="string"> + <stringvalue>127.0.0.0/8</stringvalue> + </li> + <li type="string"> + <stringvalue>*.local</stringvalue> + </li> + <li type="string"> + <stringvalue>no_proxy.unit-test.invalid</stringvalue> + </li> + </entry> + <entry name="host" mtime="1243184967" type="string"> + <stringvalue>http_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="use_http_proxy" mtime="1243185310" type="bool" value="true"> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_pac_script/.gconf/system/proxy/%gconf.xml b/src/test/resources/data/gnome_pac_script/.gconf/system/proxy/%gconf.xml new file mode 100755 index 0000000..a5dde13 --- /dev/null +++ b/src/test/resources/data/gnome_pac_script/.gconf/system/proxy/%gconf.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<gconf> + <entry name="autoconfig_url" mtime="1243185338" type="string"> + <stringvalue>test/data/pac/test1.pac</stringvalue> + </entry> + <entry name="old_socks_port" mtime="1243184977" type="int" value="8889"> + </entry> + <entry name="old_socks_host" mtime="1243184977" type="string"> + <stringvalue>sodddddd</stringvalue> + </entry> + <entry name="old_ftp_port" mtime="1243184977" type="int" value="8099"> + </entry> + <entry name="old_ftp_host" mtime="1243184977" type="string"> + <stringvalue>ftpproxy</stringvalue> + </entry> + <entry name="old_secure_port" mtime="1243184977" type="int" value="8090"> + </entry> + <entry name="old_secure_host" mtime="1243184977" type="string"> + <stringvalue>sslproxy</stringvalue> + </entry> + <entry name="socks_port" mtime="1243185041" type="int" value="8093"> + </entry> + <entry name="socks_host" mtime="1243185029" type="string"> + <stringvalue>socks_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="ftp_port" mtime="1243185020" type="int" value="8092"> + </entry> + <entry name="ftp_host" mtime="1243185014" type="string"> + <stringvalue>ftp_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="secure_port" mtime="1243185005" type="int" value="8091"> + </entry> + <entry name="secure_host" mtime="1243184991" type="string"> + <stringvalue>https_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="mode" mtime="1243185310" type="string"> + <stringvalue>auto</stringvalue> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_white_list/.gconf/system/http_proxy/%gconf.xml b/src/test/resources/data/gnome_white_list/.gconf/system/http_proxy/%gconf.xml new file mode 100755 index 0000000..dd2d5fd --- /dev/null +++ b/src/test/resources/data/gnome_white_list/.gconf/system/http_proxy/%gconf.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<gconf> + <entry name="port" mtime="1243184973" type="int" value="8090"> + </entry> + <entry name="use_same_proxy" mtime="1243184977" type="bool" value="false"> + </entry> + <entry name="ignore_hosts" mtime="1243185198" type="list" ltype="string"> + <li type="string"> + <stringvalue>localhost</stringvalue> + </li> + <li type="string"> + <stringvalue>127.0.0.0/8</stringvalue> + </li> + <li type="string"> + <stringvalue>*.local</stringvalue> + </li> + <li type="string"> + <stringvalue>no_proxy.unit-test.invalid</stringvalue> + </li> + </entry> + <entry name="host" mtime="1243184967" type="string"> + <stringvalue>http_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="use_http_proxy" mtime="1243185171" type="bool" value="true"> + </entry> +</gconf> diff --git a/src/test/resources/data/gnome_white_list/.gconf/system/proxy/%gconf.xml b/src/test/resources/data/gnome_white_list/.gconf/system/proxy/%gconf.xml new file mode 100755 index 0000000..8818703 --- /dev/null +++ b/src/test/resources/data/gnome_white_list/.gconf/system/proxy/%gconf.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<gconf> + <entry name="old_socks_port" mtime="1243184977" type="int" value="8889"> + </entry> + <entry name="old_socks_host" mtime="1243184977" type="string"> + <stringvalue>sodddddd</stringvalue> + </entry> + <entry name="old_ftp_port" mtime="1243184977" type="int" value="8099"> + </entry> + <entry name="old_ftp_host" mtime="1243184977" type="string"> + <stringvalue>ftpproxy</stringvalue> + </entry> + <entry name="old_secure_port" mtime="1243184977" type="int" value="8090"> + </entry> + <entry name="old_secure_host" mtime="1243184977" type="string"> + <stringvalue>sslproxy</stringvalue> + </entry> + <entry name="socks_port" mtime="1243185041" type="int" value="8093"> + </entry> + <entry name="socks_host" mtime="1243185029" type="string"> + <stringvalue>socks_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="ftp_port" mtime="1243185020" type="int" value="8092"> + </entry> + <entry name="ftp_host" mtime="1243185014" type="string"> + <stringvalue>ftp_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="secure_port" mtime="1243185005" type="int" value="8091"> + </entry> + <entry name="secure_host" mtime="1243184991" type="string"> + <stringvalue>https_proxy.unit-test.invalid</stringvalue> + </entry> + <entry name="mode" mtime="1243184951" type="string"> + <stringvalue>manual</stringvalue> + </entry> +</gconf> diff --git a/src/test/resources/data/kde_env/.kde/share/config/kioslaverc b/src/test/resources/data/kde_env/.kde/share/config/kioslaverc new file mode 100644 index 0000000..03e3f0f --- /dev/null +++ b/src/test/resources/data/kde_env/.kde/share/config/kioslaverc @@ -0,0 +1,17 @@ +PersistentProxyConnection=false + +[$Version] +update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 + +[Notification Messages] +WarnOnLeaveSSLMode=false + +[Proxy Settings] +AuthMode=0 +NoProxyFor= +Proxy Config Script= +ProxyType=4 +ReversedException=false +ftpProxy=FTP_PROXY +httpProxy=HTTP_PROXY +httpsProxy=HTTPS_PROXY diff --git a/src/test/resources/data/kde_manual/.kde/share/config/kioslaverc b/src/test/resources/data/kde_manual/.kde/share/config/kioslaverc new file mode 100644 index 0000000..0d4f115 --- /dev/null +++ b/src/test/resources/data/kde_manual/.kde/share/config/kioslaverc @@ -0,0 +1,17 @@ +PersistentProxyConnection=false + +[$Version] +update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 + +[Notification Messages] +WarnOnLeaveSSLMode=false + +[Proxy Settings] +AuthMode=0 +NoProxyFor= +Proxy Config Script= +ProxyType=1 +ReversedException=false +ftpProxy=ftp://ftp_proxy.unit-test.invalid:8092 +httpProxy=http://http_proxy.unit-test.invalid:8090 +httpsProxy=https://https_proxy.unit-test.invalid:8091 diff --git a/src/test/resources/data/kde_none/.kde/share/config/kioslaverc b/src/test/resources/data/kde_none/.kde/share/config/kioslaverc new file mode 100644 index 0000000..413575f --- /dev/null +++ b/src/test/resources/data/kde_none/.kde/share/config/kioslaverc @@ -0,0 +1,17 @@ +PersistentProxyConnection=false + +[$Version] +update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 + +[Notification Messages] +WarnOnLeaveSSLMode=false + +[Proxy Settings] +AuthMode=0 +NoProxyFor= +Proxy Config Script= +ProxyType=0 +ReversedException=false +ftpProxy= +httpProxy= +httpsProxy= diff --git a/src/test/resources/data/kde_pac_script/.kde/share/config/kioslaverc b/src/test/resources/data/kde_pac_script/.kde/share/config/kioslaverc new file mode 100644 index 0000000..f3fa699 --- /dev/null +++ b/src/test/resources/data/kde_pac_script/.kde/share/config/kioslaverc @@ -0,0 +1,17 @@ +PersistentProxyConnection=false + +[$Version] +update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 + +[Notification Messages] +WarnOnLeaveSSLMode=false + +[Proxy Settings] +AuthMode=0 +NoProxyFor= +Proxy Config Script=test/data/pac/test1.pac +ProxyType=2 +ReversedException=false +ftpProxy= +httpProxy= +httpsProxy= diff --git a/src/test/resources/data/kde_white_list/.kde/share/config/kioslaverc b/src/test/resources/data/kde_white_list/.kde/share/config/kioslaverc new file mode 100644 index 0000000..80d0286 --- /dev/null +++ b/src/test/resources/data/kde_white_list/.kde/share/config/kioslaverc @@ -0,0 +1,17 @@ +PersistentProxyConnection=false + +[$Version] +update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 + +[Notification Messages] +WarnOnLeaveSSLMode=false + +[Proxy Settings] +AuthMode=0 +NoProxyFor=no_proxy.unit-test.invalid,.unit-test.invalid +Proxy Config Script= +ProxyType=1 +ReversedException=false +ftpProxy=ftp://ftp_proxy.unit-test.invalid:8092 +httpProxy=http://http_proxy.unit-test.invalid:8090 +httpsProxy=https://https_proxy.unit-test.invalid:8091 diff --git a/src/test/resources/data/osx/osx_all.plist b/src/test/resources/data/osx/osx_all.plist new file mode 100644 index 0000000..62dcab7 --- /dev/null +++ b/src/test/resources/data/osx/osx_all.plist @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CurrentSet</key> + <string>/Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651</string> + <key>NetworkServices</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>AppleTalk</key> + <dict/> + <key>DNS</key> + <dict/> + <key>IPv4</key> + <dict> + <key>ConfigMethod</key> + <string>DHCP</string> + </dict> + <key>IPv6</key> + <dict> + <key>ConfigMethod</key> + <string>Automatic</string> + </dict> + <key>Interface</key> + <dict> + <key>DeviceName</key> + <string>en0</string> + <key>Hardware</key> + <string>Ethernet</string> + <key>Type</key> + <string>Ethernet</string> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + <key>Proxies</key> + <dict> + <key>ExceptionsList</key> + <array> + <string>*.local</string> + <string>169.254/16</string> + </array> + <key>ExcludeSimpleHostnames</key> + <integer>1</integer> + <key>FTPEnable</key> + <integer>1</integer> + <key>FTPPassive</key> + <integer>1</integer> + <key>FTPPort</key> + <integer>8092</integer> + <key>FTPProxy</key> + <string>ftp_proxy.unit-test.invalid</string> + <key>GopherEnable</key> + <integer>1</integer> + <key>GopherPort</key> + <integer>8090</integer> + <key>GopherProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPEnable</key> + <integer>1</integer> + <key>HTTPPort</key> + <integer>8090</integer> + <key>HTTPProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPSEnable</key> + <integer>1</integer> + <key>HTTPSPort</key> + <integer>8091</integer> + <key>HTTPSProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>ProxyAutoConfigEnable</key> + <integer>1</integer> + <key>ProxyAutoConfigURLString</key> + <string>http://http_proxy.unit-test.invalid/wpad.pac</string> + <key>ProxyAutoDiscoveryEnable</key> + <integer>1</integer> + <key>RTSPEnable</key> + <integer>1</integer> + <key>RTSPPort</key> + <integer>8094</integer> + <key>RTSPProxy</key> + <string>rtsp_proxy.unit-test.invalid</string> + <key>SOCKSEnable</key> + <integer>1</integer> + <key>SOCKSPort</key> + <integer>8095</integer> + <key>SOCKSProxy</key> + <string>socks_proxy.unit-test.invalid</string> + </dict> + <key>SMB</key> + <dict/> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + </dict> + <key>Sets</key> + <dict> + <key>8458B09B-93EA-44C2-AD05-0B4E4A4D9651</key> + <dict> + <key>Network</key> + <dict> + <key>Global</key> + <dict> + <key>IPv4</key> + <dict> + <key>ServiceOrder</key> + <array> + <string>299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </array> + </dict> + </dict> + <key>Service</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>__LINK__</key> + <string>/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </dict> + </dict> + </dict> + <key>UserDefinedName</key> + <string>Automatic</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>Network</key> + <dict> + <key>HostNames</key> + <dict> + <key>LocalHostName</key> + <string>rossis-Mac-mini</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>ComputerName</key> + <string>rossi’s Mac mini</string> + <key>ComputerNameEncoding</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist> diff --git a/src/test/resources/data/osx/osx_manual.plist b/src/test/resources/data/osx/osx_manual.plist new file mode 100644 index 0000000..9c7b0b3 --- /dev/null +++ b/src/test/resources/data/osx/osx_manual.plist @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CurrentSet</key> + <string>/Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651</string> + <key>NetworkServices</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>AppleTalk</key> + <dict/> + <key>DNS</key> + <dict/> + <key>IPv4</key> + <dict> + <key>ConfigMethod</key> + <string>DHCP</string> + </dict> + <key>IPv6</key> + <dict> + <key>ConfigMethod</key> + <string>Automatic</string> + </dict> + <key>Interface</key> + <dict> + <key>DeviceName</key> + <string>en0</string> + <key>Hardware</key> + <string>Ethernet</string> + <key>Type</key> + <string>Ethernet</string> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + <key>Proxies</key> + <dict> + <key>ExceptionsList</key> + <array> + <string>*.local</string> + <string>no_proxy.unit-test.invalid</string> + </array> + <key>ExcludeSimpleHostnames</key> + <integer>1</integer> + <key>FTPEnable</key> + <integer>1</integer> + <key>FTPPassive</key> + <integer>1</integer> + <key>FTPPort</key> + <integer>8092</integer> + <key>FTPProxy</key> + <string>ftp_proxy.unit-test.invalid</string> + <key>GopherEnable</key> + <integer>1</integer> + <key>GopherPort</key> + <integer>8090</integer> + <key>GopherProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPEnable</key> + <integer>1</integer> + <key>HTTPPort</key> + <integer>8090</integer> + <key>HTTPProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPSEnable</key> + <integer>1</integer> + <key>HTTPSPort</key> + <integer>8091</integer> + <key>HTTPSProxy</key> + <string>https_proxy.unit-test.invalid</string> + <key>ProxyAutoConfigEnable</key> + <integer>0</integer> + <key>ProxyAutoConfigURLString</key> + <string>http://http_proxy.unit-test.invalid/wpad.pac</string> + <key>ProxyAutoDiscoveryEnable</key> + <integer>0</integer> + <key>RTSPEnable</key> + <integer>1</integer> + <key>RTSPPort</key> + <integer>8094</integer> + <key>RTSPProxy</key> + <string>rtsp_proxy.unit-test.invalid</string> + <key>SOCKSEnable</key> + <integer>1</integer> + <key>SOCKSPort</key> + <integer>8095</integer> + <key>SOCKSProxy</key> + <string>socks_proxy.unit-test.invalid</string> + </dict> + <key>SMB</key> + <dict/> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + </dict> + <key>Sets</key> + <dict> + <key>8458B09B-93EA-44C2-AD05-0B4E4A4D9651</key> + <dict> + <key>Network</key> + <dict> + <key>Global</key> + <dict> + <key>IPv4</key> + <dict> + <key>ServiceOrder</key> + <array> + <string>299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </array> + </dict> + </dict> + <key>Service</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>__LINK__</key> + <string>/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </dict> + </dict> + </dict> + <key>UserDefinedName</key> + <string>Automatic</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>Network</key> + <dict> + <key>HostNames</key> + <dict> + <key>LocalHostName</key> + <string>rossis-Mac-mini</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>ComputerName</key> + <string>rossi’s Mac mini</string> + <key>ComputerNameEncoding</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist> diff --git a/src/test/resources/data/osx/osx_pac.plist b/src/test/resources/data/osx/osx_pac.plist new file mode 100644 index 0000000..5a5b64d --- /dev/null +++ b/src/test/resources/data/osx/osx_pac.plist @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CurrentSet</key> + <string>/Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651</string> + <key>NetworkServices</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>AppleTalk</key> + <dict/> + <key>DNS</key> + <dict/> + <key>IPv4</key> + <dict> + <key>ConfigMethod</key> + <string>DHCP</string> + </dict> + <key>IPv6</key> + <dict> + <key>ConfigMethod</key> + <string>Automatic</string> + </dict> + <key>Interface</key> + <dict> + <key>DeviceName</key> + <string>en0</string> + <key>Hardware</key> + <string>Ethernet</string> + <key>Type</key> + <string>Ethernet</string> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + <key>Proxies</key> + <dict> + <key>ExceptionsList</key> + <array> + <string>*.local</string> + <string>169.254/16</string> + </array> + <key>ExcludeSimpleHostnames</key> + <integer>1</integer> + <key>FTPEnable</key> + <integer>1</integer> + <key>FTPPassive</key> + <integer>1</integer> + <key>FTPPort</key> + <integer>8092</integer> + <key>FTPProxy</key> + <string>ftp_proxy.unit-test.invalid</string> + <key>GopherEnable</key> + <integer>1</integer> + <key>GopherPort</key> + <integer>8090</integer> + <key>GopherProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPEnable</key> + <integer>1</integer> + <key>HTTPPort</key> + <integer>8090</integer> + <key>HTTPProxy</key> + <string>http_proxy.unit-test.invalid</string> + <key>HTTPSEnable</key> + <integer>1</integer> + <key>HTTPSPort</key> + <integer>8091</integer> + <key>HTTPSProxy</key> + <string>https_proxy.unit-test.invalid</string> + <key>ProxyAutoConfigEnable</key> + <integer>1</integer> + <key>ProxyAutoConfigURLString</key> + <string>http://http_proxy.unit-test.invalid/wpad.pac</string> + <key>ProxyAutoDiscoveryEnable</key> + <integer>0</integer> + <key>RTSPEnable</key> + <integer>1</integer> + <key>RTSPPort</key> + <integer>8094</integer> + <key>RTSPProxy</key> + <string>rtsp_proxy.unit-test.invalid</string> + <key>SOCKSEnable</key> + <integer>1</integer> + <key>SOCKSPort</key> + <integer>8095</integer> + <key>SOCKSProxy</key> + <string>socks_proxy.unit-test.invalid</string> + </dict> + <key>SMB</key> + <dict/> + <key>UserDefinedName</key> + <string>Ethernet</string> + </dict> + </dict> + <key>Sets</key> + <dict> + <key>8458B09B-93EA-44C2-AD05-0B4E4A4D9651</key> + <dict> + <key>Network</key> + <dict> + <key>Global</key> + <dict> + <key>IPv4</key> + <dict> + <key>ServiceOrder</key> + <array> + <string>299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </array> + </dict> + </dict> + <key>Service</key> + <dict> + <key>299B07C0-D0E0-4840-8486-9E77B9ED84DB</key> + <dict> + <key>__LINK__</key> + <string>/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB</string> + </dict> + </dict> + </dict> + <key>UserDefinedName</key> + <string>Automatic</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>Network</key> + <dict> + <key>HostNames</key> + <dict> + <key>LocalHostName</key> + <string>rossis-Mac-mini</string> + </dict> + </dict> + <key>System</key> + <dict> + <key>ComputerName</key> + <string>rossi’s Mac mini</string> + <key>ComputerNameEncoding</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist> diff --git a/src/test/resources/data/pac/test1.pac b/src/test/resources/data/pac/test1.pac new file mode 100644 index 0000000..4d8c2d6 --- /dev/null +++ b/src/test/resources/data/pac/test1.pac @@ -0,0 +1,4 @@ + +function FindProxyForURL(url, host) { + return "PROXY http_proxy.unit-test.invalid:8090"; +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/test2.pac b/src/test/resources/data/pac/test2.pac new file mode 100644 index 0000000..f8a846e --- /dev/null +++ b/src/test/resources/data/pac/test2.pac @@ -0,0 +1,10 @@ +// Test comments in scripts + +function FindProxyForURL(url, host) { + + /* + * This is a multiline comment + */ + + return "DIRECT"; // This returns always DIRECT +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/testDateRange.pac b/src/test/resources/data/pac/testDateRange.pac new file mode 100644 index 0000000..305b783 --- /dev/null +++ b/src/test/resources/data/pac/testDateRange.pac @@ -0,0 +1,11 @@ +// Test date range functions + +function FindProxyForURL(url, host) { + dateRange(1, 30); + dateRange("JUN", "JUL"); + dateRange(2008, 2009); + dateRange("JUN", "JUL", "GMT"); + dateRange(1, "JUN", 2008, 30, "JUL", 2099, "GMT"); + + return "DIRECT"; +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/testLocalIP.pac b/src/test/resources/data/pac/testLocalIP.pac new file mode 100644 index 0000000..ace486c --- /dev/null +++ b/src/test/resources/data/pac/testLocalIP.pac @@ -0,0 +1,4 @@ + +function FindProxyForURL(url, host) { + return "PROXY "+ myIpAddress()+":8080"; +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/testMultiProxy.pac b/src/test/resources/data/pac/testMultiProxy.pac new file mode 100644 index 0000000..9f5a2d1 --- /dev/null +++ b/src/test/resources/data/pac/testMultiProxy.pac @@ -0,0 +1,4 @@ +function FindProxyForURL(url, host) +{ + return "PROXY my-proxy.com:80 ; PROXY my-proxy2.com: 8080; "; +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/testTimeRange.pac b/src/test/resources/data/pac/testTimeRange.pac new file mode 100644 index 0000000..21138ac --- /dev/null +++ b/src/test/resources/data/pac/testTimeRange.pac @@ -0,0 +1,11 @@ +// Test weekday functions + +function FindProxyForURL(url, host) { + timeRange(12); + timeRange(11, 16); + timeRange(10, 30, 17, 30, "gmt"); + timeRange(10, 30, 00, 17, 30, 30, "GMT"); + timeRange(19, 9); + + return "DIRECT"; +}
\ No newline at end of file diff --git a/src/test/resources/data/pac/testWeekDay.pac b/src/test/resources/data/pac/testWeekDay.pac new file mode 100644 index 0000000..1b37cb1 --- /dev/null +++ b/src/test/resources/data/pac/testWeekDay.pac @@ -0,0 +1,10 @@ +// Test weekday functions + +function FindProxyForURL(url, host) { + weekdayRange("MON"); + weekdayRange("MON", "GMT"); + weekdayRange("FRI", "MON"); + weekdayRange("MON", "WED", "GMT"); + + return "DIRECT"; +}
\ No newline at end of file diff --git a/src/test/resources/data/win/proxy_util_amd64.dll b/src/test/resources/data/win/proxy_util_amd64.dll new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/test/resources/data/win/proxy_util_amd64.dll diff --git a/src/test/resources/data/win/proxy_util_ia64.dll b/src/test/resources/data/win/proxy_util_ia64.dll new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/test/resources/data/win/proxy_util_ia64.dll diff --git a/src/test/resources/data/win/proxy_util_w32.dll b/src/test/resources/data/win/proxy_util_w32.dll new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/test/resources/data/win/proxy_util_w32.dll diff --git a/src/test/resources/data/wpad/wpad.pac b/src/test/resources/data/wpad/wpad.pac new file mode 100644 index 0000000..4d8c2d6 --- /dev/null +++ b/src/test/resources/data/wpad/wpad.pac @@ -0,0 +1,4 @@ + +function FindProxyForURL(url, host) { + return "PROXY http_proxy.unit-test.invalid:8090"; +}
\ No newline at end of file |