mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
* otel can eprintln kthx * started python integration tests, features * more tests more things * adding heaps more things * updating docs * fixing python test * fixing errors, updating integration test * Add models for OAuth2, Person, ServiceAccount and add missing endpoints * Alias Group to GroupInfo to keep it retrocompatible * Fixed issues from review * adding oauth2rs_get_basic_secret * adding oauth2rs_get_basic_secret * Fixed mypy issues * adding more error logs * updating test scripts and configs * fixing tests and validating things * more errors --------- Co-authored-by: Dogeek <simon.bordeyne@gmail.com>
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import json
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
from kanidm import KanidmClient
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
async def client() -> KanidmClient:
|
|
"""sets up a client with a basic thing"""
|
|
|
|
return KanidmClient(
|
|
config_file=Path(__file__).parent.parent.parent / "examples/config_localhost",
|
|
)
|
|
|
|
|
|
@pytest.mark.network
|
|
@pytest.mark.asyncio
|
|
async def test_oauth2_rs_list(client: KanidmClient) -> None:
|
|
"""tests getting the list of oauth2 resource servers"""
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
print(f"config: {client.config}")
|
|
|
|
username = "admin"
|
|
# change this to be your admin password.
|
|
password = "pdf1Xz8q2QFsMTsvbv2jXNBaSEsDpW9h83ZRsH7dDfsJeJdM"
|
|
|
|
auth_resp = await client.authenticate_password(
|
|
username, password, update_internal_auth_token=True
|
|
)
|
|
if auth_resp.state is None:
|
|
raise ValueError(
|
|
"Failed to authenticate, check the admin password is set right"
|
|
)
|
|
if auth_resp.state.success is None:
|
|
raise ValueError(
|
|
"Failed to authenticate, check the admin password is set right"
|
|
)
|
|
|
|
resource_servers = await client.oauth2_rs_list()
|
|
print("content:")
|
|
print(json.dumps(resource_servers, indent=4))
|
|
|
|
if resource_servers:
|
|
for oauth_rs in resource_servers:
|
|
for mapping in oauth_rs.oauth2_rs_sup_scope_map:
|
|
print(f"oauth2_rs_sup_scope_map: {mapping}")
|
|
user, scopes = mapping.split(":")
|
|
scopes = scopes.replace("{", "[").replace("}", "]")
|
|
scopes = json.loads(scopes)
|
|
print(f"{user=} {scopes=}")
|