e2e: fix tests using promptstages

This commit is contained in:
Jens Langhammer 2020-09-09 18:38:49 +02:00
parent 2d6b57839d
commit a7be0379f4
1 changed files with 14 additions and 19 deletions

View File

@ -12,7 +12,6 @@ from docker.types import Healthcheck
from e2e.utils import USER, SeleniumTestCase from e2e.utils import USER, SeleniumTestCase
from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding
from passbook.policies.expression.models import ExpressionPolicy from passbook.policies.expression.models import ExpressionPolicy
from passbook.policies.models import PolicyBinding
from passbook.stages.email.models import EmailStage, EmailTemplates from passbook.stages.email.models import EmailStage, EmailTemplates
from passbook.stages.identification.models import IdentificationStage from passbook.stages.identification.models import IdentificationStage
from passbook.stages.prompt.models import FieldTypes, Prompt, PromptStage from passbook.stages.prompt.models import FieldTypes, Prompt, PromptStage
@ -79,9 +78,16 @@ class TestFlowsEnroll(SeleniumTestCase):
field_key="email", label="E-Mail", order=1, type=FieldTypes.EMAIL field_key="email", label="E-Mail", order=1, type=FieldTypes.EMAIL
) )
# Password checking policy
password_policy = ExpressionPolicy.objects.create(
name="policy-enrollment-password-equals",
expression="return request.context['password'] == request.context['password_repeat']",
)
# Stages # Stages
first_stage = PromptStage.objects.create(name="prompt-stage-first") first_stage = PromptStage.objects.create(name="prompt-stage-first")
first_stage.fields.set([username_prompt, password, password_repeat]) first_stage.fields.set([username_prompt, password, password_repeat])
first_stage.validation_policies.set([password_policy])
first_stage.save() first_stage.save()
second_stage = PromptStage.objects.create(name="prompt-stage-second") second_stage = PromptStage.objects.create(name="prompt-stage-second")
second_stage.fields.set([name_field, email]) second_stage.fields.set([name_field, email])
@ -89,15 +95,6 @@ class TestFlowsEnroll(SeleniumTestCase):
user_write = UserWriteStage.objects.create(name="enroll-user-write") user_write = UserWriteStage.objects.create(name="enroll-user-write")
user_login = UserLoginStage.objects.create(name="enroll-user-login") user_login = UserLoginStage.objects.create(name="enroll-user-login")
# Password checking policy
password_policy = ExpressionPolicy.objects.create(
name="policy-enrollment-password-equals",
expression="return request.context['password'] == request.context['password_repeat']",
)
PolicyBinding.objects.create(
target=first_stage, policy=password_policy, order=0
)
flow = Flow.objects.create( flow = Flow.objects.create(
name="default-enrollment-flow", name="default-enrollment-flow",
slug="default-enrollment-flow", slug="default-enrollment-flow",
@ -174,9 +171,16 @@ class TestFlowsEnroll(SeleniumTestCase):
field_key="email", label="E-Mail", order=1, type=FieldTypes.EMAIL field_key="email", label="E-Mail", order=1, type=FieldTypes.EMAIL
) )
# Password checking policy
password_policy = ExpressionPolicy.objects.create(
name="policy-enrollment-password-equals",
expression="return request.context['password'] == request.context['password_repeat']",
)
# Stages # Stages
first_stage = PromptStage.objects.create(name="prompt-stage-first") first_stage = PromptStage.objects.create(name="prompt-stage-first")
first_stage.fields.set([username_prompt, password, password_repeat]) first_stage.fields.set([username_prompt, password, password_repeat])
first_stage.validation_policies.set([password_policy])
first_stage.save() first_stage.save()
second_stage = PromptStage.objects.create(name="prompt-stage-second") second_stage = PromptStage.objects.create(name="prompt-stage-second")
second_stage.fields.set([name_field, email]) second_stage.fields.set([name_field, email])
@ -190,15 +194,6 @@ class TestFlowsEnroll(SeleniumTestCase):
user_write = UserWriteStage.objects.create(name="enroll-user-write") user_write = UserWriteStage.objects.create(name="enroll-user-write")
user_login = UserLoginStage.objects.create(name="enroll-user-login") user_login = UserLoginStage.objects.create(name="enroll-user-login")
# Password checking policy
password_policy = ExpressionPolicy.objects.create(
name="policy-enrollment-password-equals",
expression="return request.context['password'] == request.context['password_repeat']",
)
PolicyBinding.objects.create(
target=first_stage, policy=password_policy, order=0
)
flow = Flow.objects.create( flow = Flow.objects.create(
name="default-enrollment-flow", name="default-enrollment-flow",
slug="default-enrollment-flow", slug="default-enrollment-flow",