Beispiel #1
0
    def test_login_unvalidated(self):
        from ptahcrowd import login
        from ptahcrowd.provider import CrowdUser

        user = CrowdUser(username='******',
                         email='email',
                         password='******')
        CrowdUser.__type__.add(user)

        user.validated = False

        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD)
        cfg['allow-unvalidated'] = False

        request = self.make_request(POST={
            'login': '******',
            'password': '******'
        })
        request.environ['HTTP_HOST'] = 'example.com'

        form = login.LoginForm(None, request)
        form.update_form()
        form.login_handler()

        self.assertIn('Account is not validated.', request.render_messages())
Beispiel #2
0
    def test_login_unvalidated(self):
        from ptahcrowd import login
        from ptahcrowd.provider import CrowdUser

        user = CrowdUser(name="name", login="******", email="email", password="******")
        CrowdUser.__type__.add(user)

        uri = user.__uri__
        user.validated = False

        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD)
        cfg["allow-unvalidated"] = False

        request = DummyRequest(POST={"login": "******", "password": "******"})
        request.environ["HTTP_HOST"] = "example.com"

        form = login.LoginForm(None, request)
        form.update()
        form.login_handler()

        self.assertIn("Account is not validated.", ptah.render_messages(request))
Beispiel #3
0
    def test_login_unvalidated(self):
        from ptahcrowd import login
        from ptahcrowd.provider import CrowdUser

        user = CrowdUser(username='******', email='email',
                         password='******')
        CrowdUser.__type__.add(user)

        user.validated = False

        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD)
        cfg['allow-unvalidated'] = False

        request = self.make_request(
            POST={'login': '******', 'password': '******'})
        request.environ['HTTP_HOST'] = 'example.com'

        form = login.LoginForm(None, request)
        form.update_form()
        form.login_handler()

        self.assertIn('Account is not validated.',request.render_messages())
Beispiel #4
0
    def test_validate(self):
        from ptahcrowd import validation
        from ptahcrowd.provider import CrowdUser

        user = CrowdUser(username='******', email='email')
        CrowdUser.__type__.add(user)

        t = ptah.token.service.generate(validation.TOKEN_TYPE, user.__uri__)

        res = validation.validate(self.request)
        self.assertIsInstance(res, HTTPFound)
        self.assertIn(
            "Can't validate email address.", self.request.render_messages())

        user.validated = False
        self.request.GET['token'] = t
        self.request.session.clear()

        res = validation.validate(self.request)
        self.assertIn("Account has been successfully validated.",
                      self.request.render_messages())

        self.assertTrue(user.validated)