kanidm/kanidm_rlm_python/tests/test_check_vlan.py
James Hodgkinson 805ac2dd16
Python module and rewritten RADIUS integration (#826)
* added python kanidm module
* rewrote RADIUS integration
* updated the documentation
* updating github actions to run more often
* BLEEP BLOOP ASYNCIO IS GR8
* adding config to makefile to run pykanidm tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Firstyear <william@blackhats.net.au>
2022-06-20 20:16:55 +10:00

43 lines
1.1 KiB
Python

""" tests the check_vlan function """
from typing import Any
import aiohttp
import pytest
from kanidm import KanidmClient
from kanidm.types import KanidmClientConfig
from kanidmradius import check_vlan
@pytest.mark.asyncio
async def test_check_vlan(event_loop: Any) -> None:
""" test 1 """
async with aiohttp.ClientSession(loop=event_loop) as session:
testconfig = KanidmClientConfig.parse_toml("""
uri='https://kanidm.example.com'
radius_groups = [
{ name = "crabz", "vlan" = 1234 },
{ name = "hello world", "vlan" = 12345 },
]
""")
print(f"{testconfig=}")
kanidm_client = KanidmClient(
config = testconfig,
session=session,
)
print(f"{kanidm_client.config=}")
assert check_vlan(
acc=12345678,
group={'name' : 'crabz'},
kanidm_client=kanidm_client
) == 1234
assert check_vlan(
acc=12345678,
group={'name' : 'foo'},
kanidm_client=kanidm_client
) == 12345678