oscerd opened a new pull request, #23113:
URL: https://github.com/apache/camel/pull/23113

   ## Motivation
   
   Keycloak 26 introduced an 
[Organizations](https://www.keycloak.org/docs/latest/server_admin/index.html#_managing-organizations)
 primitive that allows realms to model multi-tenant scenarios — companies, 
customer accounts, etc. — with members and identity-provider links.
   
   The Keycloak admin client `26.0.8` already on `camel-keycloak`'s classpath 
exposes the Organizations API via `OrganizationsResource` / 
`OrganizationResource` / `OrganizationMembersResource` / 
`OrganizationIdentityProvidersResource`, but none of it was surfaced as Camel 
operations. This change wires the full Organizations CRUD plus member and 
identity-provider management into the existing `camel-keycloak` producer.
   
   JIRA: https://issues.apache.org/jira/browse/CAMEL-23452
   
   ## Changes
   
   ### New operations on ``KeycloakOperations``
   
   | Operation | Description |
   | --- | --- |
   | `createOrganization` | Create a new organization (header-based or 
`pojoRequest=true` with `OrganizationRepresentation`). |
   | `updateOrganization` | Update an existing organization (POJO request). |
   | `deleteOrganization` | Delete an organization by ID. |
   | `getOrganization` | Retrieve an organization by ID. |
   | `listOrganizations` | List all organizations in a realm (optional 
`FIRST_RESULT` / `MAX_RESULTS` paging). |
   | `searchOrganizations` | Search organizations by free-text (name / alias / 
domain), with optional paging. |
   | `addOrganizationMember` | Add an existing realm user as a member of an 
organization. |
   | `removeOrganizationMember` | Remove a user from an organization. |
   | `listOrganizationMembers` | List members of an organization (optional 
paging). |
   | `linkOrganizationIdentityProvider` | Link an existing realm IdP to an 
organization. |
   | `unlinkOrganizationIdentityProvider` | Unlink an IdP from an organization. 
|
   | `listOrganizationIdentityProviders` | List IdPs linked to an organization. 
|
   
   ### New headers on ``KeycloakConstants``
   
   `ORGANIZATION_ID`, `ORGANIZATION_NAME`, `ORGANIZATION_ALIAS`, 
`ORGANIZATION_DESCRIPTION`, `ORGANIZATION_REDIRECT_URL`, `ORGANIZATION_DOMAIN`, 
`ORGANIZATION_SEARCH`. Member operations re-use the existing `USER_ID`, 
IdP-link operations re-use `IDP_ALIAS`, and paging operations re-use 
`FIRST_RESULT` / `MAX_RESULTS`.
   
   ### Implementation
   
   `KeycloakProducer` follows the existing switch-on-operation pattern. Every 
new method validates required headers (`MISSING_REALM_NAME`, 
`MISSING_ORGANIZATION_ID`, `MISSING_ORGANIZATION_NAME`, 
`MISSING_ORGANIZATION_MEMBER_ID`, `MISSING_ORGANIZATION_IDP_ALIAS`) and returns 
either the JAX-RS `Response`, a representation POJO, a `List<...>`, or a fixed 
success string — matching the conventions used by existing operations.
   
   ### Tests
   
   * `KeycloakProducerTest` adds Mockito-based unit tests for all 12 operations 
plus missing-name / missing-id validation.
   * `KeycloakTestInfraIT` exercises the full lifecycle (create → list → get → 
search → add-member → list-members → remove-member → link-IdP → list-IdPs → 
unlink-IdP → cleanup) against the testcontainers-based Keycloak from 
`camel-test-infra-keycloak`, with a dedicated cleanup step ordered before the 
existing IdP/realm teardown.
   
   ### Documentation
   
   `keycloak-component.adoc` is updated:
   * New `Organization Management` entry in the **Supported Operations** 
summary.
   * New `=== Organization Operations` section with end-to-end Java examples 
covering all 12 operations.
   
   ## How to test
   
   ```bash
   cd components/camel-keycloak
   mvn clean install                          # unit tests
   mvn verify -Pit                            # integration tests 
(testcontainers)
   ```
   
   All 91 unit tests pass locally (28 of them in `KeycloakProducerTest`, 
including the 11 new organization tests).
   
   ## Notes
   
   * No new dependencies. The Organizations API is already provided by 
`keycloak-admin-client` 26.0.8 currently on the classpath.
   * No public API signatures are changed; only additions to the operations 
enum and constants.
   
   ---
   
   _Claude Code on behalf of Andrea Cosentino_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to