Browse Source
test: improved the tests on urls, back to 100%
pull/360/head
Richard Nemeth
2 years ago
No known key found for this signature in database
GPG Key ID: 21C39470DF3DEC39
3 changed files with
12 additions and
3 deletions
-
tests/test_keycloak_admin.py
-
tests/test_keycloak_openid.py
-
tests/test_urls_patterns.py
|
|
@ -1844,6 +1844,7 @@ def test_get_required_action_by_alias(admin: KeycloakAdmin, realm: str): |
|
|
|
ra = admin.get_required_action_by_alias("UPDATE_PASSWORD") |
|
|
|
assert ra in ractions |
|
|
|
assert ra["alias"] == "UPDATE_PASSWORD" |
|
|
|
assert admin.get_required_action_by_alias("does-not-exist") is None |
|
|
|
|
|
|
|
|
|
|
|
def test_update_required_action(admin: KeycloakAdmin, realm: str): |
|
|
|
|
|
@ -106,7 +106,7 @@ def test_auth_url(env, oid: KeycloakOpenID): |
|
|
|
res |
|
|
|
== f"http://{env.KEYCLOAK_HOST}:{env.KEYCLOAK_PORT}/realms/{oid.realm_name}" |
|
|
|
+ f"/protocol/openid-connect/auth?client_id={oid.client_id}&response_type=code" |
|
|
|
+ "&redirect_uri=http://test.test/*&scope=email&state= " |
|
|
|
+ "&redirect_uri=http://test.test/*&scope=email&state=" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
"""Test URL patterns.""" |
|
|
|
|
|
|
|
import inspect |
|
|
|
from keycloak import urls_patterns |
|
|
|
|
|
|
|
|
|
|
@ -15,7 +15,12 @@ def test_correctness_of_patterns(): |
|
|
|
|
|
|
|
# Test that the patterns have unique names |
|
|
|
seen_urls = list() |
|
|
|
for url in urls: |
|
|
|
urls_from_src = [ |
|
|
|
x.split("=")[0].strip() |
|
|
|
for x in inspect.getsource(urls_patterns).splitlines() |
|
|
|
if x.startswith("URL_") |
|
|
|
] |
|
|
|
for url in urls_from_src: |
|
|
|
assert url not in seen_urls, f"The url pattern {url} is present twice." |
|
|
|
seen_urls.append(url) |
|
|
|
|
|
|
@ -24,4 +29,7 @@ def test_correctness_of_patterns(): |
|
|
|
for url in urls: |
|
|
|
url_value = urls_patterns.__dict__[url] |
|
|
|
assert url_value not in seen_url_values, f"The url {url} has a duplicate value {url_value}" |
|
|
|
assert ( |
|
|
|
url_value == url_value.strip() |
|
|
|
), f"The url {url} with value '{url_value}' has whitespace values" |
|
|
|
seen_url_values.append(url_value) |