You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR Review: test user pass with special characters fixed to run on all platforms
Gather context and analyze PR
Read changed file for context
Review for correctness, security, and performance
Post review findings
Summary
The fix is correct and well-reasoned. The root cause was that the old code always wrapped credentials in shell-quoting ("...") when passing them as --user/--pass args to the NATS server process. On Windows, ProcessBuilder flattens the arg list into a shell command line and the shell strips those quotes, so the server receives the bare credential. On Unix, ProcessBuilder passes the list directly to execv with no shell, so the quotes became literal characters in the credential string — making the test fail with the wrong credential. The fix adds quotes only on Windows.
One pre-existing issue worth noting
Duplicate test character (\t / (char)9)
src/test/java/io/nats/client/AuthTests.java, lines 105 and 107:
\t is ASCII 9 (horizontal tab), so these two lines test the identical character and one of the server-start/stop cycles is redundant. This was present in the original code too — not introduced by this PR — but since the test is being renamed and cleaned up anyway, this would be a good time to remove the duplicate.
Everything else looks good
quoteCredentialForOs logic — correct. WINDOWS.isCurrentOs() from JUnit's org.junit.jupiter.api.condition.OS is the right way to branch. The method is private static and only used in the test helper, appropriate scope.
Builder API switch — NatsServerRunner.builder().customArgs(customArgs) is the idiomatic newer API; the NatsTestServer(Builder b) constructor is already in place to accept it.
Removing @EnabledOnOs — the whole point of the fix. The test is now valid on all platforms.
Comments — the two block comments explaining the JSON-encoding rationale and the OS-quoting difference are clear and accurate; a future reader will understand the constraint without digging into ProcessBuilder docs.
No security, thread-safety, or performance concerns — this is test infrastructure; correctness is the only axis that matters here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.