Just a quick example on how to test a particular RHSSO instance with Python unittest library.
-
Python 3
-
KCAPI: Make sure you have installed the Keycloak API (kcapi).
pip install kcapi
This example tests that there is a realm called frankfurt
(can be changed see instructions below) and that inside this realm there is the following components:
- A general role called
offline_access
(Almost always succeed because is a role created by RHSSO) - A client named
MyClient
exists and is not public.
To test it make sure to spin up a RHSSO in the cloud via (Openshift Online). Once you got it running change go to the test file inside the test folder and change these parameters to target your deployment:
def setUp(self):
# This could be environment variables.
ENDPOINT = "https://sso-cvaldezr-dev.apps.sandbox-m3.1530.p1.openshiftapps.com"
USER = "admin"
PASSWORD = "admin"
self.REALM = "frankfurt"
Where ENDPOINT
is the URL of your running RHSSO instance and self.REALM
allow you to check for the same conditions but in other realms.
Disclaimer: these tests only work with HTTPS at the moment.
To run the test you just need to get into the project root folder and run:
python3 -m unittest discover test -v