mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-23 15:31:53 +08:00
test: speedup integration test use sharedContainer
refer: https://java.testcontainers.org/test_framework_integration/junit_5/#shared-containers
This commit is contained in:
+35
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-159
@@ -28,17 +28,10 @@ import java.nio.file.Paths;
|
|||||||
@Testcontainers
|
@Testcontainers
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TomcatIntegrationTest {
|
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
|
// https://hub.docker.com/_/tomcat/tags
|
||||||
public static final String tomcat6ImageName = "reajason/tomcat:6-jdk6";
|
public static final MountableFile warJakartaFile = MountableFile.forHostPath(Paths.get("../vul-webapp-jakarta/build/libs/vul-webapp-jakarta.war").toAbsolutePath());
|
||||||
public static final String tomcat7ImageName = "tomcat:7.0.85-jre7";
|
public static final MountableFile warFile = MountableFile.forHostPath(Paths.get("../vul-webapp/build/libs/vul-webapp.war").toAbsolutePath());
|
||||||
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 String getUrl(GenericContainer<?> tomcat) {
|
public String getUrl(GenericContainer<?> tomcat) {
|
||||||
String host = tomcat.getHost();
|
String host = tomcat.getHost();
|
||||||
@@ -48,152 +41,7 @@ public class TomcatIntegrationTest {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
public void testGodzillaAssertOk(String url, String shellType, int targetJdkVersion, Packer.INSTANCE packer) {
|
||||||
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) {
|
|
||||||
String pass = "pass" + shellType;
|
String pass = "pass" + shellType;
|
||||||
String key = "key" + shellType;
|
String key = "key" + shellType;
|
||||||
String headerValue = "Godzilla" + shellType;
|
String headerValue = "Godzilla" + shellType;
|
||||||
@@ -206,7 +54,7 @@ public class TomcatIntegrationTest {
|
|||||||
String shellUrl = url + "/";
|
String shellUrl = url + "/";
|
||||||
if (Packer.INSTANCE.JSP.equals(packer)) {
|
if (Packer.INSTANCE.JSP.equals(packer)) {
|
||||||
String uploadEntry = url + "/upload";
|
String uploadEntry = url + "/upload";
|
||||||
String filename = shellType + ".jsp";
|
String filename = shellType + "Godzilla.jsp";
|
||||||
shellUrl = url + "/" + filename;
|
shellUrl = url + "/" + filename;
|
||||||
VulTool.uploadJspFileToServer(uploadEntry, filename, content);
|
VulTool.uploadJspFileToServer(uploadEntry, filename, content);
|
||||||
VulTool.urlIsOk(shellUrl);
|
VulTool.urlIsOk(shellUrl);
|
||||||
@@ -217,7 +65,7 @@ public class TomcatIntegrationTest {
|
|||||||
GodzillaShellTool.testIsOk(shellUrl, shellConfig);
|
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;
|
String paramName = "Command" + shellType;
|
||||||
CommandShellConfig config = CommandShellConfig.builder().paramName(paramName).build();
|
CommandShellConfig config = CommandShellConfig.builder().paramName(paramName).build();
|
||||||
String content = CommandShellTool.generate(Server.TOMCAT, config, shellType, targetJdkVersion, packer);
|
String content = CommandShellTool.generate(Server.TOMCAT, config, shellType, targetJdkVersion, packer);
|
||||||
@@ -225,7 +73,7 @@ public class TomcatIntegrationTest {
|
|||||||
String shellUrl = url + "/";
|
String shellUrl = url + "/";
|
||||||
if (Packer.INSTANCE.JSP.equals(packer)) {
|
if (Packer.INSTANCE.JSP.equals(packer)) {
|
||||||
String uploadEntry = url + "/upload";
|
String uploadEntry = url + "/upload";
|
||||||
String filename = shellType + ".jsp";
|
String filename = shellType + "Command.jsp";
|
||||||
shellUrl = url + "/" + filename;
|
shellUrl = url + "/" + filename;
|
||||||
VulTool.uploadJspFileToServer(uploadEntry, filename, content);
|
VulTool.uploadJspFileToServer(uploadEntry, filename, content);
|
||||||
VulTool.urlIsOk(shellUrl);
|
VulTool.urlIsOk(shellUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user