Exemplo n.º 1
0
 def test_token_password_change_wrong_token(self):
     from por.dashboard.security.views import change_password
     request = Request(method='POST', params={'token': u'notexistingtoken',
                                              'password': '******',
                                              'password_repeat': 'topsecret'})
     response = change_password(request)
     self.assertEqual(response['request'].msgs[0].message, u'Token doesn\'t exist.')
Exemplo n.º 2
0
 def test_token_password_change_missmatch(self):
     email = u'*****@*****.**'
     self.add_user(email)
     token = self.generate_token(email)['token']
     from por.dashboard.security.views import change_password
     request = Request(method='POST', params={'token': token,
                                              'password': '******',
                                              'password_repeat': 'missmatch'})
     response = change_password(request)
     self.assertEqual(response['request'].msgs[0].message, u'Passwords missmatch.')
Exemplo n.º 3
0
 def test_password_set(self):
     email = u'*****@*****.**'
     self.add_user(email)
     session = DBSession()
     self.assertEqual(session.query(User).filter_by(email=email).one().password, None)
     token = self.generate_token(email)['token']
     from por.dashboard.security.views import change_password
     request = Request(method='POST', params={'token': token,
                                              'password': '******',
                                              'password_repeat': 'topsecret'})
     response = change_password(request)
     self.assertEqual(response.headers.get('Location'),'/login_form')
     self.assertNotEqual(session.query(User).filter_by(email=email).one().password, None)
Exemplo n.º 4
0
 def test_token_store_cleanup(self):
     email = u'*****@*****.**'
     self.add_user(email)
     self.generate_token(email)['token']
     token2 = self.generate_token(email)['token']
     session = DBSession()
     self.assertEqual(len(session.query(PasswordResetToken).join(User).filter(User.email == email).all()),1)
     from por.dashboard.security.views import change_password
     request = Request(method='POST', params={'token': token2,
                                              'password': '******',
                                              'password_repeat': 'topsecret'})
     response = change_password(request)
     self.assertEqual(response.headers.get('Location'),'/login_form')
     self.assertEqual(len(session.query(PasswordResetToken).join(User).filter(User.email == email).all()),0)
Exemplo n.º 5
0
    def test_token_password_change(self):
        from pyramid_mailer import get_mailer
        email = u'*****@*****.**'
        self.add_user(email)
        response = self.generate_token(email)
        mailer = get_mailer(response['request'])
        self.assertTrue(len(mailer.outbox))

        from por.dashboard.security.views import change_password
        request = Request(method='POST', params={'token': response['token'],
                                                 'password': '******',
                                                 'password_repeat': 'topsecret'})
        response = change_password(request)
        self.assertEqual(response.headers.get('Location'),'/login_form')