Tooling for provisioning LDAP objects to external services.
-
The central service to receive LDAP changes and forward them to subscribed clients.
-
Server side of the provisioning project
-
The provisioning consumer library
-
An example implementation of a client.
Build containers for testing:
docker compose build
Run containers:
docker compose up --detach --remove-orphans
To create a subscription, open http://localhost:7777/docs and find the method called 'Create Subscription'. Enter the following data into the request body:
{
"name": "subscription1",
"realms_topics": [{"realm": "udm", "topic": "groups/group"}],
"request_prefill": true
}
To make a change in the LDAP, open http://localhost:8001.
Enter with:
- Login DN: cn=admin,dc=univention-organization,dc=intranet
- Password: univention
Find an entry with univentionObjectType
= 'groups/group' and modify it.
To retrieve messages for the subscriber, open http://localhost:7777/docs. Find the method named 'Get Subscription Messages' and execute it.
Now, you see the messages, that the subscriber received from the udm-pre-fill process and udm-listener
Ensure that you have poetry
installed.
If desired, set poetry to create a virtualenv in the project directory:
poetry config virtualenvs.in-project true
Install the dependencies:
poetry install --with dev
docker compose up example-client
poetry run pytest tests/unit
or
python3 -m pytest tests/unit
docker compose run --quiet-pull --rm test /app/.venv/bin/python3 -m pytest tests/integration
Copy the example e2e test settings json file:
cp tests/e2e/e2e_settings.json.example tests/e2e/e2e_settings.json
The json file includes all parameters, including credentials for the "local", "dev-env" and "pipeline" environments. This is acceptable because these environments are only run locally and never exposed publicly. Because the "gaia" environment is publicly available we don't put the real credentials for it into the tests/e2e/e2e_settings.json file.
To also run the tests against a gaia deployment,
you need to change all "changeme"
entries in the tests/e2e/e2e_settings.json
to their correct values.
First, start the provisioning-components:
docker compose up --detach --remove-orphans
optimized command:
docker compose up --pull always --build events-and-consumer-api nats1 nats2 nats3 dispatcher prefill udm-listener udm-transformer ldap-notifier udm-rest-api ldap-server
Wait for up to 1 minute for the default LDAP changes to be processed by the dispatcher.
Then run the e2e tests.
poetry run pytest tests/e2e/
optimized command:
poetry shell
pytest -v -p no:cacheprovider tests/e2e/
There is a test container designed to run the e2e tests in docker-compose in a gitlab pipeline. But this can also be executed locally to debug pipeline problems and in case you can't or don't want to install the test dependencies locally,
docker compose run --quiet-pull --rm test /app/.venv/bin/pytest tests/e2e -v --environment pipeline
Start the necessary services via tilt:
tilt up keycloak ldap-server ldap-notifier udm-rest-api stack-data-ums stack-data-swp provisioning provisioning-udm-listener
Limiting the tilt-resources instead of plainly running tilt up
will save time and machine resources.
The provisioning-api and ldap-server are not accessible from the outside.
We can work around that by starting a kubernetes port-forward
:
kubectl port-forward deploy/provisioning-api 7777
kubectl port-forward ldap-server-0 3890:389
The unit- and integration-tests are configured via ENV values. The End to End tests are designed to also run in other environments. (outside the provisioning repository)
the well-known configuration-values for the e2e tests are configured in
tests/e2e/conftest.py
you can specify the environment via a pytest argument:
--environment=ENVIRONMENT
set the environment you are running the tests
in.accepted values are: 'local', 'dev-env', 'pipeline'
and 'gaia'
E.g.:
poetry shell
pytest -v -p no:cacheprovider tests/e2e/ --environment dev-env
Run the pre-commit checks before committing:
docker compose run --rm pre-commit run
Build the sphinx documentation:
docker compose run docs make html