integrate/app/authentik/test_authentik.py

42 lines
1003 B
Python
Raw Normal View History

2022-03-04 18:51:33 +01:00
import email
from .authentik import Authentik
2022-03-06 12:31:12 +01:00
from .models import User
import pytest
2022-03-04 18:51:33 +01:00
2022-03-06 12:31:12 +01:00
@pytest.fixture
def api() -> Authentik:
return Authentik(base="http://localhost:9000/", token="foobar123", )
def test_get_user_by_username(api: Authentik):
u = User(username="akadmin",
name="",
groups=[],
email="",
is_active=True,
attributes={}
)
u = api.get_user(u)
assert not u == None
assert u.username == "akadmin"
2022-03-04 18:51:33 +01:00
2022-03-06 12:31:12 +01:00
def test_create_user(api: Authentik):
# res = a.create_web_hook(hook_endpoint="http://172.17.0.1:8000")
2022-03-04 18:51:33 +01:00
u = User(username="banane",
name="banane",
groups=[],
email="foo@example.org",
is_active=True,
attributes={}
2022-03-06 12:31:12 +01:00
)
if(api.get_user(u)):
api.delete_user(api.get_user(u))
assert api.get_user(u) == None
c = api.create_user(u)
2022-03-04 18:51:33 +01:00
assert u.username == c.username
assert not c.pk == None