-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Client Resource must return a single item (#39851) #43382
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
base: main
Are you sure you want to change the base?
Client Resource must return a single item (#39851) #43382
Conversation
af04a23 to
cec612a
Compare
| @GET | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| List<ClientRepresentation> findByClientId(@QueryParam("clientId") String clientId); | ||
| ClientRepresentation findByClientId(@QueryParam("clientId") String clientId); |
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.
Please see keycloak/keycloak-client#155 (comment) and use the method name findClientByClientId, then deprecate findByClientId.
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.
@shawkins Thanks for the thorough review and helpful suggestions! I’ve addressed the feedback and pushed updates relating to #39851 and #155 :
-
Renamed the API to findClientByClientId(String) and deprecated findByClientId(String)
-
Kept the old method as a compat shim delegating to the new one (returns empty/singleton list) ClientTest.findByClientListResult()
-
Migrated tests to the new API and standardized assertions (assertNotNull, assertNull, etc.);retained one minimal compat test with @SuppressWarnings("deprecation")
This is my first PR to Keycloak—happy to take any suggestions or guidance to align with project requirements.
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.
This is my first PR to Keycloak—happy to take any suggestions or guidance to align with project requirements.
@cherifyazid thank you for this pr. Everything looks good - can you also add a DCO sign off to your commit?
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.
@shawkins Done !
|
|
||
| ClientRepresentation client = clients.get(0); | ||
| ClientRepresentation client = realmResource.clients().findByClientId("myclient"); | ||
| assertNotNull(client); |
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.
Keep the same style of assertion, use static method of Assertions class instead of static import, just to unify the way asserts are used
Prefer Assertions.assertNotNull(client);
85f3411 to
086ef7a
Compare
086ef7a to
fd73a1f
Compare
fd73a1f to
56f9526
Compare
40d7aab to
2d16e23
Compare
|
I might be wrong here, but just stumbled upon this and saw this kind of snippets in the PR: ClientRepresentation client = realm.admin().clients().findClientByClientId(attachTo);
if (client != null) {
throw new IllegalStateException("No client found with client id: " + attachTo);
}Shouldn't the condition check that client is null instead? i.e. |
Absolutely those two instances need to be corrected. Also @cherifyazid are you able to update / rebase this pr? |
2d16e23 to
76ddcf4
Compare
|
@cobotrifork nice catch, correction pushed. |
76ddcf4 to
273c7b8
Compare
|
@cherifyazid @cobotrifork took a pass over the changes and made several refinements. There are now two new default methods on ClientsResource:
To all other reviewers if need this pr can be split apart - just the changes to ClientRepresentation could go in by itself, and the changes to the legacy test classes could be omitted. |
273c7b8 to
deaa197
Compare
|
Nice work! Could you please resolve the conflicts? |
Closes keycloak#39851 Signed-off-by: CHERIF Yazid <[email protected]> Signed-off-by: Steve Hawkins <[email protected]> # Conflicts: # testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oid4vc/issuance/signing/OID4VCIssuerEndpointTest.java
4c9f7f7 to
8165a39
Compare
It's resolved, but unfortunately this will keep coming up as too many files are touched. If we don't see a path to get it in soon whole, then it will be best to break it up. |
|
@mposolda @lhanusov @vmuzikar @cherifyazid based upon more feedback from @keycloak/cloud-native I'll stop updating this PR. If core-clients would entertain these some of these changes, we'll assign the PR to someone in that team. If not, then this PR and the keycloak / keycloak-client issues can be closed. |
|
Just to add a bit more context to what @shawkins stated. The current Admin REST API suffers from numerous issues and inconsistencies. Instead of trying to navigate the possible fixes while managing breaking changes, we decided to take a step back and redesign the API as a version 2, currently focused and scoped to Client management. Hence we're not prioritizing enhancements to the current (v1) API as those will come in v2. |
|
@cherifyazid Thanks for understanding. Can we close this PR then? |
I'd let @mposolda make that call since he was last to triage the keycloak-client issue. If he or those heavily working on the tests like @lhanusov don't want these changes, then definitely this pr and keycloak and keycloak-client issues can be closed. |
We have such a method org.keycloak.admin.client.resource.ClientsResource.findByClientId(String) that should return a single item, but it returns a List of ClientRepresentation.
for more details please check the issue description
Closes #39851
Signed-off-by: cherifyazid [email protected]