cubicweb/pyramid/test/test_login.py
branch3.24
changeset 11816 6392f34fcdad
parent 11631 faf279e33298
child 11924 4c949c28ce59
equal deleted inserted replaced
11815:d63140bd4d6e 11816:6392f34fcdad
       
     1 from os.path import join
       
     2 from shutil import rmtree
       
     3 
     1 from cubicweb.pyramid.test import PyramidCWTest
     4 from cubicweb.pyramid.test import PyramidCWTest
     2 
     5 
     3 
     6 
     4 class LoginTest(PyramidCWTest):
     7 class LoginTest(PyramidCWTest):
     5     def test_login_form(self):
     8     def test_login_form(self):
    39         self.assertNotIn('auth_tkt', cookies)
    42         self.assertNotIn('auth_tkt', cookies)
    40         self.assertIn('pauth_tkt', cookies)
    43         self.assertIn('pauth_tkt', cookies)
    41         self.assertIsNotNone(cookies['pauth_tkt'].expires)
    44         self.assertIsNotNone(cookies['pauth_tkt'].expires)
    42 
    45 
    43     def test_login_bad_password(self):
    46     def test_login_bad_password(self):
    44         res = self.webapp.post('/login', {
    47         self.config.i18ncompile(['en', 'fr'])
    45             '__login': self.admlogin, '__password': 'empty'}, status=403)
    48         try:
    46         self.assertIn('Authentication failed', res.text)
    49             self.config._gettext_init()
       
    50             res = self.webapp.post(
       
    51                 '/login',
       
    52                 {'__login': self.admlogin, '__password': 'empty'},
       
    53                 headers={'Accept-Language': 'fr'},
       
    54                 status=403)
       
    55         finally:
       
    56             rmtree(join(self.config.apphome, 'i18n'))
       
    57         self.assertIn(u"\xc9chec de l'authentification", res.text)
    47 
    58 
    48 
    59 
    49 if __name__ == '__main__':
    60 if __name__ == '__main__':
    50     from unittest import main
    61     from unittest import main
    51     main()
    62     main()