aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-03-26 14:57:33 -0400
committerAdam Domurad <[email protected]>2013-03-26 14:57:33 -0400
commit58b4d6e3dc3a95cfbc6f369287aca04763522e48 (patch)
treec31e0146381288222138a667844893106772d87e /tests
parentc4f2dc4c8dc8c025c5d27c627717a164755986ae (diff)
Integration of unsigned applet confirmation dialogue.
Diffstat (limited to 'tests')
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java b/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java
new file mode 100644
index 0000000..be33f20
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java
@@ -0,0 +1,59 @@
+package net.sourceforge.jnlp.security.appletextendedsecurity;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class UnsignedAppletTrustConfirmationTest {
+
+ private List<String> toList(String ... parts) {
+ List<String> list = new ArrayList<String>();
+ for (String part : parts) {
+ list.add(part);
+ }
+ return list;
+ }
+
+ @Test
+ public void testToRelativePaths() throws Exception {
+ /* Absolute -> Relative */
+ assertEquals(toList("test.jar"),
+ UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example.com/test.jar"), "http://example.com/"));
+
+ /* Relative is unchanged */
+ assertEquals(toList("test.jar"),
+ UnsignedAppletTrustConfirmation.toRelativePaths(toList("test.jar"), "http://example.com/"));
+
+ /* Different root URL is unchanged */
+ assertEquals(toList("http://example2.com/test.jar"),
+ UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example2.com/test.jar"), "http://example.com/"));
+
+ /* Path with invalid URL characters is handled */
+ assertEquals(toList("test .jar"),
+ UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example.com/test .jar"), "http://example.com/"));
+ }
+
+ @Test
+ public void testNormalizeUrlAndStripParams() throws Exception {
+ /* Test that URL is normalized (encoded if not already encoded, leading whitespace trimmed, etc) */
+ assertEquals("http://example.com/%20test%20test",
+ UnsignedAppletTrustConfirmation.normalizeUrlAndStripParams(new URL("http://example.com/ test%20test ")).toString());
+ /* Test that a URL without '?' is left unchanged */
+ assertEquals("http://example.com/test",
+ UnsignedAppletTrustConfirmation.normalizeUrlAndStripParams(new URL("http://example.com/test")).toString());
+ /* Test that parts of a URL that come after '?' are stripped */
+ assertEquals("http://example.com/test",
+ UnsignedAppletTrustConfirmation.normalizeUrlAndStripParams(new URL("http://example.com/test?test=test")).toString());
+ /* Test that everything after the first '?' is stripped */
+ assertEquals("http://example.com/test",
+ UnsignedAppletTrustConfirmation.normalizeUrlAndStripParams(new URL("http://example.com/test?http://example.com/?test")).toString());
+
+ /* Test normalization + stripping */
+ assertEquals("http://example.com/%20test%20test",
+ UnsignedAppletTrustConfirmation.normalizeUrlAndStripParams(new URL("http://www.example.com/ test%20test ?test=test")).toString());
+ }
+} \ No newline at end of file