diff options
author | Andrew Azores <[email protected]> | 2013-09-26 10:25:33 -0400 |
---|---|---|
committer | Andrew Azores <[email protected]> | 2013-09-26 10:25:33 -0400 |
commit | c824b24b3c7656e6230b6c1d398a927b1225f0c2 (patch) | |
tree | dc6594b350e9583b1bda9d1be35259e03f9ce9fa /tests/netx/unit/sun/applet/PluginAppletViewerTest.java | |
parent | 22c0eae35d290f25bfd69b937c09c10b6f961db7 (diff) |
Fix for PR1204, handling of query strings and absolute paths.
Absolute paths in resource URLs are correctly handled when appended to host
URLs and URL query strings are not removed.
* netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java:
(getVersionedUrlUsingQuery) renamed to getVersionedUrl, refactored
construction of URL
* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:
(requestPluginProxyInfo) extracted proxy URI logic.
(processProxyUri) new method for finding proxy URIs, handles absolute
resource paths correctly
* tests/netx/unit/net/sourceforge/jnlp/cache/ResourceUrlCreatorTest.java:
added tests for ResourceUrlCreator#getVersionedUrl
* tests/netx/unit/sun/applet/PluginAppletViewerTest.java: added tests for
PluginAppletViewer.processProxyUri
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/resources/AbsolutePathsAndQueryStrings.html:
new reproducer checks that absolute paths and query strings in resource
URLs are properly handled, and caching still works
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/resources/AbsolutePathsAndQueryStrings.jnlp:
same
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/testcases/AbsolutePathsAndQueryStrings.java:
same
Diffstat (limited to 'tests/netx/unit/sun/applet/PluginAppletViewerTest.java')
-rw-r--r-- | tests/netx/unit/sun/applet/PluginAppletViewerTest.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/netx/unit/sun/applet/PluginAppletViewerTest.java b/tests/netx/unit/sun/applet/PluginAppletViewerTest.java index cecedfc..69e5cb1 100644 --- a/tests/netx/unit/sun/applet/PluginAppletViewerTest.java +++ b/tests/netx/unit/sun/applet/PluginAppletViewerTest.java @@ -42,8 +42,11 @@ import static org.junit.Assert.assertEquals; import static sun.applet.PluginPipeMockUtil.getPluginStoreId; import static sun.applet.PluginPipeMockUtil.getPluginStoreObject; +import java.net.URI; import java.util.concurrent.Callable; +import junit.framework.Assert; + import net.sourceforge.jnlp.AsyncCall; import net.sourceforge.jnlp.ServerAccess; @@ -156,6 +159,43 @@ public class PluginAppletViewerTest { assertEquals(expectedReturn, call.join()); } + @Test + public void testConvertUriSchemeForProxyQuery() throws Exception { + URI[] testUris = { + new URI("http", "foo.com", "/bar", null), + new URI("https", "foo.com", "/bar", null), + new URI("ftp", "foo.com", "/app/res/pub/channel.jar?i=1234", null), + new URI("socket", "foo.co.uk", "/bar/pub/ale.jar", null), + }; + + for (URI uri : testUris) { + URI result = new URI(PluginAppletViewer.convertUriSchemeForProxyQuery(uri)); + assertQueryForBrowserProxyUsesHttpFallback(uri, result); + String hierarchicalPath = result.getAuthority() + result.getPath(); + assertQueryForBrowserProxyContainsNoDoubleSlashes(hierarchicalPath); + assertQueryForBrowserProxyDoesNotChangeQuery(uri, result); + } + } + + // Test that only HTTP is used as fallback scheme if a protocol other than HTTP(S) or FTP is specified + public void assertQueryForBrowserProxyUsesHttpFallback(URI expected, URI result) { + if (expected.getScheme().equals("ftp") || expected.getScheme().startsWith("http")) { + Assert.assertEquals(expected.getScheme(), result.getScheme()); + } else { + Assert.assertEquals(result.getScheme(), "http"); + } + } + + // Test that absolute resource paths do not result in double-slashes within the URI + public void assertQueryForBrowserProxyContainsNoDoubleSlashes(String uri) { + Assert.assertFalse(uri.contains("//")); + } + + // Test that the query string of the URI is not changed + public void assertQueryForBrowserProxyDoesNotChangeQuery(URI expected, URI result) { + Assert.assertEquals(expected.getQuery(), result.getQuery()); + } + /************************************************************************** * Test utilities * **************************************************************************/ @@ -238,4 +278,4 @@ public class PluginAppletViewerTest { int expectedLength = 6; return parseAndCheckJSMessage(message, expectedLength, "ToString", contextObjectID); } -}
\ No newline at end of file +} |