Ejemplo n.º 1
0
    def test_change_password_user_back(self):
        from ptah.crowd.module import UserWrapper
        from ptah.crowd.user import ChangePasswordForm

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.back': 'Back'})
        wrapper = UserWrapper(user, request)

        view = ChangePasswordForm(wrapper, request)
        try:
            view.update()
        except Exception, res:
            pass
Ejemplo n.º 2
0
    def test_change_password(self):
        from ptah.crowd.module import UserWrapper
        from ptah.crowd.user import ChangePasswordForm

        user = self._user()
        f = ChangePasswordForm(None, None)

        request = DummyRequest(
            POST = {'form.buttons.change': 'Change',
                    'password': '******',
                    ChangePasswordForm.csrfname: f.token})
        wrapper = UserWrapper(user, request)

        view = ChangePasswordForm(wrapper, request)
        view.update()

        self.assertEqual(user.password, '{plain}12345')
Ejemplo n.º 3
0
    def test_change_password_forbidden(self):
        from ptah.crowd.module import UserWrapper
        from ptah.crowd.user import ChangePasswordForm

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.change': 'Change',
                    'password': '******',
                    })
        wrapper = UserWrapper(user, request)

        view = ChangePasswordForm(wrapper, request)
        try:
            view.update()
        except Exception, res:
            pass
Ejemplo n.º 4
0
    def test_change_password_error(self):
        from ptah.crowd.module import UserWrapper
        from ptah.crowd.user import ChangePasswordForm

        user = self._user()
        f = ChangePasswordForm(None, None)

        request = DummyRequest(
            POST = {'form.buttons.change': 'Change',
                    ChangePasswordForm.csrfname: f.token})
        wrapper = UserWrapper(user, request)

        view = ChangePasswordForm(wrapper, request)
        view.update()

        self.assertIn(
            'Please fix indicated errors.',
            request.session['msgservice'][0])