-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Factor out some common object mocking in tests #15396
Conversation
@jesperronn Please feel free to let me know if there is anything I need to change. I look forward to your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup, @gzhao9. I think there is already a MockSecurityContextHolderStrategy
available in spring-security-core
. Can you please enhance that instead?
I think it would be reasonable to add the default constructor and one that takes a SecurityContext
to that class.
Please also run ./gradlew format && ./gradlew check
before committing next. It appears there are some formatting issues that those two tasks will help you work through.
When you are done, will you please change your commits to be more descriptive in the following way. For each commit, describe what you've done and include the issue number like so:
Use MockSecurityContextHolderStrategy
Issue gh-14768
For the final commit, please use Closes gh-14768
instead as this integrates with our build system to close the issue automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, @gzhao9. I've left feedback inline.
Additionally, will you please consider whether you can follow the same strategy for all four files when it comes to setting up mocks? It seems that in one you have a separate class, in another you have a field and a setup
method, and in others you use a local method. It would be nice if the code can be more consistent.
Finally, will you please ensure that your commits are in the following format:
Factor out common SecurityContextHolderStrategy mocking
or similar, depending on the work done for each file.
...framework/security/authorization/method/AuthorizationManagerAfterMethodInterceptorTests.java
Outdated
Show resolved
Hide resolved
...ramework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProviderTests.java
Show resolved
Hide resolved
web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java
Outdated
Show resolved
Hide resolved
web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java
Outdated
Show resolved
Hide resolved
web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java
Outdated
Show resolved
Hide resolved
I found |
I first focus on each file code modification. I will rebase commits when there is no need to modify the code or format. |
Thanks for the updates, @gzhao9! I think there are two other items from the review that haven't been addressed yet. Are you able to do those as well? |
I have modified the code as required. |
7d2e734
to
4c08ad4
Compare
Thanks, @gzhao9! This is now merged into |
Hi there,
This PR is to address issue #14768, which involves reducing repeated mock object creation in tests.
I mistakenly closed PR #15256 and then discovered that I do not have permission to reopen it, receiving the message
this branch was force pushed or recreated.
I'm not sure if I should reopen the original or create this new PRAlthough my issue submission mentioned 4 separate draft PRs, I combined them into this PR, since they all address the same problem.