8000 Migration Tool - Updating MigrateTest. by lhanusov · Pull Request #47509 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MigrateTest {
Path rootPath = getRootPath();
Path oldTestsuitePath = rootPath.resolve("testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite").toAbsolutePath();
Path newBaseTestPath = rootPath.resolve("tests/base/src/test/java/org/keycloak/tests").toAbsolutePath();
Path newWebAuthnTestPath = rootPath.resolve("tests/webauthn/src/test/java/org/keycloak/tests").toAbsolutePath();

public static void main(String[] args) throws Exception {
MigrateTest migrateTest = new MigrateTest();
Expand All @@ -54,11 +55,12 @@ public void migrate(String test) throws Exception {
testPath = getOldTestsuitePath(testPath);
}

Path destinationPath = getDestination(testPath);
boolean hasWebAuthnPath = testPath.startsWith(oldTestsuitePath + "/webauthn");
Path destinationPath = getDestination(testPath, hasWebAuthnPath);

System.out.println("Root: " + rootPath);
System.out.println("Old tests: " + oldTestsuitePath);
System.out.println("Migrated tests: " + newBaseTestPath);
System.out.println("Migrated tests: " + (hasWebAuthnPath ? newWebAuthnTestPath : newBaseTestPath));
System.out.println();
System.out.println("Migrating test: " + testPath);
System.out.println("To: " + destinationPath);
Expand Down Expand Up @@ -120,8 +122,8 @@ private void validatePaths(Path testPath, Path destinationPath) throws IOExcepti
throw new RuntimeException("Test file not found");
}

if (!destinationPath.startsWith(newBaseTestPath.toString())) {
throw new RuntimeException("Can only migrate tests to " + newBaseTestPath);
if (!destinationPath.startsWith(newBaseTestPath.toString()) && !destinationPath.startsWith(newWebAuthnTestPath.toString())) {
throw new RuntimeException("Can only migrate tests to " + newBaseTestPath + "or to " + newBaseTestPath);
}

Path destinationDir = destinationPath.resolve("..");
Expand All @@ -131,8 +133,9 @@ private void validatePaths(Path testPath, Path destinationPath) throws IOExcepti
}
}

private Path getDestination(Path testPath) {
return Path.of(testPath.toString().replace(oldTestsuitePath.toString(), newBaseTestPath.toString()));
private Path getDestination(Path testPath, boolean hasWebAuthnPath) {
return Path.of(testPath.toString().replace(oldTestsuitePath.toString(),
hasWebAuthnPath ? newWebAuthnTestPath.toString() : newBaseTestPath.toString()));
}

private List<String> readFileToList(Path path) throws IOException {
Expand Down
Loading
0