stages/email: don't crash when testing stage does not exist
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ae26d2756f
commit
ebf9f0ca63
|
@ -1,7 +1,6 @@
|
|||
"""consent tests"""
|
||||
from time import sleep
|
||||
|
||||
from django.http.response import HttpResponse
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_str
|
||||
from rest_framework.test import APITestCase
|
||||
|
@ -41,12 +40,14 @@ class TestConsentStage(APITestCase):
|
|||
session = self.client.session
|
||||
session[SESSION_KEY_PLAN] = plan
|
||||
session.save()
|
||||
response: HttpResponse = self.client.post(
|
||||
response = self.client.post(
|
||||
reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}),
|
||||
{},
|
||||
)
|
||||
# pylint: disable=no-member
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertJSONEqual(
|
||||
# pylint: disable=no-member
|
||||
force_str(response.content),
|
||||
{
|
||||
"component": "xak-flow-redirect",
|
||||
|
|
|
@ -16,7 +16,11 @@ class Command(BaseCommand): # pragma: no cover
|
|||
"""Send a test-email with global settings"""
|
||||
delete_stage = False
|
||||
if options["stage"]:
|
||||
stage = EmailStage.objects.get(name=options["stage"])
|
||||
stages = EmailStage.objects.filter(name=options["stage"])
|
||||
if not stages.exists():
|
||||
print(f"Stage '{options['stage']}' does not exist")
|
||||
return
|
||||
stage = stages.first()
|
||||
else:
|
||||
stage = EmailStage.objects.create(
|
||||
name=f"temp-global-stage-{uuid4()}", use_global_settings=True
|
||||
|
|
Reference in New Issue