integrate/app/authentik/test_authentik.py
Philipp Rothmann a113ffdfda fix tests
2022-03-06 15:29:00 +01:00

41 lines
942 B
Python

import email
import logging
from .api import Authentik
from .models import User
import pytest
@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"
def test_create_user(api: Authentik):
u = User(username="banane",
name="banane",
groups=[],
email="foo@example.org",
is_active=True,
attributes={}
)
if(api.get_user(u)):
api.delete_user(api.get_user(u))
assert api.get_user(u) == None
c = api.create_user(u)
assert u.username == c.username
assert not c.pk == None