|
22 | 22 | import org.junit.jupiter.api.Test; |
23 | 23 | import org.opendataloader.pdf.api.Config; |
24 | 24 |
|
| 25 | +import java.io.ByteArrayOutputStream; |
| 26 | +import java.io.PrintStream; |
| 27 | + |
25 | 28 | import static org.junit.jupiter.api.Assertions.*; |
26 | 29 |
|
27 | 30 | class CLIOptionsContentSafetyTest { |
@@ -75,4 +78,25 @@ void deprecatedSensitiveDataValueIsAccepted() throws Exception { |
75 | 78 | assertFalse(config.getFilterConfig().isFilterSensitiveData(), |
76 | 79 | "Deprecated sensitive-data value should not enable sanitization"); |
77 | 80 | } |
| 81 | + |
| 82 | + @Test |
| 83 | + void deprecatedSensitiveDataValuePrintsWarning() throws Exception { |
| 84 | + PrintStream originalErr = System.err; |
| 85 | + ByteArrayOutputStream errContent = new ByteArrayOutputStream(); |
| 86 | + System.setErr(new PrintStream(errContent)); |
| 87 | + try { |
| 88 | + parseArgs("--output-dir", "/tmp", "--content-safety-off", "sensitive-data"); |
| 89 | + assertTrue(errContent.toString().contains("deprecated"), |
| 90 | + "Should print a deprecation warning to stderr"); |
| 91 | + } finally { |
| 92 | + System.setErr(originalErr); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + void sanitizeWithDeprecatedSensitiveDataStillEnablesSanitize() throws Exception { |
| 98 | + Config config = parseArgs("--output-dir", "/tmp", "--content-safety-off", "sensitive-data", "--sanitize"); |
| 99 | + assertTrue(config.getFilterConfig().isFilterSensitiveData(), |
| 100 | + "--sanitize should win over deprecated --content-safety-off sensitive-data"); |
| 101 | + } |
78 | 102 | } |
0 commit comments