Ejemplo n.º 1
0
    def test_verify_identity_invalid_token_only_show_instruction_template(self):

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token='foobar', email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)
Ejemplo n.º 2
0
    def test_verify_identity_mismatch_token_type_fail(self):
        token = LoginToken.objects.create(token_type=AUTH_TOKEN, value='foobarbaz', user=self.user)

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token=token.value, email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)
Ejemplo n.º 3
0
    def test_verify_identity_invalid_token_only_show_instruction_template(
            self):

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token='foobar', email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)
Ejemplo n.º 4
0
    def test_verify_identity_no_token_fallback_to_template_render(self):

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        res = ViewClass(self.request, token="", email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)

        assert_equals(type(res), TemplateResponse)
Ejemplo n.º 5
0
    def test_verify_idenitity_while_anonymous_activate_user_and_delete_token(self):
        token = self.user.create_token(token_type=MAIL_TOKEN)
        verify_mail = b64encode(self.user.email)

        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token=token.value, email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(True, updated_user.is_active)
        assert_equals(True, updated_user.mail_verified)
        assert_raises(LoginToken.DoesNotExist, lambda: LoginToken.objects.get(token_type=MAIL_TOKEN, value=token.value))
Ejemplo n.º 6
0
    def test_verify_identity_no_token_fallback_to_template_render(self):

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        res = ViewClass(self.request, token="", email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)

        assert_equals(type(res), TemplateResponse)
Ejemplo n.º 7
0
    def test_verify_identity_mismatch_token_type_fail(self):
        token = LoginToken.objects.create(token_type=AUTH_TOKEN,
                                          value='foobarbaz',
                                          user=self.user)

        verify_mail = b64encode(self.user.email)
        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token=token.value, email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(False, updated_user.is_active)
        assert_equals(False, updated_user.mail_verified)
Ejemplo n.º 8
0
    def test_verify_idenitity_while_anonymous_activate_user_and_delete_token(
            self):
        token = self.user.create_token(token_type=MAIL_TOKEN)
        verify_mail = b64encode(self.user.email)

        ViewClass = IdentityVerifyView.as_view()
        ViewClass(self.request, token=token.value, email=verify_mail)

        updated_user = Identity.objects.get(pk=self.user.pk)

        assert_equals(True, updated_user.is_active)
        assert_equals(True, updated_user.mail_verified)
        assert_raises(
            LoginToken.DoesNotExist,
            lambda: LoginToken.objects.get(token_type=MAIL_TOKEN,
                                           value=token.value))
Ejemplo n.º 9
0
    url(r'^login/recovery/(?P<origin_site>\d+)/$', RecoveryLoginView.as_view(), name='login-recovery'),

    url(r'^login/$', LoginView.as_view(), name='login'),  # dummy url
    url(r'^login/(?P<origin_site>\d+)/$', LoginView.as_view(), name='login'),
    url(r'^login/(?P<origin_site>\d+)/(?P<next_url>\S+)/$', LoginView.as_view(), name='login'),

    url(r'^logout/$', LogoutView.as_view(), name='logout'),  # dummy url
    url(r'^logout/(?P<origin_site>\d+)/$', LogoutView.as_view(), name='logout'),
    url(r'^logout/(?P<origin_site>\d+)/(?P<next_url>\S+)/$', LogoutView.as_view(), name='logout'),

    url(r'^register/$', CreateIdentityView.as_view(), name='register'),  # dummy url
    url(r'^register/(?P<origin_site>\d+)/$', CreateIdentityView.as_view(), name='register'),
    url(r'^register/(?P<origin_site>\d+)/(?P<next_url>\S+)/$', CreateIdentityView.as_view(), name='create_identity'),

    #each of these urls below should start w/ the same string
    #there's middleware which controls inactive account if: url.startswith(reverse('verify_identity'))
    url(r'^verify/$', IdentityVerifyView.as_view(), name='verify_identity'),
    url(r'^verify/(?P<email>[A-Za-z0-9=]+)/(?P<token>\w+)/$', IdentityVerifyView.as_view(), name='verify_identity'),

    url(r'^verify/resend/$', IdentityVerifyResend.as_view(), name='verify_resend'),
    # ^ each of these urls above should start w/ the same string

    url(r'^password-change/$', PasswordChangeView.as_view(), name='password_change'),
    url(r'^password-recovery/$', PasswordRecoveryRequestView.as_view(), name='password_recovery'),
    url(r'^password-recovery/finish/(?P<email>[A-Za-z0-9=]+)/(?P<token>\S+)/$', PasswordResetView.as_view(), name='recovery_finish'),
    url(r'^password-recovery/finish/$', FinishRecoveryView.as_view(), name='recovery_finish'),

    url(r'^$', LoginView.as_view(), name='homepage')
)
Ejemplo n.º 10
0
        name='logout'),
    url(r'^logout/(?P<origin_site>\d+)/(?P<next_url>\S+)/$',
        LogoutView.as_view(),
        name='logout'),
    url(r'^register/$', CreateIdentityView.as_view(),
        name='register'),  #dummy url
    url(r'^register/(?P<origin_site>\d+)/$',
        CreateIdentityView.as_view(),
        name='register'),
    url(r'^register/(?P<origin_site>\d+)/(?P<next_url>\S+)/$',
        CreateIdentityView.as_view(),
        name='create_identity'),

    #each of these urls below should start w/ the same string
    #there's middleware which controls inactive account if: url.startswith(reverse('verify_identity'))
    url(r'^verify/$', IdentityVerifyView.as_view(), name='verify_identity'),
    url(r'^verify/(?P<email>[A-Za-z0-9=]+)/(?P<token>\w+)/$',
        IdentityVerifyView.as_view(),
        name='verify_identity'),
    url(r'^verify/resend/$',
        IdentityVerifyResend.as_view(),
        name='verify_resend'),
    # ^ each of these urls above should start w/ the same string
    url(r'^password-change/$',
        PasswordChangeView.as_view(),
        name='password_change'),
    url(r'^password-recovery/$',
        PasswordRecoveryRequestView.as_view(),
        name='password_recovery'),
    url(r'^password-recovery/finish/(?P<email>[A-Za-z0-9=]+)/(?P<token>\S+)/$',
        PasswordResetView.as_view(),