recovery: add test for invalid key

This commit is contained in:
Jens Langhammer 2020-12-13 18:46:36 +01:00
parent e818416863
commit 32f5d5ba72
2 changed files with 7 additions and 9 deletions

View file

@ -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"""

View file

@ -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)