This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jarsigner.git
The following commit(s) were added to refs/heads/master by this push:
new e9775b3 Deduplicate Windows escaping assertions
e9775b3 is described below
commit e9775b358b3433e59ea53b49eb2526d3084c3f1d
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Nov 19 00:54:36 2026 +0100
Deduplicate Windows escaping assertions
---
.../jarsigner/JarSignerCommandLineBuilderTest.java | 44 ++++++----------------
1 file changed, 12 insertions(+), 32 deletions(-)
diff --git
a/src/test/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilderTest.java
b/src/test/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilderTest.java
index abe3e86..3928f47 100644
---
a/src/test/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilderTest.java
+++
b/src/test/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilderTest.java
@@ -51,52 +51,32 @@ class JarSignerCommandLineBuilderTest {
return Arrays.toString(cli.getArguments());
}
- @Test
- void passwordWithAmpersandShouldBeEscapedOnWindows() throws Exception {
- request.setStorepass("p&ssword");
- String argsString = buildArgsString();
-
+ private void assertEscaped(String raw, String escaped, String argsString) {
if (IS_WINDOWS) {
- assertTrue(
- argsString.contains("p^&ssword"),
- "Password with '&' should be escaped with '^' on Windows,
args: " + argsString);
+ assertTrue(argsString.contains(escaped), "Value should be escaped
on Windows, args: " + argsString);
} else {
assertTrue(
- argsString.contains("p&ssword"),
- "Password should pass through unchanged on non-Windows,
args: " + argsString);
+ argsString.contains(raw),
+ "Value should pass through unchanged on non-Windows, args:
" + argsString);
}
}
+ @Test
+ void passwordWithAmpersandShouldBeEscapedOnWindows() throws Exception {
+ request.setStorepass("p&ssword");
+ assertEscaped("p&ssword", "p^&ssword", buildArgsString());
+ }
+
@Test
void keypassWithAmpersandShouldBeEscapedOnWindows() throws Exception {
request.setKeypass("k&ypass");
- String argsString = buildArgsString();
-
- if (IS_WINDOWS) {
- assertTrue(
- argsString.contains("k^&ypass"),
- "Keypass with '&' should be escaped with '^' on Windows,
args: " + argsString);
- } else {
- assertTrue(
- argsString.contains("k&ypass"),
- "Keypass should pass through unchanged on non-Windows,
args: " + argsString);
- }
+ assertEscaped("k&ypass", "k^&ypass", buildArgsString());
}
@Test
void passwordWithOtherSpecialCharsShouldBeEscapedOnWindows() throws
Exception {
request.setStorepass("p|ss<word>(1)@home^end");
- String argsString = buildArgsString();
-
- if (IS_WINDOWS) {
- assertTrue(
- argsString.contains("p^|ss^<word^>^(1^)^@home^^end"),
- "Special chars should be escaped on Windows, args: " +
argsString);
- } else {
- assertTrue(
- argsString.contains("p|ss<word>(1)@home^end"),
- "Password should pass through unchanged on non-Windows,
args: " + argsString);
- }
+ assertEscaped("p|ss<word>(1)@home^end",
"p^|ss^<word^>^(1^)^@home^^end", buildArgsString());
}
@Test