Skip to content
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

#2320: Unit Tests for ACL Credential Propagation in JedisPool/UnifiedJedis #4121

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

YoHanKi
Copy link

@YoHanKi YoHanKi commented Mar 23, 2025

Questions

  • In your previous feedback, you mentioned, "I would start with reviewing submitted tests and check if there are other places where we configure username/password with missing tests." Does this mean that username/password should be passed in every test, or are you referring to specific tests (e.g., JedisPoolTest or JedisPooledTest)?

  • Regarding the approach of using a test-specific subclass (TestJedisFactory) to verify, without using Reflection, that the ACL credentials provided to the constructor are correctly reflected in the internal JedisClientConfig—is this approach acceptable? Are there any additional aspects we should check?

  • Additionally, we would like to confirm if the placement of these tests is appropriate.

- Unit test for constructors of JedisPool/UnifeidJedis which verifies that the provided username/password reaches ConnectionFactory. Without the need of explicit test env
@ggivo
Copy link
Collaborator

ggivo commented Mar 24, 2025

Hi @YoHanKi,
Thanks for spending time on this issue an sorry I was not more specific.

With commit we have introduced dedicated test user acljedis different than default one

user acljedis on all commands allkeys >fizzbuzz

and added integration tests JedisWithCompleteCredentialsTest.java, JedisPoolWithCompleteCredentialsTest.java, SSLJedisWithCompleteCredentialsTest.java to connect with non-default user.

In the comment #2320 (comment) it is mentioned that there are still missing tests, what I meant is to try to identify them and add any missing ones.

Optionally we can create a unit test for JedisPoolUnitTest, ..., which exercises JedisPool object constructions.
A unit test should be placed in a separate test class.

Regarding the approach of using a test-specific subclass (TestJedisFactory) to verify, without using Reflection, that the ACL credentials provided to the constructor are correctly reflected in the internal JedisClientConfig—is this approach acceptable? Are there any additional aspects we should check?

Another option instead of using Reflection is to use Mocking object construction

Hope it helps...

YoHanKi added 3 commits March 26, 2025 23:11
- Unit test for constructors of JedisPool/UnifeidJedis which verifies that the provided username/password reaches ConnectionFactory. Without the need of explicit test env
- Unit test for constructors of JedisPool/UnifeidJedis which verifies that the provided username/password reaches JedisFactory/ConnectionFactory. Without the need of explicit test env
- Unit test for constructors of JedisPool/UnifeidJedis which verifies that the provided username/password reaches JedisFactory/ConnectionFactory. Without the need of explicit test env

- In addition to the existing integration tests that connect with the dedicated non-default user "acljedis"
@YoHanKi
Copy link
Author

YoHanKi commented Mar 28, 2025

Hello @ggivo ,

Thank you for your guidance.

I have written tests based on your feedback and did my best, though I feel my skills are still quite limited.
If you could kindly point out any additional improvements or errors, I would be more than happy to revise them.

I really appreciate your support for a junior developer like me.

@ggivo
Copy link
Collaborator

ggivo commented Apr 4, 2025

@YoHanKi
Sorry for the delayed response. Got dragged on other assignments.
ACLJedisPoolTest & ACLJedisTest looks good to me.
I have my doubts about mixing Mock's with actual env in JedisPoolUnitTest.java and need to take a closer look. Will try to spend some time on it in the upcoming days.

YoHanKi and others added 3 commits April 4, 2025 23:53
…magic numbers (redis#2320)

- Added unit tests for JedisPool/UnifiedJedis constructors to verify that the provided username/password reaches JedisFactory/ConnectionFactory
- Change verification method to find necessary fields instead of using magic numbers
@YoHanKi
Copy link
Author

YoHanKi commented Apr 4, 2025

Hello, @ggivo

Thank you very much for your kind attention and review. Before you looked into JedisPoolUnitTest, I was concerned that the previous usage of magic numbers (such as context.arguments().get(1)) might lead to potential issues, so I modified it accordingly. If you feel that the previous approach is more suitable, I would be more than happy to revert the change.

Once again, I sincerely appreciate your thoughtful review and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants