Repository navigation
Offline tests; fix read timeout, failure handling, PNG answers, secrets in the log - #37
Merged
Merged
Conversation
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes
Two things together: the offline tests of the client, and the fixes they made possible.
Tests
MockPveServer):RequestTest,LoginTest,TaskTest,GeneratedClientTest, andFailureTestfor the cases below. 55 tests, no cluster needed, run bymvn testand so by the build workflow.LiveClusterTestis taggedliveand runs only with-P live(it needsPVE_HOST,PVE_API_TOKEN,PVE_TEST_VMID).Test.java(a program that needed a cluster, run with the exec plugin) is removed.Fixed
Resultwith status 408 and the reason.Resultwith no data. It is now status 502 with the start of the body in the reason; an error status is kept.Result.responseInError()andgetError()threwNullPointerExceptionwhen there was no response, which is the case of every failed request above./api2/json. The bytes are now returned as they are, the request goes to/api2/png, an error answer keeps its status and errors, and login and task status are always read as JSON.FINERprinted the ticket and the CSRF token of the login answer; the log atFINEprinted the query string of GET and DELETE requests, which repeats the parameters unmasked. Both are now masked, and the parameters of every method are listed with the secret ones as****.loginthrewNullPointerExceptionon an answer without data or without a ticket; it now returnsfalse. The realm is read from the part after the last@.NullPointerExceptionorArrayIndexOutOfBoundsException. Now aPveResultExceptionbefore any request.Content-Lengthheader was set to the number of characters, not of bytes: the line is removed, the JDK sets the header itself.Changed
getApiUrl()follows the response type of the client (/api2/jsonor/api2/png). New protectedgetBaseAddress()gives scheme, host and port.login(when it throws, when it returnsfalse), ofsetTimeoutand ofgetExitStatusTask(null while the task runs) corrected to what the code does.Not changed: certificate validation stays off by default, as in the other cv4pve clients.
Tests
On the code before the fix the 11 tests of
FailureTestall fail (among them: the call to a silent node still running after 5 seconds, the PNG bytes altered,NullPointerExceptioninresponseInError, the ticket in the log). After: 55 passed, 0 failed, with Maven and JDK 23.The answers are simulated: the fixes were not run against a real cluster. The PNG path in particular should be tried on a node.