testytest
This commit is contained in:
parent
3034bb3b69
commit
23bdcc7957
6 changed files with 9 additions and 19 deletions
2
Makefile
2
Makefile
|
@ -19,7 +19,7 @@ run:
|
|||
|
||||
|
||||
test:
|
||||
./env/bin/pytest --sw app
|
||||
./env/bin/pytest -s --sw app
|
||||
|
||||
integration:
|
||||
./env/bin/uvicorn app.main:app --reload --host 0.0.0.0
|
||||
|
|
|
@ -165,7 +165,6 @@ class Authentik:
|
|||
r = r["results"][0]
|
||||
|
||||
if "pk" in r:
|
||||
print(r)
|
||||
return User(**r)
|
||||
raise Exception(r)
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ class WekanApi:
|
|||
raise Exception(r)
|
||||
if r == {}:
|
||||
return None
|
||||
print(r)
|
||||
return User(**r)
|
||||
|
||||
def get_all_users(self) -> List[UserBase]:
|
||||
|
@ -75,6 +74,5 @@ class WekanApi:
|
|||
|
||||
def delete_user(self, id: str):
|
||||
r = self.delete(f"users/{id}").json()
|
||||
print(r)
|
||||
if "error" in r:
|
||||
raise Exception(r)
|
||||
|
|
|
@ -25,12 +25,9 @@ def test_get_user(api: WekanApi):
|
|||
def test_get_users(api: WekanApi):
|
||||
assert True if "api" in [u.username for u in api.get_all_users()] else False
|
||||
|
||||
def test_create_user(api: WekanApi):
|
||||
user = api.create_user("foo", "foo@32bar.com", "")
|
||||
def test_create_and_delete_user(api: WekanApi):
|
||||
user = api.create_user("foo", "foo42@bar.com", "")
|
||||
assert api.get_user("foo").username == "foo"
|
||||
assert type(user) is User
|
||||
|
||||
def test_delete_user(api: WekanApi):
|
||||
u = api.create_user("Bar", "foo@bar42.com", "")
|
||||
api.delete_user(u.id)
|
||||
assert api.get_user("Bar") == None
|
||||
api.delete_user(user.id)
|
||||
assert api.get_user("foo") == None
|
||||
|
|
|
@ -36,7 +36,7 @@ def authentik(settings: AuthentikSettings):
|
|||
r = a.create_web_hook(
|
||||
hook_endpoint="http://172.17.0.1:8000/authentik/hook/") # docker localhost
|
||||
except Exception as e:
|
||||
logging.info(e)
|
||||
logging.error(e)
|
||||
return a
|
||||
|
||||
|
||||
|
@ -45,24 +45,21 @@ def authentik_user(authentik):
|
|||
user = authentik.create_user(User(username="foobar", name="Foo Bar", email="foo@bar.com"))
|
||||
yield user
|
||||
authentik.delete_user(user)
|
||||
print("DELETING USER")
|
||||
|
||||
|
||||
|
||||
def test_create_user(mocker, authentik: Authentik, authentik_user: WekanUser, wekan: WekanApi):
|
||||
# Actually this should already trigger the hook, but in authentik it doesn't trigger when come from api
|
||||
def test_create_user(mocker, authentik_user: WekanUser, wekan: WekanApi):
|
||||
# Actually authentik user creation should already trigger the hook, but in authentik it doesn't trigger when come from api
|
||||
# mock = mocker.patch("app.event_controller.EventController.handle_model_created_event")
|
||||
authentik_message = {"model": {"pk": authentik_user.pk, "app": "authentik_core", "name": authentik_user.name,
|
||||
"model_name": "user"}, "http_request": {"args": {}, "path": "/api/v3/core/users/", "method": "POST"}}
|
||||
response = client.post("/authentik/hook/", json=authentik_message)
|
||||
print(response.text)
|
||||
assert response.status_code == 200
|
||||
wu = wekan.get_user(authentik_user.username)
|
||||
assert not wu == None
|
||||
assert wu.username == authentik_user.username
|
||||
assert authentik_user.email in [i.address for i in wu.emails]
|
||||
|
||||
wekan.delete_user(authentik_user.username)
|
||||
wekan.delete_user(wu.id)
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
|
|
|
@ -21,7 +21,6 @@ def test_hook_fails_for_wrong_input():
|
|||
"user_username": "akadmin"
|
||||
}"""
|
||||
response = client.post("/authentik/hook/", data=d)
|
||||
print(response.text)
|
||||
assert response.status_code == 422
|
||||
|
||||
def test_hook_model_created(mocker):
|
||||
|
|
Loading…
Reference in a new issue