From 26d07f522ed3dc041d5ce1968d0d11d2c8f6dfa2 Mon Sep 17 00:00:00 2001 From: ReaJason Date: Wed, 4 Dec 2024 21:53:52 +0800 Subject: [PATCH] test: speedup integration test use sharedContainer refer: https://java.testcontainers.org/test_framework_integration/junit_5/#shared-containers --- .../tomcat/Tomcat10ContainerTest.java | 35 ++++ .../tomcat/Tomcat11ContainerTest.java | 35 ++++ .../tomcat/Tomcat6ContainerTest.java | 36 ++++ .../tomcat/Tomcat7ContainerTest.java | 37 ++++ .../tomcat/Tomcat8ContainerTest.java | 47 +++++ .../tomcat/Tomcat9ContainerTest.java | 35 ++++ .../tomcat/TomcatIntegrationTest.java | 166 +----------------- 7 files changed, 232 insertions(+), 159 deletions(-) create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat10ContainerTest.java create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat11ContainerTest.java create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat6ContainerTest.java create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat7ContainerTest.java create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat8ContainerTest.java create mode 100644 integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat9ContainerTest.java diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat10ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat10ContainerTest.java new file mode 100644 index 00000000..a3d98a08 --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat10ContainerTest.java @@ -0,0 +1,35 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat10ContainerTest extends TomcatIntegrationTest { + public static final String tomcat10ImageName = "tomcat:10.1-jre11"; + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat10ImageName) + .withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + @ParameterizedTest(name = tomcat10ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat10ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat11ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat11ContainerTest.java new file mode 100644 index 00000000..f22031b4 --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat11ContainerTest.java @@ -0,0 +1,35 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat11ContainerTest extends TomcatIntegrationTest { + public static final String tomcat11ImageName = "tomcat:11.0-jre17"; + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat11ImageName) + .withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + @ParameterizedTest(name = tomcat11ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat11ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat6ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat6ContainerTest.java new file mode 100644 index 00000000..d060dc72 --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat6ContainerTest.java @@ -0,0 +1,36 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat6ContainerTest extends TomcatIntegrationTest { + public static final String tomcat6ImageName = "reajason/tomcat:6-jdk6"; + + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat6ImageName) + .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + @ParameterizedTest(name = tomcat6ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat6ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP); + } +} \ No newline at end of file diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat7ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat7ContainerTest.java new file mode 100644 index 00000000..b3c52db4 --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat7ContainerTest.java @@ -0,0 +1,37 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat7ContainerTest extends TomcatIntegrationTest { + public static final String tomcat7ImageName = "tomcat:7.0.85-jre7"; + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat7ImageName) + .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + + @ParameterizedTest(name = tomcat7ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP); + } + + + @ParameterizedTest(name = tomcat7ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat8ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat8ContainerTest.java new file mode 100644 index 00000000..cca9422c --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat8ContainerTest.java @@ -0,0 +1,47 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat8ContainerTest extends TomcatIntegrationTest { + public static final String tomcat8ImageName = "tomcat:8-jre8"; + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat8ImageName) + .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + @ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JS") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testGodzillaJS(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine); + } + + @ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JS") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testCommandJS(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat9ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat9ContainerTest.java new file mode 100644 index 00000000..fd68a442 --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat9ContainerTest.java @@ -0,0 +1,35 @@ +package com.reajason.javaweb.integration.tomcat; + +import com.reajason.javaweb.memsell.packer.Packer; +import com.reajason.javaweb.memsell.tomcat.TomcatShell; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; + +/** + * @author ReaJason + * @since 2024/12/4 + */ +public class Tomcat9ContainerTest extends TomcatIntegrationTest { + public static final String tomcat9ImageName = "tomcat:9-jre9"; + @Container + public final static GenericContainer tomcat = new GenericContainer<>(tomcat9ImageName) + .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + @ParameterizedTest(name = tomcat9ImageName + "|{0}Godzilla|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testGodzillaJSP(String shellType) { + testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP); + } + + @ParameterizedTest(name = tomcat9ImageName + "|{0}Command|JSP") + @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) + void testCommandJSP(String shellType) { + testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/TomcatIntegrationTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/TomcatIntegrationTest.java index 3e8563cc..14bf52a8 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/TomcatIntegrationTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/tomcat/TomcatIntegrationTest.java @@ -28,17 +28,10 @@ import java.nio.file.Paths; @Testcontainers @Slf4j public class TomcatIntegrationTest { - - public static final MountableFile warFile = MountableFile.forHostPath(Paths.get("../vul-webapp/build/libs/vul-webapp.war").toAbsolutePath()); - public static final MountableFile warJakartaFile = MountableFile.forHostPath(Paths.get("../vul-webapp-jakarta/build/libs/vul-webapp-jakarta.war").toAbsolutePath()); - // https://hub.docker.com/_/tomcat/tags - public static final String tomcat6ImageName = "reajason/tomcat:6-jdk6"; - public static final String tomcat7ImageName = "tomcat:7.0.85-jre7"; - public static final String tomcat8ImageName = "tomcat:8-jre8"; - public static final String tomcat9ImageName = "tomcat:9-jre9"; - public static final String tomcat10ImageName = "tomcat:10.1-jre11"; - public static final String tomcat11ImageName = "tomcat:11.0-jre17"; + public static final MountableFile warJakartaFile = MountableFile.forHostPath(Paths.get("../vul-webapp-jakarta/build/libs/vul-webapp-jakarta.war").toAbsolutePath()); + public static final MountableFile warFile = MountableFile.forHostPath(Paths.get("../vul-webapp/build/libs/vul-webapp.war").toAbsolutePath()); + public String getUrl(GenericContainer tomcat) { String host = tomcat.getHost(); @@ -48,152 +41,7 @@ public class TomcatIntegrationTest { return url; } - @Nested - class Tomcat6 { - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat6ImageName) - .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - @ParameterizedTest(name = tomcat6ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat6ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP); - } - } - - @Nested - class Tomcat7 { - - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat7ImageName) - .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - - @ParameterizedTest(name = tomcat7ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP); - } - - - @ParameterizedTest(name = tomcat7ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP); - } - } - - @Nested - class Tomcat8 { - - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat8ImageName) - .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - @ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JS") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testGodzillaJS(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine); - } - - @ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JS") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testCommandJS(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine); - } - } - - @Nested - class Tomcat9 { - - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat9ImageName) - .withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - @ParameterizedTest(name = tomcat9ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat9ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP); - } - } - - @Nested - class Tomcat10 { - - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat10ImageName) - .withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - @ParameterizedTest(name = tomcat10ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat10ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP); - } - } - - @Nested - class Tomcat11 { - - @Container - public final GenericContainer tomcat = new GenericContainer<>(tomcat11ImageName) - .withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war") - .waitingFor(Wait.forHttp("/app")) - .withExposedPorts(8080); - - @ParameterizedTest(name = tomcat11ImageName + "|{0}Godzilla|JSP") - @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) - void testGodzillaJSP(String shellType) { - testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP); - } - - @ParameterizedTest(name = tomcat11ImageName + "|{0}Command|JSP") - @ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE}) - void testCommandJSP(String shellType) { - testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP); - } - } - - private void testGodzillaAssertOk(String url, String shellType, int targetJdkVersion, Packer.INSTANCE packer) { + public void testGodzillaAssertOk(String url, String shellType, int targetJdkVersion, Packer.INSTANCE packer) { String pass = "pass" + shellType; String key = "key" + shellType; String headerValue = "Godzilla" + shellType; @@ -206,7 +54,7 @@ public class TomcatIntegrationTest { String shellUrl = url + "/"; if (Packer.INSTANCE.JSP.equals(packer)) { String uploadEntry = url + "/upload"; - String filename = shellType + ".jsp"; + String filename = shellType + "Godzilla.jsp"; shellUrl = url + "/" + filename; VulTool.uploadJspFileToServer(uploadEntry, filename, content); VulTool.urlIsOk(shellUrl); @@ -217,7 +65,7 @@ public class TomcatIntegrationTest { GodzillaShellTool.testIsOk(shellUrl, shellConfig); } - private void testCommandAssertOk(String url, String shellType, int targetJdkVersion, Packer.INSTANCE packer) { + public void testCommandAssertOk(String url, String shellType, int targetJdkVersion, Packer.INSTANCE packer) { String paramName = "Command" + shellType; CommandShellConfig config = CommandShellConfig.builder().paramName(paramName).build(); String content = CommandShellTool.generate(Server.TOMCAT, config, shellType, targetJdkVersion, packer); @@ -225,7 +73,7 @@ public class TomcatIntegrationTest { String shellUrl = url + "/"; if (Packer.INSTANCE.JSP.equals(packer)) { String uploadEntry = url + "/upload"; - String filename = shellType + ".jsp"; + String filename = shellType + "Command.jsp"; shellUrl = url + "/" + filename; VulTool.uploadJspFileToServer(uploadEntry, filename, content); VulTool.urlIsOk(shellUrl);