cesarvr / testing_rhsso

Just a quick sample of how to test a RHSSO instance using Python unittest framework and kcapi.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Just a quick example on how to test a particular RHSSO instance with Python unittest library.

Dependencies

  • Python 3

  • KCAPI: Make sure you have installed the Keycloak API (kcapi).

    pip install kcapi

What Does It Test

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.

Configuration

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.

Running the tests

To run the test you just need to get into the project root folder and run:

python3 -m unittest discover test -v

running_tests

About

Just a quick sample of how to test a RHSSO instance using Python unittest framework and kcapi.


Languages

Language:Python 100.0%