|
@ -22,7 +22,11 @@ def test_keycloak_version(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_keycloak_admin_bad_init(env): |
|
|
def test_keycloak_admin_bad_init(env): |
|
|
"""Test keycloak admin bad init.""" |
|
|
|
|
|
|
|
|
"""Test keycloak admin bad init. |
|
|
|
|
|
|
|
|
|
|
|
:param env: Environment fixture |
|
|
|
|
|
:type env: KeycloakTestEnv |
|
|
|
|
|
""" |
|
|
with pytest.raises(TypeError) as err: |
|
|
with pytest.raises(TypeError) as err: |
|
|
KeycloakAdmin( |
|
|
KeycloakAdmin( |
|
|
server_url=f"http://{env.KEYCLOAK_HOST}:{env.KEYCLOAK_PORT}", |
|
|
server_url=f"http://{env.KEYCLOAK_HOST}:{env.KEYCLOAK_PORT}", |
|
@ -43,7 +47,11 @@ def test_keycloak_admin_bad_init(env): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_keycloak_admin_init(env): |
|
|
def test_keycloak_admin_init(env): |
|
|
"""Test keycloak admin init.""" |
|
|
|
|
|
|
|
|
"""Test keycloak admin init. |
|
|
|
|
|
|
|
|
|
|
|
:param env: Environment fixture |
|
|
|
|
|
:type env: KeycloakTestEnv |
|
|
|
|
|
""" |
|
|
admin = KeycloakAdmin( |
|
|
admin = KeycloakAdmin( |
|
|
server_url=f"http://{env.KEYCLOAK_HOST}:{env.KEYCLOAK_PORT}", |
|
|
server_url=f"http://{env.KEYCLOAK_HOST}:{env.KEYCLOAK_PORT}", |
|
|
username=env.KEYCLOAK_ADMIN, |
|
|
username=env.KEYCLOAK_ADMIN, |
|
@ -118,7 +126,11 @@ def test_keycloak_admin_init(env): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_realms(admin: KeycloakAdmin): |
|
|
def test_realms(admin: KeycloakAdmin): |
|
|
"""Test realms.""" |
|
|
|
|
|
|
|
|
"""Test realms. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
""" |
|
|
# Get realms |
|
|
# Get realms |
|
|
realms = admin.get_realms() |
|
|
realms = admin.get_realms() |
|
|
assert len(realms) == 1, realms |
|
|
assert len(realms) == 1, realms |
|
@ -183,7 +195,13 @@ def test_realms(admin: KeycloakAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_import_export_realms(admin: KeycloakAdmin, realm: str): |
|
|
def test_import_export_realms(admin: KeycloakAdmin, realm: str): |
|
|
"""Test import and export of realms.""" |
|
|
|
|
|
|
|
|
"""Test import and export of realms. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
realm_export = admin.export_realm(export_clients=True, export_groups_and_role=True) |
|
|
realm_export = admin.export_realm(export_clients=True, export_groups_and_role=True) |
|
@ -201,7 +219,13 @@ def test_import_export_realms(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_users(admin: KeycloakAdmin, realm: str): |
|
|
def test_users(admin: KeycloakAdmin, realm: str): |
|
|
"""Test users.""" |
|
|
|
|
|
|
|
|
"""Test users. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Check no users present |
|
|
# Check no users present |
|
@ -293,7 +317,13 @@ def test_users(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_users_pagination(admin: KeycloakAdmin, realm: str): |
|
|
def test_users_pagination(admin: KeycloakAdmin, realm: str): |
|
|
"""Test user pagination.""" |
|
|
|
|
|
|
|
|
"""Test user pagination. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
for ind in range(admin.PAGE_SIZE + 50): |
|
|
for ind in range(admin.PAGE_SIZE + 50): |
|
@ -311,7 +341,13 @@ def test_users_pagination(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_idps(admin: KeycloakAdmin, realm: str): |
|
|
def test_idps(admin: KeycloakAdmin, realm: str): |
|
|
"""Test IDPs.""" |
|
|
|
|
|
|
|
|
"""Test IDPs. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Create IDP |
|
|
# Create IDP |
|
@ -383,7 +419,13 @@ def test_idps(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_user_credentials(admin: KeycloakAdmin, user: str): |
|
|
def test_user_credentials(admin: KeycloakAdmin, user: str): |
|
|
"""Test user credentials.""" |
|
|
|
|
|
|
|
|
"""Test user credentials. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param user: Keycloak user |
|
|
|
|
|
:type user: str |
|
|
|
|
|
""" |
|
|
res = admin.set_user_password(user_id=user, password="booya", temporary=True) |
|
|
res = admin.set_user_password(user_id=user, password="booya", temporary=True) |
|
|
assert res == dict(), res |
|
|
assert res == dict(), res |
|
|
|
|
|
|
|
@ -411,7 +453,13 @@ def test_user_credentials(admin: KeycloakAdmin, user: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_social_logins(admin: KeycloakAdmin, user: str): |
|
|
def test_social_logins(admin: KeycloakAdmin, user: str): |
|
|
"""Test social logins.""" |
|
|
|
|
|
|
|
|
"""Test social logins. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param user: Keycloak user |
|
|
|
|
|
:type user: str |
|
|
|
|
|
""" |
|
|
res = admin.add_user_social_login( |
|
|
res = admin.add_user_social_login( |
|
|
user_id=user, provider_id="gitlab", provider_userid="test", provider_username="test" |
|
|
user_id=user, provider_id="gitlab", provider_userid="test", provider_username="test" |
|
|
) |
|
|
) |
|
@ -451,7 +499,11 @@ def test_social_logins(admin: KeycloakAdmin, user: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_server_info(admin: KeycloakAdmin): |
|
|
def test_server_info(admin: KeycloakAdmin): |
|
|
"""Test server info.""" |
|
|
|
|
|
|
|
|
"""Test server info. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
""" |
|
|
info = admin.get_server_info() |
|
|
info = admin.get_server_info() |
|
|
assert set(info.keys()) == { |
|
|
assert set(info.keys()) == { |
|
|
"systemInfo", |
|
|
"systemInfo", |
|
@ -471,7 +523,13 @@ def test_server_info(admin: KeycloakAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_groups(admin: KeycloakAdmin, user: str): |
|
|
def test_groups(admin: KeycloakAdmin, user: str): |
|
|
"""Test groups.""" |
|
|
|
|
|
|
|
|
"""Test groups. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param user: Keycloak user |
|
|
|
|
|
:type user: str |
|
|
|
|
|
""" |
|
|
# Test get groups |
|
|
# Test get groups |
|
|
groups = admin.get_groups() |
|
|
groups = admin.get_groups() |
|
|
assert len(groups) == 0 |
|
|
assert len(groups) == 0 |
|
@ -615,7 +673,13 @@ def test_groups(admin: KeycloakAdmin, user: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_clients(admin: KeycloakAdmin, realm: str): |
|
|
def test_clients(admin: KeycloakAdmin, realm: str): |
|
|
"""Test clients.""" |
|
|
|
|
|
|
|
|
"""Test clients. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Test get clients |
|
|
# Test get clients |
|
@ -875,7 +939,13 @@ def test_clients(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_realm_roles(admin: KeycloakAdmin, realm: str): |
|
|
def test_realm_roles(admin: KeycloakAdmin, realm: str): |
|
|
"""Test realm roles.""" |
|
|
|
|
|
|
|
|
"""Test realm roles. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Test get realm roles |
|
|
# Test get realm roles |
|
@ -1031,7 +1101,13 @@ def test_realm_roles(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_client_roles(admin: KeycloakAdmin, client: str): |
|
|
def test_client_roles(admin: KeycloakAdmin, client: str): |
|
|
"""Test client roles.""" |
|
|
|
|
|
|
|
|
"""Test client roles. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param client: Keycloak client |
|
|
|
|
|
:type client: str |
|
|
|
|
|
""" |
|
|
# Test get client roles |
|
|
# Test get client roles |
|
|
res = admin.get_client_roles(client_id=client) |
|
|
res = admin.get_client_roles(client_id=client) |
|
|
assert len(res) == 0 |
|
|
assert len(res) == 0 |
|
@ -1194,7 +1270,14 @@ def test_client_roles(admin: KeycloakAdmin, client: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_enable_token_exchange(admin: KeycloakAdmin, realm: str): |
|
|
def test_enable_token_exchange(admin: KeycloakAdmin, realm: str): |
|
|
"""Test enable token exchange.""" |
|
|
|
|
|
|
|
|
"""Test enable token exchange. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
:raises AssertionError: In case of bad configuration |
|
|
|
|
|
""" |
|
|
# Test enabling token exchange between two confidential clients |
|
|
# Test enabling token exchange between two confidential clients |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
@ -1283,7 +1366,13 @@ def test_enable_token_exchange(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_email(admin: KeycloakAdmin, user: str): |
|
|
def test_email(admin: KeycloakAdmin, user: str): |
|
|
"""Test email.""" |
|
|
|
|
|
|
|
|
"""Test email. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param user: Keycloak user |
|
|
|
|
|
:type user: str |
|
|
|
|
|
""" |
|
|
# Emails will fail as we don't have SMTP test setup |
|
|
# Emails will fail as we don't have SMTP test setup |
|
|
with pytest.raises(KeycloakPutError) as err: |
|
|
with pytest.raises(KeycloakPutError) as err: |
|
|
admin.send_update_account(user_id=user, payload=dict()) |
|
|
admin.send_update_account(user_id=user, payload=dict()) |
|
@ -1296,7 +1385,11 @@ def test_email(admin: KeycloakAdmin, user: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_sessions(admin: KeycloakAdmin): |
|
|
def test_get_sessions(admin: KeycloakAdmin): |
|
|
"""Test get sessions.""" |
|
|
|
|
|
|
|
|
"""Test get sessions. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
""" |
|
|
sessions = admin.get_sessions(user_id=admin.get_user_id(username=admin.username)) |
|
|
sessions = admin.get_sessions(user_id=admin.get_user_id(username=admin.username)) |
|
|
assert len(sessions) >= 1 |
|
|
assert len(sessions) >= 1 |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
@ -1305,7 +1398,13 @@ def test_get_sessions(admin: KeycloakAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_client_installation_provider(admin: KeycloakAdmin, client: str): |
|
|
def test_get_client_installation_provider(admin: KeycloakAdmin, client: str): |
|
|
"""Test get client installation provider.""" |
|
|
|
|
|
|
|
|
"""Test get client installation provider. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param client: Keycloak client |
|
|
|
|
|
:type client: str |
|
|
|
|
|
""" |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
admin.get_client_installation_provider(client_id=client, provider_id="bad") |
|
|
admin.get_client_installation_provider(client_id=client, provider_id="bad") |
|
|
assert err.match('404: b\'{"error":"Unknown Provider"}\'') |
|
|
assert err.match('404: b\'{"error":"Unknown Provider"}\'') |
|
@ -1324,7 +1423,13 @@ def test_get_client_installation_provider(admin: KeycloakAdmin, client: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_auth_flows(admin: KeycloakAdmin, realm: str): |
|
|
def test_auth_flows(admin: KeycloakAdmin, realm: str): |
|
|
"""Test auth flows.""" |
|
|
|
|
|
|
|
|
"""Test auth flows. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
res = admin.get_authentication_flows() |
|
|
res = admin.get_authentication_flows() |
|
@ -1471,7 +1576,13 @@ def test_auth_flows(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_authentication_configs(admin: KeycloakAdmin, realm: str): |
|
|
def test_authentication_configs(admin: KeycloakAdmin, realm: str): |
|
|
"""Test authentication configs.""" |
|
|
|
|
|
|
|
|
"""Test authentication configs. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Test list of auth providers |
|
|
# Test list of auth providers |
|
@ -1503,7 +1614,13 @@ def test_authentication_configs(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_users(admin: KeycloakAdmin, realm: str): |
|
|
def test_sync_users(admin: KeycloakAdmin, realm: str): |
|
|
"""Test sync users.""" |
|
|
|
|
|
|
|
|
"""Test sync users. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Only testing the error message |
|
|
# Only testing the error message |
|
@ -1513,7 +1630,13 @@ def test_sync_users(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_client_scopes(admin: KeycloakAdmin, realm: str): |
|
|
def test_client_scopes(admin: KeycloakAdmin, realm: str): |
|
|
"""Test client scopes.""" |
|
|
|
|
|
|
|
|
"""Test client scopes. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Test get client scopes |
|
|
# Test get client scopes |
|
@ -1651,7 +1774,13 @@ def test_client_scopes(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_components(admin: KeycloakAdmin, realm: str): |
|
|
def test_components(admin: KeycloakAdmin, realm: str): |
|
|
"""Test components.""" |
|
|
|
|
|
|
|
|
"""Test components. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
# Test get components |
|
|
# Test get components |
|
@ -1702,7 +1831,13 @@ def test_components(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_keys(admin: KeycloakAdmin, realm: str): |
|
|
def test_keys(admin: KeycloakAdmin, realm: str): |
|
|
"""Test keys.""" |
|
|
|
|
|
|
|
|
"""Test keys. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
assert set(admin.get_keys()["active"].keys()) == {"AES", "HS256", "RS256", "RSA-OAEP"} |
|
|
assert set(admin.get_keys()["active"].keys()) == {"AES", "HS256", "RS256", "RSA-OAEP"} |
|
|
assert {k["algorithm"] for k in admin.get_keys()["keys"]} == { |
|
|
assert {k["algorithm"] for k in admin.get_keys()["keys"]} == { |
|
@ -1714,7 +1849,13 @@ def test_keys(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_events(admin: KeycloakAdmin, realm: str): |
|
|
def test_events(admin: KeycloakAdmin, realm: str): |
|
|
"""Test events.""" |
|
|
|
|
|
|
|
|
"""Test events. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
|
|
|
|
|
|
events = admin.get_events() |
|
|
events = admin.get_events() |
|
@ -1734,7 +1875,13 @@ def test_events(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_auto_refresh(admin: KeycloakAdmin, realm: str): |
|
|
def test_auto_refresh(admin: KeycloakAdmin, realm: str): |
|
|
"""Test auto refresh token.""" |
|
|
|
|
|
|
|
|
"""Test auto refresh token. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
# Test get refresh |
|
|
# Test get refresh |
|
|
admin.auto_refresh_token = list() |
|
|
admin.auto_refresh_token = list() |
|
|
admin.connection = ConnectionManager( |
|
|
admin.connection = ConnectionManager( |
|
@ -1818,7 +1965,13 @@ def test_auto_refresh(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_required_actions(admin: KeycloakAdmin, realm: str): |
|
|
def test_get_required_actions(admin: KeycloakAdmin, realm: str): |
|
|
"""Test required actions.""" |
|
|
|
|
|
|
|
|
"""Test required actions. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
ractions = admin.get_required_actions() |
|
|
ractions = admin.get_required_actions() |
|
|
assert isinstance(ractions, list) |
|
|
assert isinstance(ractions, list) |
|
@ -1836,7 +1989,13 @@ def test_get_required_actions(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_required_action_by_alias(admin: KeycloakAdmin, realm: str): |
|
|
def test_get_required_action_by_alias(admin: KeycloakAdmin, realm: str): |
|
|
"""Test get required action by alias.""" |
|
|
|
|
|
|
|
|
"""Test get required action by alias. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
ractions = admin.get_required_actions() |
|
|
ractions = admin.get_required_actions() |
|
|
ra = admin.get_required_action_by_alias("UPDATE_PASSWORD") |
|
|
ra = admin.get_required_action_by_alias("UPDATE_PASSWORD") |
|
@ -1846,7 +2005,13 @@ def test_get_required_action_by_alias(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_required_action(admin: KeycloakAdmin, realm: str): |
|
|
def test_update_required_action(admin: KeycloakAdmin, realm: str): |
|
|
"""Test update required action.""" |
|
|
|
|
|
|
|
|
"""Test update required action. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
ra = admin.get_required_action_by_alias("UPDATE_PASSWORD") |
|
|
ra = admin.get_required_action_by_alias("UPDATE_PASSWORD") |
|
|
old = copy.deepcopy(ra) |
|
|
old = copy.deepcopy(ra) |
|
@ -1860,7 +2025,19 @@ def test_update_required_action(admin: KeycloakAdmin, realm: str): |
|
|
def test_get_composite_client_roles_of_group( |
|
|
def test_get_composite_client_roles_of_group( |
|
|
admin: KeycloakAdmin, realm: str, client: str, group: str, composite_client_role: str |
|
|
admin: KeycloakAdmin, realm: str, client: str, group: str, composite_client_role: str |
|
|
): |
|
|
): |
|
|
"""Test get composite client roles of group.""" |
|
|
|
|
|
|
|
|
"""Test get composite client roles of group. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
:param client: Keycloak client |
|
|
|
|
|
:type client: str |
|
|
|
|
|
:param group: Keycloak group |
|
|
|
|
|
:type group: str |
|
|
|
|
|
:param composite_client_role: Composite client role |
|
|
|
|
|
:type composite_client_role: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
role = admin.get_client_role(client, composite_client_role) |
|
|
role = admin.get_client_role(client, composite_client_role) |
|
|
admin.assign_group_client_roles(group_id=group, client_id=client, roles=[role]) |
|
|
admin.assign_group_client_roles(group_id=group, client_id=client, roles=[role]) |
|
@ -1871,7 +2048,19 @@ def test_get_composite_client_roles_of_group( |
|
|
def test_get_role_client_level_children( |
|
|
def test_get_role_client_level_children( |
|
|
admin: KeycloakAdmin, realm: str, client: str, composite_client_role: str, client_role: str |
|
|
admin: KeycloakAdmin, realm: str, client: str, composite_client_role: str, client_role: str |
|
|
): |
|
|
): |
|
|
"""Test get children of composite client role.""" |
|
|
|
|
|
|
|
|
"""Test get children of composite client role. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
:param client: Keycloak client |
|
|
|
|
|
:type client: str |
|
|
|
|
|
:param composite_client_role: Composite client role |
|
|
|
|
|
:type composite_client_role: str |
|
|
|
|
|
:param client_role: Client role |
|
|
|
|
|
:type client_role: str |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
child = admin.get_client_role(client, client_role) |
|
|
child = admin.get_client_role(client, client_role) |
|
|
parent = admin.get_client_role(client, composite_client_role) |
|
|
parent = admin.get_client_role(client, composite_client_role) |
|
@ -1880,7 +2069,17 @@ def test_get_role_client_level_children( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_upload_certificate(admin: KeycloakAdmin, realm: str, client: str, selfsigned_cert: tuple): |
|
|
def test_upload_certificate(admin: KeycloakAdmin, realm: str, client: str, selfsigned_cert: tuple): |
|
|
"""Test upload certificate.""" |
|
|
|
|
|
|
|
|
"""Test upload certificate. |
|
|
|
|
|
|
|
|
|
|
|
:param admin: Keycloak Admin client |
|
|
|
|
|
:type admin: KeycloakAdmin |
|
|
|
|
|
:param realm: Keycloak realm |
|
|
|
|
|
:type realm: str |
|
|
|
|
|
:param client: Keycloak client |
|
|
|
|
|
:type client: str |
|
|
|
|
|
:param selfsigned_cert: Selfsigned certificates |
|
|
|
|
|
:type selfsigned_cert: tuple |
|
|
|
|
|
""" |
|
|
admin.realm_name = realm |
|
|
admin.realm_name = realm |
|
|
cert, _ = selfsigned_cert |
|
|
cert, _ = selfsigned_cert |
|
|
cert = cert.decode("utf-8").strip() |
|
|
cert = cert.decode("utf-8").strip() |
|
|