Overview of Changes
- Add annotation
@JsonIgnoreon variableauthHeaderto avoid auto-serialization. - Import package
com.fasterxml.jackson.annotation.JsonIgnoreto make annotation valid. - run command
./gradlew checkstyleMainand./gradlew formatto fix style error.
Related Issues
Fixed #42905
Type of Change
- [X] Fix bug
Impact
Now when class DockerRegistryUserAuthentication and DockerRegistryTokenAuthentication use method createAuthHeader() would't add "authHeader" : null field.
Test
I've already test the class DockerRegistryUserAuthentication and DockerRegistryTokenAuthentication method getAuthHeader(), but only write rough test code not create a new branch to test. Do I need create a new branch?
Effect of Test
Use decode tools to display the original string.
Expected Result:
{
"username" : "Ben",
"password" : "123455",
"serveraddress" : "docker@example.com",
"email" : "https://docker.example.com"
}
it works as expected.
Note
If anything I did worked not as expected, plz contact with me. Finally, looking forward to your reply.
Comment From: snicoll
@1328032567 thank you for making your first contribution to Spring Boot. To validate the auth header would not be included, I've changed the assertion of the "full" sample to be strict. See d4010d3.
Comment From: wickdynex
@1328032567 thank you for making your first contribution to Spring Boot. To validate the auth header would not be included, I've changed the assertion of the "full" sample to be strict. See d4010d3.
Alright, though you did't merge my branch(what a pity) but also used my modification. And finally I understand the true meaning of DockerRegistryUserAuthenticationTests and DockerRegistryTokenAuthenticationTests 🤣. And you change the test assert more strict, is that necessary? 🤔and why need to do this, could you plz explain it for me? Appreciate so much🥺.
Comment From: snicoll
though you did't merge my branch(what a pity) but also used my modification.
I did merge it, see 351018e. If you're worried about this not being recognized as a contribution of yours, See the tags next to your name on this page.
the test assert more strict, is that necessary
Nothing was validating that the auth header is gone. By using a strict assertion (true instead of false) the test will fail if there is an extra attribute present.
Comment From: wickdynex
though you did't merge my branch(what a pity) but also used my modification.
I did merge it, see 351018e. If you're worried about this not being recognized as a contribution of yours, See the tags next to your name on this page.
the test assert more strict, is that necessary
Nothing was validating that the auth header is gone. By using a strict assertion (
trueinstead offalse) the test will fail if there is an extra attribute present.
oh, I try to look through the doc for JSONAssert() api, and figure out the null attribution would also be valid through flag false, so we need to modify the flag into true. Thanks for your explanation🤩, Im very grateful.
Finally, about contribution, thanks for merging my PR #42910, Im overjoyed🥳.