-
Notifications
You must be signed in to change notification settings - Fork 8.1k
added better validation and more validation tests #46277
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?
Conversation
fixes: keycloak#46271 Signed-off-by: Erik Jan de Wit <[email protected]>
mabartos
left a comment
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.
To fix compilation errors.
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Martin Bartoš <[email protected]>
mabartos
left a comment
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.
@edewit Thanks! Just added a few things
| // Validate the fully populated model (createClientModel only validates the basic model) | ||
| ValidationUtil.validateClient(session, model, true, r -> { | ||
| session.getTransactionManager().setRollbackOnly(); | ||
| throw new ServiceException(r.getAllErrorsAsString(), Response.Status.BAD_REQUEST); |
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.
In the v1, we use localized errors, but I think it does not have to be here for now as we don't have propagated the Auth context in the service.
So, +1 to keep this instead of the localized messages for now.
| mapper.toModel(client, model); | ||
|
|
||
| // Validate the fully populated model (createClientModel only validates the basic model) | ||
| ValidationUtil.validateClient(session, model, true, r -> { |
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.
It is needed also for the update... See here: https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/services/resources/admin/ClientResource.java#L162
Would it be possible to move this validation at the end of the method, where you set the third boolean param to mark if it's create or update op?
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.
but the code you show there is executed already form DefaultClientService
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.
@edewit Ahh, sorry, you're right. So, please prepare the missing tests for the update. Thanks!
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.
As mentioned, we lack of the validation for the update. Thus, we're missing some test cases for update.
Bonus: It'd be good to abstract/generalize a little bit these test cases to avoid the duplication.
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.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.AuthenticatorSubflowsTest2#testSubflow2Keycloak CI - Forms IT (chrome) |
fixes: #46271
Signed-off-by: Erik Jan de Wit [email protected]