kanidm/pykanidm/tests/test_radius_check_vlan.py

54 lines
1.1 KiB
Python
Raw Normal View History

2024-09-10 02:36:50 +02:00
"""tests the check_vlan function"""
2022-09-29 02:08:15 +02:00
2024-09-10 02:36:50 +02:00
import asyncio
2022-09-29 02:08:15 +02:00
from typing import Any
import pytest
from kanidm import KanidmClient
from kanidm.types import KanidmClientConfig, RadiusTokenGroup
2022-10-02 03:28:58 +02:00
from kanidm.radius.utils import check_vlan
2022-09-29 02:08:15 +02:00
@pytest.mark.asyncio
2024-09-10 02:36:50 +02:00
async def test_check_vlan() -> None:
2022-09-29 02:08:15 +02:00
"""test 1"""
2024-09-10 02:36:50 +02:00
# event_loop = asyncio.get_running_loop()
2022-09-29 02:08:15 +02:00
testconfig = KanidmClientConfig.parse_toml(
"""
uri='https://kanidm.example.com'
radius_groups = [
2022-10-02 03:28:58 +02:00
{ spn = "crabz@example.com", "vlan" = 1234 },
{ spn = "hello@world", "vlan" = 12345 },
2022-09-29 02:08:15 +02:00
]
"""
)
print(f"{testconfig=}")
kanidm_client = KanidmClient(
config=testconfig,
)
print(f"{kanidm_client.config=}")
assert (
check_vlan(
acc=12345678,
2022-10-02 03:28:58 +02:00
group=RadiusTokenGroup(spn="crabz@example.com", uuid="crabz"),
2022-09-29 02:08:15 +02:00
kanidm_client=kanidm_client,
)
== 1234
)
assert (
check_vlan(
acc=12345678,
group=RadiusTokenGroup(spn="foo@bar.com", uuid="lol"),
kanidm_client=kanidm_client,
)
== 12345678
)