def test_realm(monkeypatch): monkeypatch.setenv('USERNAME', 'admin') monkeypatch.setenv('PASSWORD', 'admin') bootstrap.wait_for_keycloak() tok = bootstrap.get_token() bootstrap.create_realm('testrealm', token=tok) # cleanup bootstrap.delete_realm('testrealm', token=tok)
def test_bootstrap(monkeypatch): monkeypatch.setenv('USERNAME', 'admin') monkeypatch.setenv('PASSWORD', 'admin') monkeypatch.setenv('KEYCLOAK_REALM', 'testrealm') monkeypatch.setenv('KEYCLOAK_CLIENT_ID', 'testclient') bootstrap.bootstrap() # cleanup tok = bootstrap.get_token() bootstrap.delete_service_role('testclient', token=tok) bootstrap.delete_realm('testrealm', token=tok)
def keycloak_bootstrap(monkeypatch): monkeypatch.setenv('KEYCLOAK_REALM', 'testrealm') monkeypatch.setenv('KEYCLOAK_CLIENT_ID', 'testclient') monkeypatch.setenv('USERNAME', 'admin') monkeypatch.setenv('PASSWORD', 'admin') secret = bootstrap.bootstrap() monkeypatch.setenv('KEYCLOAK_CLIENT_SECRET', secret) token = partial(get_token, os.environ['KEYCLOAK_URL'], client_id='testclient', client_secret=secret, ) rest_client = RestClient( f'{os.environ["KEYCLOAK_URL"]}/auth/admin/realms/testrealm', token=token, retries=0, ) yield rest_client tok = bootstrap.get_token() bootstrap.delete_service_role('testclient', token=tok) bootstrap.delete_realm('testrealm', token=tok)