Merge branch 'main' into securityFixes

This commit is contained in:
Anthony Stirling 2025-05-27 16:10:11 +01:00 committed by GitHub
commit 8605bf0716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 17 deletions

View File

@ -134,7 +134,7 @@ Stirling-PDF currently supports 40 languages!
| Hungarian (Magyar) (hu_HU) | ![88%](https://geps.dev/progress/88) |
| Indonesian (Bahasa Indonesia) (id_ID) | ![72%](https://geps.dev/progress/72) |
| Irish (Gaeilge) (ga_IE) | ![82%](https://geps.dev/progress/82) |
| Italian (Italiano) (it_IT) | ![88%](https://geps.dev/progress/88) |
| Italian (Italiano) (it_IT) | ![96%](https://geps.dev/progress/96) |
| Japanese (日本語) (ja_JP) | ![84%](https://geps.dev/progress/84) |
| Korean (한국어) (ko_KR) | ![82%](https://geps.dev/progress/82) |
| Norwegian (Norsk) (no_NB) | ![77%](https://geps.dev/progress/77) |

View File

@ -1,24 +1,26 @@
package stirling.software.common.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class CheckProgramInstallTest {
@ -140,7 +142,7 @@ class CheckProgramInstallTest {
void testGetAvailablePythonCommand_WhenNoPythonIsAvailable()
throws IOException, InterruptedException {
// Arrange
when(mockExecutor.runCommandWithOutputHandling(any(List.class)))
when(mockExecutor.runCommandWithOutputHandling(anyList()))
.thenThrow(new IOException("Command not found"));
// Act
@ -168,7 +170,7 @@ class CheckProgramInstallTest {
String firstCall = CheckProgramInstall.getAvailablePythonCommand();
// Change the mock to simulate a change in the environment
when(mockExecutor.runCommandWithOutputHandling(any(List.class)))
when(mockExecutor.runCommandWithOutputHandling(anyList()))
.thenThrow(new IOException("Command not found"));
String secondCall = CheckProgramInstall.getAvailablePythonCommand();

View File

@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
@ -132,7 +133,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer(
invocation -> {
// When command is executed, simulate creation of output files
@ -175,7 +176,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer(
invocation -> {
// When command is executed, simulate creation of output files
@ -251,7 +252,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer(
invocation -> {
// When command is executed, simulate creation of output files
@ -537,7 +538,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE))
.thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class)))
when(mockProcessExecutor.runCommandWithOutputHandling(anyList()))
.thenAnswer(
invocation -> {
// When command is executed, find the output directory argument