test: test order list is important

This commit is contained in:
ReaJason
2025-02-25 01:41:28 +08:00
parent bc103376d3
commit d004ed1dbc
55 changed files with 244 additions and 273 deletions
@@ -7,10 +7,7 @@ import com.reajason.javaweb.memshell.ShellType;
import org.junit.jupiter.params.provider.Arguments;
import org.testcontainers.shaded.org.apache.commons.lang3.tuple.Triple;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -22,20 +19,25 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
*/
public class TestCasesProvider {
public static Stream<Arguments> getTestCases(String imageName, Server server, Set<String> testShellTypes, Set<Packers> testPackers, Set<Triple<String, ShellTool, Packers>> unSupportedCases) {
public static Stream<Arguments> getTestCases(String imageName, Server server, List<String> testShellTypes, List<Packers> testPackers, List<Triple<String, ShellTool, Packers>> unSupportedCases) {
return getTestCases(imageName, server, testShellTypes, testPackers, unSupportedCases, null);
}
public static Stream<Arguments> getTestCases(String imageName, Server server, Set<String> testShellTypes, Set<Packers> testPackers, Set<Triple<String, ShellTool, Packers>> unSupportedCases, Set<ShellTool> unSupportedShellTools) {
Set<ShellTool> supportedShellTools = new HashSet<>(server.getShell().getSupportedShellTools());
public static Stream<Arguments> getTestCases(String imageName, Server server, List<String> testShellTypes, List<Packers> testPackers, List<Triple<String, ShellTool, Packers>> unSupportedCases, List<ShellTool> unSupportedShellTools) {
Set<ShellTool> supportedShellTools = new TreeSet<>(server.getShell().getSupportedShellTools());
if (unSupportedShellTools != null) {
supportedShellTools.removeAll(unSupportedShellTools);
unSupportedShellTools.forEach(supportedShellTools::remove);
}
Set<String> unSupported = unSupportedCases == null ? Collections.emptySet() : unSupportedCases.stream().map(i -> i.getLeft() + i.getMiddle() + i.getRight()).collect(Collectors.toSet());
return supportedShellTools.stream()
.flatMap(supportedShellTool -> {
Set<String> toolSupportedShellTypes = new HashSet<>(server.getShell().getSupportedShellTypes(supportedShellTool));
toolSupportedShellTypes.retainAll(testShellTypes);
List<String> toolSupportedShellTypes = new ArrayList<>();
Set<String> supportedShellTypes = server.getShell().getSupportedShellTypes(supportedShellTool);
for (String testShellType : testShellTypes) {
if (supportedShellTypes.contains(testShellType)) {
toolSupportedShellTypes.add(testShellType);
}
}
return toolSupportedShellTypes.stream().flatMap(supportedShellType -> {
if (supportedShellType.startsWith(ShellType.AGENT)) {
if (!unSupported.contains(supportedShellType + supportedShellTool + Packers.AgentJar)) {
@@ -56,7 +58,7 @@ public class TestCasesProvider {
});
}
public static Stream<Arguments> getTestCases(String imageName, Server server, Set<String> testShellTypes, Set<Packers> testPackers) {
public static Stream<Arguments> getTestCases(String imageName, Server server, List<String> testShellTypes, List<Packers> testPackers) {
return getTestCases(imageName, server, testShellTypes, testPackers, null);
}
}