stages/captcha: remove dependency on captcha app

This commit is contained in:
Jens Langhammer 2021-02-26 10:13:58 +01:00
parent 535770abbd
commit 1bef659b10
3 changed files with 6 additions and 12 deletions

View File

@ -12,6 +12,7 @@ class CaptchaStageSerializer(StageSerializer):
model = CaptchaStage model = CaptchaStage
fields = StageSerializer.Meta.fields + ["public_key", "private_key"] fields = StageSerializer.Meta.fields + ["public_key", "private_key"]
extra_kwargs = {"private_key": {"write_only": True}}
class CaptchaStageViewSet(ModelViewSet): class CaptchaStageViewSet(ModelViewSet):

View File

@ -1,9 +0,0 @@
"""authentik captcha stage settings"""
# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do
RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
NOCAPTCHA = True
INSTALLED_APPS = ["captcha"]
SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"]

View File

@ -1,5 +1,4 @@
"""captcha tests""" """captcha tests"""
from django.conf import settings
from django.test import Client, TestCase from django.test import Client, TestCase
from django.urls import reverse from django.urls import reverse
from django.utils.encoding import force_str from django.utils.encoding import force_str
@ -11,6 +10,9 @@ from authentik.flows.planner import FlowPlan
from authentik.flows.views import SESSION_KEY_PLAN from authentik.flows.views import SESSION_KEY_PLAN
from authentik.stages.captcha.models import CaptchaStage from authentik.stages.captcha.models import CaptchaStage
# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do
RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
class TestCaptchaStage(TestCase): class TestCaptchaStage(TestCase):
"""Captcha tests""" """Captcha tests"""
@ -29,8 +31,8 @@ class TestCaptchaStage(TestCase):
) )
self.stage = CaptchaStage.objects.create( self.stage = CaptchaStage.objects.create(
name="captcha", name="captcha",
public_key=settings.RECAPTCHA_PUBLIC_KEY, public_key=RECAPTCHA_PUBLIC_KEY,
private_key=settings.RECAPTCHA_PRIVATE_KEY, private_key=RECAPTCHA_PRIVATE_KEY,
) )
FlowStageBinding.objects.create(target=self.flow, stage=self.stage, order=2) FlowStageBinding.objects.create(target=self.flow, stage=self.stage, order=2)