recovery: add test for invalid key
This commit is contained in:
parent
e818416863
commit
32f5d5ba72
|
@ -1,15 +1,6 @@
|
||||||
"""Small helper functions"""
|
"""Small helper functions"""
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.http import HttpRequest, HttpResponse
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.template.context import Context
|
|
||||||
|
|
||||||
|
|
||||||
def render_xml(request: HttpRequest, template: str, ctx: Context) -> HttpResponse:
|
|
||||||
"""Render template with content_type application/xml"""
|
|
||||||
return render(request, template, context=ctx, content_type="application/xml")
|
|
||||||
|
|
||||||
|
|
||||||
def get_random_id() -> str:
|
def get_random_id() -> str:
|
||||||
"""Random hex id"""
|
"""Random hex id"""
|
||||||
|
|
|
@ -32,3 +32,10 @@ class TestRecovery(TestCase):
|
||||||
reverse("authentik_recovery:use-token", kwargs={"key": token.key})
|
reverse("authentik_recovery:use-token", kwargs={"key": token.key})
|
||||||
)
|
)
|
||||||
self.assertEqual(int(self.client.session["_auth_user_id"]), token.user.pk)
|
self.assertEqual(int(self.client.session["_auth_user_id"]), token.user.pk)
|
||||||
|
|
||||||
|
def test_recovery_view_invalid(self):
|
||||||
|
"""Test recovery view with invalid token"""
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("authentik_recovery:use-token", kwargs={"key": "abc"})
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
Reference in a new issue