From 32f5d5ba720171918383dc74a6e6935f20211e5a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 13 Dec 2020 18:46:36 +0100 Subject: [PATCH] recovery: add test for invalid key --- authentik/providers/saml/utils/__init__.py | 9 --------- authentik/recovery/tests.py | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/authentik/providers/saml/utils/__init__.py b/authentik/providers/saml/utils/__init__.py index a9487a696..16c18a18e 100644 --- a/authentik/providers/saml/utils/__init__.py +++ b/authentik/providers/saml/utils/__init__.py @@ -1,15 +1,6 @@ """Small helper functions""" 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: """Random hex id""" diff --git a/authentik/recovery/tests.py b/authentik/recovery/tests.py index f696c2c98..39406d49d 100644 --- a/authentik/recovery/tests.py +++ b/authentik/recovery/tests.py @@ -32,3 +32,10 @@ class TestRecovery(TestCase): reverse("authentik_recovery:use-token", kwargs={"key": token.key}) ) 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)