Skip to content

Fix admin event paths when request realm casing differs - #55226

Draft
Aschenbath wants to merge 3 commits into
keycloak:mainfrom
Aschenbath:fix/admin-event-realm-path-55222
Draft

Aschenbath wants to merge 3 commits into
keycloak:mainfrom
Aschenbath:fix/admin-event-realm-path-55222

Conversation

@Aschenbath

Copy link
Copy Markdown

Use the realm name matched in the request so admin-event resource paths stay relative to the realm when a case-insensitive database accepts different casing. Shared extraction preserves the casing of decoded resource names and IDs in both API versions and keeps unmatched paths intact.

The regressions invoke the builders in real server sessions with the resolved realm model, so they also run on case-sensitive databases. They cover both URI overloads, decoded paths and trailing slashes; the admin-event documentation now describes the path semantics.

Closes #55222

Validation on Windows with JDK 17, the distribution server and H2 (dev-mem): AdminEventTest passed 15 tests and AdminEventV2Test passed 7, with no failures or skips. Before the fix, both mixed-case regressions failed while their same-case controls passed. mvnw.cmd -Pspotless spotless:apply and mvnw.cmd -Pspotless spotless:check passed.

AI assistance: Codex generated the implementation, regression tests and documentation.

Use the realm matched in the request to derive resource paths for both Admin API versions.

Closes keycloak#55222

Signed-off-by: Nash Aschenbath <wwh86696@163.com>
@ahus1

ahus1 commented Nov 16, 2026

Copy link
Copy Markdown
Member

Putting this one on hold. Let's first agree on the solution in the parent.

@ahus1 ahus1 self-assigned this Nov 16, 2026
@ahus1 ahus1 removed status/hold PR should not be merged. On hold for later. team/core-shared labels Nov 18, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the fix/admin-event-realm-path-55222 branch from 34f1c86 to 0682616 Compare November 18, 2026 13:00
@ahus1
ahus1 requested a balanced review from Copilot November 19, 2026 09:19
@ahus1

ahus1 commented Nov 19, 2026

Copy link
Copy Markdown
Member

I've updated the PR to include a database-backed end-to-end test for the problem at hand.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both admin event tests misidentify the remote MSSQL configuration, causing them to expect 404 instead of valid success responses and fail the Azure database job.

1 open issue
What changed in this PR

Fixes admin-event resource paths when request realm casing differs from the stored name, addressing #55222 across both Admin API versions.

Changes:

  • Shares path extraction using the request’s matched realm name and preserves unmatched paths.
  • Adds exact-case and uppercase-realm request tests with database-specific expectations.
  • Extends database-suite dependencies and CI execution to Admin API v2.
File Description
tests/​utils/​src/​main/​java/​org/​keycloak/​tests/​suites/​DatabaseTest.java Documents selection criteria for cross-database tests.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​event/​AdminEventTest.java Adds realm-casing tests for user-update event paths.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​AdminEventBuilder.java Extracts paths using the matched request realm.
rest/​admin-v2/​tests/​src/​test/​java/​org/​keycloak/​tests/​suites/​DatabaseTestSuite.java Adds the v2 database test suite.
rest/​admin-v2/​tests/​src/​test/​java/​org/​keycloak/​tests/​admin/​client/​v2/​AdminEventV2Test.java Adds realm-casing tests for v2 client-event paths.
rest/​admin-v2/​tests/​pom.xml Adds database providers and JUnit suite support.
rest/​admin-v2/​services/​src/​main/​java/​org/​keycloak/​events/​admin/​v2/​AdminEventV2Builder.java Delegates to shared extraction with the v2 route prefix.
.github/​actions/​run-store-tests/​action.yml Runs the v2 database suite in store-test CI.

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The test fails incorrectly on case-insensitive remote databases such as MSSQL because it checks the supplier name rather than the vendor, expecting 404 instead of 201.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Resolve vendor for remote database supplier

rest/​admin-v2/​tests/​src/​test/​java/​org/​keycloak/​tests/​admin/​client/​v2/​AdminEventV2Test.java:142

With kc.test.database=remote and a case-insensitive vendor such as mssql, this returns remote, so the mixed-case request succeeds with 201 but the test incorrectly expects 404. Resolve kc.test.database.vendor for the remote supplier, as the v1 regression already does.

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin events record an incorrect resource path when realm name casing differs in the request

3 participants