stages/user_delete: fix missing API, fix missing tests

This commit is contained in:
Jens Langhammer 2020-05-13 23:20:07 +02:00
parent 19cb310446
commit f289025d8e
3 changed files with 18 additions and 1 deletions

View File

@ -37,6 +37,7 @@ from passbook.stages.invitation.api import InvitationStageViewSet, InvitationVie
from passbook.stages.otp.api import OTPStageViewSet
from passbook.stages.password.api import PasswordStageViewSet
from passbook.stages.prompt.api import PromptStageViewSet, PromptViewSet
from passbook.stages.user_delete.api import UserDeleteStageViewSet
from passbook.stages.user_login.api import UserLoginStageViewSet
from passbook.stages.user_logout.api import UserLogoutStageViewSet
from passbook.stages.user_write.api import UserWriteStageViewSet
@ -88,6 +89,7 @@ router.register("stages/otp", OTPStageViewSet)
router.register("stages/password", PasswordStageViewSet)
router.register("stages/prompt/stages", PromptStageViewSet)
router.register("stages/prompt/prompts", PromptViewSet)
router.register("stages/user_delete", UserDeleteStageViewSet)
router.register("stages/user_login", UserLoginStageViewSet)
router.register("stages/user_logout", UserLogoutStageViewSet)
router.register("stages/user_write", UserWriteStageViewSet)

View File

@ -14,7 +14,7 @@ LOGGER = get_logger()
class UserDeleteStageView(FormView, AuthenticationStage):
"""Finalise Enrollment flow by creating a user object."""
"""Finalise unenrollment flow by deleting the user object."""
form_class = UserDeleteForm

View File

@ -26,6 +26,21 @@ class TestUserDeleteStage(TestCase):
self.stage = UserDeleteStage.objects.create(name="delete")
FlowStageBinding.objects.create(flow=self.flow, stage=self.stage, order=2)
def test_no_user(self):
"""Test without user set"""
plan = FlowPlan(flow_pk=self.flow.pk.hex, stages=[self.stage])
session = self.client.session
session[SESSION_KEY_PLAN] = plan
session.save()
response = self.client.get(
reverse(
"passbook_flows:flow-executor", kwargs={"flow_slug": self.flow.slug}
)
)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("passbook_flows:denied"))
def test_user_delete_get(self):
"""Test Form render"""
plan = FlowPlan(flow_pk=self.flow.pk.hex, stages=[self.stage])