Skip to content

Commit

Permalink
Tests: fix permission tests, finer-grained exclusions via 'SecMan' tag
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Jun 19, 2024
1 parent 13ee7e5 commit e816aa8
Show file tree
Hide file tree
Showing 80 changed files with 315 additions and 244 deletions.
9 changes: 3 additions & 6 deletions echosvg-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ publishing.publications.maven(MavenPublication).pom {
}

test {
useJUnitPlatform()

exclude 'io/sf/carte/echosvg/apps/rasterizer/MainTest.class'
exclude 'io/sf/carte/echosvg/bridge/*LoadTest.class'
exclude 'io/sf/carte/echosvg/bridge/*PermissionsTest.class'
exclude 'io/sf/carte/echosvg/script/rhino/RhinoTest.class'
useJUnitPlatform() {
excludeTags 'SecMan'
}

// Exclude tests via gradlew test -PexcludeTests="SamplesRenderingTest.testVerticalText,..."
if (project.hasProperty('excludeTests')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.StringTokenizer;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.sf.carte.echosvg.test.TestLocations;
Expand All @@ -48,6 +49,7 @@
* @author For later modifications, see Git history.
* @version $Id$
*/
@Tag("SecMan")
@SuppressWarnings({ "deprecation", "removal" })
public class MainTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.PrivilegedExceptionAction;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -32,6 +33,7 @@
* @author For later modifications, see Git history.
* @version $Id$
*/
@Tag("SecMan")
@SuppressWarnings({ "deprecation", "removal" })
public class EcmaLoadTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.PrivilegedExceptionAction;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.sf.carte.echosvg.test.svg.SVGOnLoadExceptionTest;
Expand All @@ -34,6 +35,7 @@
* @author For later modifications, see Git history.
* @version $Id$
*/
@Tag("SecMan")
@SuppressWarnings({ "deprecation", "removal" })
public class EcmaNoLoadTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.PrivilegedExceptionAction;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -32,6 +33,7 @@
* @author For later modifications, see Git history.
* @version $Id$
*/
@Tag("SecMan")
@SuppressWarnings({ "deprecation", "removal" })
public class JarLoadTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package io.sf.carte.echosvg.bridge;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.sf.carte.echosvg.test.svg.SVGOnLoadExceptionTest;
Expand All @@ -29,6 +30,7 @@
* @author For later modifications, see Git history.
* @version $Id$
*/
@Tag("SecMan")
public class JarNoLoadTest {

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.sf.carte.echosvg.test.svg.SVGOnLoadExceptionTest;
Expand Down Expand Up @@ -60,6 +61,7 @@ public void testNoEmbed() throws Exception {
}

@Test
@Tag("SecMan")
public void testPermissionsDeniedScript() throws Exception {
runTest("application/java-archive", "bridge/ecmaCheckPermissionsDeniedScript", "NONE", true, false,
"java.lang.SecurityException");
Expand Down Expand Up @@ -98,13 +100,14 @@ public void testBridgeExceptionIllegalClipPathUri() throws Exception {
}

/*
* This should generate only a warning, according to Batik (bridge/unitTesting.xml)
* This should generate only a warning, see also bridge/unitTesting.xml
*/
// FIXME: No exception should be thrown here
@Disabled
@Test
public void testBridgeExceptionInvalidCSS() throws Exception {
runTest("application/java-archive", "bridge/error/css-invalid", "ANY", false, false,
null);
runTest("text/ecmascript", "bridge/error/css-invalid", "ANY", false, false,
"org.w3c.dom.DOMException");
}

@Test
Expand Down Expand Up @@ -205,14 +208,14 @@ public void testBridgeExceptionInvalidGBStdDevY() throws Exception {

@Test
public void testBridgeExceptionFeImageBadURL() throws Exception {
runTest("application/java-archive", "bridge/error/feImage-badurl", "ANY", false, false,
runTest("text/ecmascript", "bridge/error/feImage-badurl", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
}

@Test
public void testBridgeExceptionInvalidMergeNode() throws Exception {
runTest("application/java-archive", "bridge/error/feMerge-feMergeNode-invalid", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/feMerge-feMergeNode-invalid", "ANY", false, false,
null);
}

@Test
Expand Down Expand Up @@ -247,14 +250,14 @@ public void testBridgeExceptionInvalidTurbulenceType() throws Exception {

@Test
public void testBridgeExceptionEmptyFilter() throws Exception {
runTest("application/java-archive", "bridge/error/filter-empty", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/filter-empty", "ANY", false, false,
null);
}

@Test
public void testBridgeExceptionInvalidFilterPrimitive() throws Exception {
runTest("application/java-archive", "bridge/error/filter-filterPrimitive-invalid", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/filter-filterPrimitive-invalid", "ANY", false, false,
null);
}

@Test
Expand Down Expand Up @@ -282,11 +285,12 @@ public void testBridgeExceptionIllegalFilterUri() throws Exception {
}

// This should display a broken-image image, no exception
// FIXME: No exception should be thrown here
@Disabled
@Test
public void testBridgeExceptionImageBadURL() throws Exception {
runTest("application/java-archive", "bridge/error/image-badurl", "ANY", false, false,
null);
runTest("text/ecmascript", "bridge/error/image-badurl", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
}

@Test
Expand All @@ -313,13 +317,10 @@ public void testBridgeExceptionImageNegativeWidth() throws Exception {
"io.sf.carte.echosvg.bridge.BridgeException");
}

/*
* A comment in Batik (bridge/unitTesting.xml) claims that this gives no error there.
*/
@Test
public void testBridgeExceptionEmptyLinearGradient() throws Exception {
runTest("application/java-archive", "bridge/error/linearGradient-empty", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/linearGradient-empty", "ANY", false, false,
null);
}

@Test
Expand All @@ -330,8 +331,8 @@ public void testBridgeExceptionInvalidGradientUnits() throws Exception {

@Test
public void testBridgeExceptionMissingGradientOffset() throws Exception {
runTest("application/java-archive", "bridge/error/linearGradient-missing-offset", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/linearGradient-missing-offset", "ANY", false, false,
null);
}

@Test
Expand All @@ -348,8 +349,8 @@ public void testBridgeExceptionInvalidGradientUri() throws Exception {

@Test
public void testBridgeExceptionEmptyMask() throws Exception {
runTest("application/java-archive", "bridge/error/mask-empty", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/mask-empty", "ANY", false, false,
null);
}

@Test
Expand Down Expand Up @@ -378,8 +379,8 @@ public void testBridgeExceptionInvalidPathD() throws Exception {

@Test
public void testBridgeExceptionEmptyPattern() throws Exception {
runTest("application/java-archive", "bridge/error/pattern-empty", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/pattern-empty", "ANY", false, false,
null);
}

@Test
Expand Down Expand Up @@ -407,10 +408,9 @@ public void testBridgeExceptionInvalidPolylinePoints() throws Exception {
}

// This is not an error according to 13.2.4
@Disabled
@Test
public void testBridgeExceptionEmptyRadialGradient() throws Exception {
runTest("application/java-archive", "bridge/error/radialGradient-empty", "ANY", false, false,
runTest("text/ecmascript", "bridge/error/radialGradient-empty", "ANY", false, false,
null);
}

Expand All @@ -422,8 +422,8 @@ public void testBridgeExceptionInvalidRadialGradientUnits() throws Exception {

@Test
public void testBridgeExceptionMissingRadialGradientOffset() throws Exception {
runTest("application/java-archive", "bridge/error/radialGradient-missing-offset", "ANY", false, false,
"io.sf.carte.echosvg.bridge.BridgeException");
runTest("text/ecmascript", "bridge/error/radialGradient-missing-offset", "ANY", false, false,
null);
}

@Test
Expand All @@ -433,10 +433,9 @@ public void testBridgeExceptionRadialGradientRNegative() throws Exception {
}

// This is not an error according to 13.2.3
@Disabled
@Test
public void testBridgeExceptionRadialGradientRZero() throws Exception {
runTest("application/java-archive", "bridge/error/radialGradient-r-zero", "ANY", false, false,
runTest("text/ecmascript", "bridge/error/radialGradient-r-zero", "ANY", false, false,
null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.PrivilegedExceptionAction;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -55,6 +56,7 @@ public Void run() throws Exception {
* function. Note that scripts loaded with the 'Script()' object are disallowed
* completely in secure mode.
*/
@Tag("SecMan")
@Test
public void testECMAPermissionsDenied() throws Exception {
String scripts = "text/ecmascript";
Expand Down Expand Up @@ -82,6 +84,7 @@ public void testECMAPermissionsGranted() throws Exception {
runTest(scripts, scriptSource, scriptOrigin, secure);
}

@Tag("SecMan")
@Test
public void testJarPermissionsDenied() throws Exception {
String scripts = "application/java-archive";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package io.sf.carte.echosvg.script.rhino;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -35,6 +36,7 @@ public static void setUpBeforeAll() {
}

@Test
@Tag("SecMan")
public void testECMAPermissionsDenied() throws Exception {
runTest("script/rhino/eval", true);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e816aa8

Please sign in to comment.