Add unit tests for keycloak service#252
Conversation
Added unit tests for assignUserRole
|
Please complete the documentation(fill description, assign the PR to yourself). |
|
Hi, I have completed the PR description, assigned the PR to myself, and changed the target branch to develop. All checks have passed, and the PR is ready for review. |
ma-mirzaei
left a comment
There was a problem hiding this comment.
Tests are too implementation-coupled to Keycloak SDK. They should validate behavior, not mock the entire Keycloak object graph.
|
Hi Mohammed, I have applied some changes to KeycloakService.java to separate the service logic from the Keycloak SDK implementation details. I introduced a small KeycloakGateway boundary and moved the direct Keycloak SDK calls into KeycloakGatewayImpl. This allows KeycloakServiceTest to focus on testing the expected service behavior and errors without mocking the full Keycloak SDK object graph. All checks have passed, and the PR is ready for review. Thank you |
ma-mirzaei
left a comment
There was a problem hiding this comment.
This PR is intended to add test cases. Why are the Checkstyle configuration and suppressions being modified? Please keep unrelated build configuration changes out of this PR unless they are required for the tests and explain the reason.
|
Hi Mohammed, I initially changedd the pom.xml while troubleshooting the test execution locally, because the first test approach was failing due to Mockito/Byte Buddy setup issues. After revising the tests to avoid mocking the full Keycloak SDK object graph, those build configuration changes were no longer needed. Please let me know if there are any other changes needed Thank you |
|
Hi Mohammed, I noticed that you recently changed the status of this issue to Done, and the “Merge pull request” button is green on my side. However, I don’t see an approval from you on the pull request. Should I go ahead and merge it, or should I wait for your approval first? Thank you. |
|
I checked the PR again, and when I checked the Sonar analyze, I found the issue |
|
Hello Mohammed, I have fixed the SonarQube issues under this pull request, and the PR is ready for review. There is still one remaining SonarQube issue: “Remove this 'public' modifier”. However, the related file does not seem to exist on my local machine, so I am not sure how to resolve it from my side. Could you please advise me on how I should handle this case? Also, please let me know if there is anything else I should change, or if the PR is ready to be merged after your approval. Thank you. |
|
Whenever you want to review the project again, use the curly symbol near the reviewer’s name. The reviewer can then start reviewing it again. |
|
Hello Mohammed, After the merge from Develop to this branch, 23 issues occurred on Sonar. Should I resolve them or Merge to develop after review and work on vitruv-change? Thank you |
|
Just resolve the important issues that relate to your task's scope. |
|
Okay, since all the new issues are not related to the main objective of this PR. I have the "merge pull request" button as green but I don't see your approval Thank you Mohammed |
Summary
This PR improves Keycloak-related tests by separating application behavior from the Keycloak SDK integration layer.
KeycloakServiceTestnow validates service behavior through a fakeKeycloakGateway, whileKeycloakGatewayImplTestverifies that the gateway interacts correctly with Keycloak HTTP endpoints.Changes
KeycloakGatewayboundary for Keycloak operations.KeycloakGatewayImpl.KeycloakServiceto use the gateway for:KeycloakServiceTestto validate service behavior without mocking the full Keycloak SDK object graph.KeycloakGatewayImplTestto cover the Keycloak adapter behavior against a mock Keycloak HTTP server.Responsewith try-with-resourcesdummyassignment from password verificationVerification