Skip to content

Commit

Permalink
[WFCORE-6832] Wrong arguments to standalone.sh may lead to server con…
Browse files Browse the repository at this point in the history
…tent removal
  • Loading branch information
gaol committed May 23, 2024
1 parent 2040119 commit 22999e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.security.GeneralSecurityException;
import java.util.Collections;
Expand Down Expand Up @@ -120,7 +119,7 @@ public GitRepository(GitRepositoryConfiguration gitConfig)
}
} else {
Path atticPath = basePath.getParent().resolve("attic");
Files.copy(basePath, atticPath, StandardCopyOption.REPLACE_EXISTING);
PathUtil.copyRecursively(basePath, atticPath, true);
clearExistingFiles(basePath, gitConfig.getRepository());
try (Git git = Git.init().setDirectory(baseDir).setInitialBranch(branch).call()) {
String remoteName = DEFAULT_REMOTE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,25 @@ public void testDefaultPersistentConfigurationFile() throws Exception {
}
}

@Test
public void testNonExistingRemoteRepository() throws Exception {
createFile(root, "standard.xml", "std");
checkFiles("standard", "std");
String[] rootFiles = root.toFile().list();
Assert.assertNotNull(rootFiles);
Assert.assertEquals(1, rootFiles.length);
try (GitRepository gitRepository = new GitRepository(GitRepositoryConfiguration.Builder.getInstance()
.setBasePath(root)
.setRepository("non_existing")
.build())) {
Assert.assertEquals(root.toFile(), gitRepository.getDirectory());
} catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("WFLYSRV0269: Failed to initialize the repository non_existing"));
rootFiles = root.toFile().list();
Assert.assertNotNull(rootFiles);
Assert.assertEquals(1, rootFiles.length);
checkFiles("standard", "std");
}
}

}

0 comments on commit 22999e0

Please sign in to comment.