Refactor and cleanup

* simplify AttributeEndpointsResourceProvider
* improve explanation of properties in AdminUiPage
* add example for mailing lists and map endpoint
* better explain configuration and operation of provider in main readme
* adjust the Keycloak realm
* Add unit test for endpoint class
This commit is contained in:
Stefan Bethke 2026-07-18 17:39:01 +02:00
commit cd31ec8a20
10 changed files with 523 additions and 200 deletions

View file

@ -1,9 +1,11 @@
# Creating a Testing Keycloak
# Integration Testing
This directory contains infrastructure and tests to verify end-to-end operation of the provider.
## Creating a Testing Keycloak
The Docker Compose setup in this directory sets up Keycloak and imports a realm `testing`.
## Starting Keycloak
Run `docker compose up -d` to start Keycloak. The admin console will be available at http://localhost:8080/.
You can attach a Java debugger at `localhost:8081`.
@ -11,7 +13,7 @@ You can attach a Java debugger at `localhost:8081`.
The realm export is in `import/testing.json`.
It will be imported automatically when Keycloak starts.
## Updating the Realm
### Updating the Realm
If you want to make changes to the testing realm and persist them, you need to export the realm.
@ -25,16 +27,36 @@ docker compose exec -it keycloak sh -c "cp -rp /opt/keycloak/data/h2 /tmp && env
## Running Integration Tests
This directory also contains shell scripts that exercise the attribute endpoint.
This directory contains shell scripts that exercise the attribute endpoint.
Bring up Keycloak with `docker compose up -d`, then run one of the `client-test-export-`*`.sh` scripts.
```shell
$ ./client-test-export-dooris.sh
All attributes collated into a single list
[
"hacker-ssh-key-1",
"hacker-ssh-key-2"
]
Results mapped per attribute
{
"ssh-key-1": [
"hacker-ssh-key-1"
],
"ssh-key-2": [
"hacker-ssh-key-2"
]
}
$ ./client-test-export-mailing-lists.sh
chaos@
[
"hacker+chaos@example.net",
"tester+chaos@example.com"
]
intern@
[
"hacker+intern@example.net"
]
```
## Realm `testing` Configuration
@ -43,16 +65,16 @@ The realm contains these objects:
* Clients:
* `export-dooris-ssh-keys` with secret `export-dooris-ssh-keys-secret` and user `service-account-export-dooris-ssh-keys`
* `export-mailing-list-addresses` with secret `export-mailing-list-addresses-secret` and role `export-mailing-list-addresses`
* `export-mailing-list-addresses` with secret `export-mailing-list-addresses-secret` and user `service-account-export-mailing-list-addresses`
* Realm Roles:
* `dooris-authorized`
* `mailing-list-chaos-member`
* `mailing-list-intern-member`
* `export-dooris-ssh-keys`
* `export-mailing-list-addresses`
* `dooris-authorized` to assign to users whose SSH keys should be exported
* `mailing-list-chaos-member` to assign to users who are a member of the chaos mailing list
* `mailing-list-intern-member` to assign to users who are a member of the intern mailing list
* `export-dooris-ssh-keys` to assign to service account users that should be allowed to use the dooris endpoint config
* `export-mailing-list-addresses` to assign to service account users that should be allowed to use the mailing list endpoint configs
* Groups:
* `chaos` with role `mailing-list-chaos-member`
* `ìntern` with roles `dooris-authorized` and `mailing-list-intern-member`
* `ìntern` with roles `dooris-authorized`, `mailing-list-chaos-member` and `mailing-list-intern-member`
* Users:
* `tester` (Tony Tester), email `tester@example.com`, member of group `chaos`
* Mailing List Addresses:
@ -81,7 +103,7 @@ The realm contains these objects:
* `mailing-list-address-chaos`
* Attribute Group `mailing-list-addresses`
* `mailing-list-address-intern`
* Attribute Group `mailing-list-intern`
* Attribute Group `mailing-list-addresses`
* `ssh-key-1`
* Attribute Group `dooris-ssh-keys`
* `ssh-key-2`