|
|
@ -57,6 +57,7 @@ def test_keycloak_admin_init(env: KeycloakTestEnv) -> None: |
|
|
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, |
|
|
password=env.keycloak_admin_password, |
|
|
password=env.keycloak_admin_password, |
|
|
|
|
|
pool_maxsize=5, |
|
|
) |
|
|
) |
|
|
assert admin.connection.server_url == f"http://{env.keycloak_host}:{env.keycloak_port}", ( |
|
|
assert admin.connection.server_url == f"http://{env.keycloak_host}:{env.keycloak_port}", ( |
|
|
admin.connection.server_url |
|
|
admin.connection.server_url |
|
|
@ -72,6 +73,7 @@ def test_keycloak_admin_init(env: KeycloakTestEnv) -> None: |
|
|
assert admin.connection.token is None, admin.connection.token |
|
|
assert admin.connection.token is None, admin.connection.token |
|
|
assert admin.connection.user_realm_name is None, admin.connection.user_realm_name |
|
|
assert admin.connection.user_realm_name is None, admin.connection.user_realm_name |
|
|
assert admin.connection.custom_headers is None, admin.connection.custom_headers |
|
|
assert admin.connection.custom_headers is None, admin.connection.custom_headers |
|
|
|
|
|
assert admin.connection.pool_maxsize == 5, admin.connection.pool_maxsize |
|
|
|
|
|
|
|
|
admin = KeycloakAdmin( |
|
|
admin = KeycloakAdmin( |
|
|
server_url=f"http://{env.keycloak_host}:{env.keycloak_port}", |
|
|
server_url=f"http://{env.keycloak_host}:{env.keycloak_port}", |
|
|
@ -2622,7 +2624,7 @@ def test_auth_flows(admin: KeycloakAdmin, realm: str) -> None: |
|
|
|
|
|
|
|
|
# Test flow executions |
|
|
# Test flow executions |
|
|
res = admin.get_authentication_flow_executions(flow_alias="browser") |
|
|
res = admin.get_authentication_flow_executions(flow_alias="browser") |
|
|
assert len(res) in [8, 12, 14], res |
|
|
|
|
|
|
|
|
assert len(res) in [8, 12, 14, 15], res |
|
|
|
|
|
|
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
admin.get_authentication_flow_executions(flow_alias="bad") |
|
|
admin.get_authentication_flow_executions(flow_alias="bad") |
|
|
@ -2765,7 +2767,7 @@ def test_authentication_configs(admin: KeycloakAdmin, realm: str) -> None: |
|
|
|
|
|
|
|
|
# Test list of auth providers |
|
|
# Test list of auth providers |
|
|
res = admin.get_authenticator_providers() |
|
|
res = admin.get_authenticator_providers() |
|
|
assert len(res) <= 41 |
|
|
|
|
|
|
|
|
assert len(res) <= 42 |
|
|
|
|
|
|
|
|
res = admin.get_authenticator_provider_config_description(provider_id="auth-cookie") |
|
|
res = admin.get_authenticator_provider_config_description(provider_id="auth-cookie") |
|
|
assert res == { |
|
|
assert res == { |
|
|
@ -3328,7 +3330,7 @@ def test_get_bruteforce_status_for_user( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
admin.change_current_realm(realm) |
|
|
admin.change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -3366,7 +3368,7 @@ def test_clear_bruteforce_attempts_for_user( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
admin.change_current_realm(realm) |
|
|
admin.change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -3407,7 +3409,7 @@ def test_clear_bruteforce_attempts_for_all_users( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
admin.change_current_realm(realm) |
|
|
admin.change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -3568,7 +3570,7 @@ def test_initial_access_token( |
|
|
assert res["count"] == 2 |
|
|
assert res["count"] == 2 |
|
|
assert res["expiration"] == 3 |
|
|
assert res["expiration"] == 3 |
|
|
|
|
|
|
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, _, _ = oid_with_credentials |
|
|
|
|
|
|
|
|
client = str(uuid.uuid4()) |
|
|
client = str(uuid.uuid4()) |
|
|
secret = str(uuid.uuid4()) |
|
|
secret = str(uuid.uuid4()) |
|
|
@ -6328,7 +6330,7 @@ async def test_a_auth_flows(admin: KeycloakAdmin, realm: str) -> None: |
|
|
|
|
|
|
|
|
# Test flow executions |
|
|
# Test flow executions |
|
|
res = await admin.a_get_authentication_flow_executions(flow_alias="browser") |
|
|
res = await admin.a_get_authentication_flow_executions(flow_alias="browser") |
|
|
assert len(res) in [8, 12, 14], res |
|
|
|
|
|
|
|
|
assert len(res) in [8, 12, 14, 15], res |
|
|
|
|
|
|
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
with pytest.raises(KeycloakGetError) as err: |
|
|
await admin.a_get_authentication_flow_executions(flow_alias="bad") |
|
|
await admin.a_get_authentication_flow_executions(flow_alias="bad") |
|
|
@ -6476,7 +6478,7 @@ async def test_a_authentication_configs(admin: KeycloakAdmin, realm: str) -> Non |
|
|
|
|
|
|
|
|
# Test list of auth providers |
|
|
# Test list of auth providers |
|
|
res = await admin.a_get_authenticator_providers() |
|
|
res = await admin.a_get_authenticator_providers() |
|
|
assert len(res) <= 41 |
|
|
|
|
|
|
|
|
assert len(res) <= 42 |
|
|
|
|
|
|
|
|
res = await admin.a_get_authenticator_provider_config_description(provider_id="auth-cookie") |
|
|
res = await admin.a_get_authenticator_provider_config_description(provider_id="auth-cookie") |
|
|
assert res == { |
|
|
assert res == { |
|
|
@ -7062,7 +7064,7 @@ async def test_a_get_bruteforce_status_for_user( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
await admin.a_change_current_realm(realm) |
|
|
await admin.a_change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -7101,7 +7103,7 @@ async def test_a_clear_bruteforce_attempts_for_user( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
await admin.a_change_current_realm(realm) |
|
|
await admin.a_change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -7143,7 +7145,7 @@ async def test_a_clear_bruteforce_attempts_for_all_users( |
|
|
:param realm: Keycloak realm |
|
|
:param realm: Keycloak realm |
|
|
:type realm: str |
|
|
:type realm: str |
|
|
""" |
|
|
""" |
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, username, _ = oid_with_credentials |
|
|
await admin.a_change_current_realm(realm) |
|
|
await admin.a_change_current_realm(realm) |
|
|
|
|
|
|
|
|
# Turn on bruteforce protection |
|
|
# Turn on bruteforce protection |
|
|
@ -7317,7 +7319,7 @@ async def test_a_initial_access_token( |
|
|
assert res["count"] == 2 |
|
|
assert res["count"] == 2 |
|
|
assert res["expiration"] == 3 |
|
|
assert res["expiration"] == 3 |
|
|
|
|
|
|
|
|
oid, username, password = oid_with_credentials |
|
|
|
|
|
|
|
|
oid, _, _ = oid_with_credentials |
|
|
|
|
|
|
|
|
client = str(uuid.uuid4()) |
|
|
client = str(uuid.uuid4()) |
|
|
secret = str(uuid.uuid4()) |
|
|
secret = str(uuid.uuid4()) |
|
|
|